Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Assets/scenes/minimal.scene
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,16 @@
"Scale": 1,
"ScaleStrategy": "ConsistentHeight",
"ZIndex": 100
},
{
"__type": "Sandbox.HarvestControllerHUD",
"__guid": "647b376a-2067-40a3-9a2c-e7c013792590",
"HarvestPlayer": {
"_type": "component",
"component_id": "c8657ccc-cb8f-4ebb-8304-1bf3653d5f9a",
"go": "7027777f-eaab-46c0-a135-ed9c580259ce",
"component_type": "HarvestPlayer"
}
}
]
},
Expand Down
10 changes: 10 additions & 0 deletions Code/Player/HarvestPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ protected override void OnFixedUpdate()
{
Popup = PopupType.None;
}

ControllerChoices();

if ( _playerController.Velocity.Length > 0f && lastStep >= 70 / _playerController.Velocity.Length && _playerController.IsOnGround )
{
Expand Down Expand Up @@ -137,6 +139,14 @@ public static void Rescue()
}
}

public void ControllerChoices()
{
if ( !Input.UsingController ) return;
if ( !HasCat ) return;

if (Input.Pressed("Harvest")) Harvest();
if (Input.Pressed("Rescue")) Rescue();
}

public void OnKilled()
{
Expand Down
9 changes: 1 addition & 8 deletions Code/Player/ShrimpleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ public class ShrimpleWalker : Component
[Range(100f, 500f, 20f)]
public float RunSpeed { get; set; } = 300f;

[Property]
[Range(25f, 100f, 5f)]
public float DuckSpeed { get; set; } = 50f;

[Property]
[Range(200f, 500f, 20f)]
public float JumpStrength { get; set; } = 350f;
Expand All @@ -44,10 +40,8 @@ protected override void OnFixedUpdate()
base.OnFixedUpdate();

var wishDirection = Input.AnalogMove.Normal * Rotation.FromYaw(EyeAngles.yaw);
var isDucking = Input.Down("Duck");
var isRunning = Input.Down("Run");
var wishSpeed = isDucking ? DuckSpeed :
isRunning ? RunSpeed : WalkSpeed;
var wishSpeed = isRunning ? RunSpeed : WalkSpeed;

Controller.WishVelocity = wishDirection * wishSpeed;
Controller.Move();
Expand All @@ -62,7 +56,6 @@ protected override void OnFixedUpdate()

AnimationHelper.WithWishVelocity(Controller.WishVelocity);
AnimationHelper.WithVelocity(Controller.Velocity);
AnimationHelper.DuckLevel = isDucking ? 1f : 0f;
AnimationHelper.IsGrounded = Controller.IsOnGround;
}

Expand Down
38 changes: 38 additions & 0 deletions Code/UI/HarvestControllerHUD.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@using Sandbox;
@using Sandbox.UI;
@inherits PanelComponent
@namespace Sandbox

@if ( HarvestPlayer.HasCat && Input.UsingController )
{
<root>
<div class="Choices-buttons">
<img [email protected]>
<img [email protected]>
</div>
</root>
}


@code
{

[Property] public HarvestPlayer HarvestPlayer { get; set; }
private Texture HarvestButton { get; set; }
private Texture RescueButton { get; set; }

protected override void OnFixedUpdate()
{
HarvestButton = Input.GetGlyph( "Harvest", InputGlyphSize.Medium, false );
RescueButton = Input.GetGlyph( "Rescue", InputGlyphSize.Medium, false );

Mouse.Visible = !Input.UsingController && HarvestPlayer.HasCat;
//otherwise the cursor type will always default to pointer, for some reason?
Mouse.CursorType = null;
}

/// <summary>
/// the hash determines if the system should be rebuilt. If it changes, it will be rebuilt
/// </summary>
protected override int BuildHash() => System.HashCode.Combine( RescueButton, HarvestButton, HarvestPlayer.HasCat );
}
20 changes: 20 additions & 0 deletions Code/UI/HarvestControllerHUD.razor.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
HarvestControllerHUD
{
position: absolute;
top: 480px;
left: 0;
right: 0;
bottom: 0;
justify-content: center;
align-items: center;
font-weight: bold;
border-radius: 20px;

.Choices-buttons{
flex-direction: row;
justify-content: center;
gap: 325px;
width: 40%;
height: 128px;
}
}
4 changes: 2 additions & 2 deletions Code/UI/HarvestHUD.scss
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ HarvestHUD {
width: 50%;
position: absolute;
bottom: 150px;
pointer-events: all;

cursor: none;
.button {
border-radius: 30px;
flex-shrink: 1;
Expand All @@ -235,6 +234,7 @@ HarvestHUD {
transition: all 0.1s ease-in;
align-items: center;
justify-content: center;
pointer-events: all;

.title {
font-family: "Chewy";
Expand Down
14 changes: 13 additions & 1 deletion ProjectSettings/Input.config
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,26 @@
{
"Name": "Pick",
"KeyboardCode": "e",
"GamepadCode": "Y",
"GamepadCode": "A",
"GroupName": "Actions"
},
{
"Name": "Inventory",
"KeyboardCode": "tab",
"GamepadCode": "SwitchLeftMenu",
"GroupName": "Other"
},
{
"Name": "Harvest",
"KeyboardCode": "ins",
"GamepadCode": "X",
"GroupName": "Other"
},
{
"Name": "Rescue",
"KeyboardCode": "del",
"GamepadCode": "Y",
"GroupName": "Other"
}
],
"__guid": "b45f516a-555b-4595-911a-31df09a8874e",
Expand Down