Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invert the Running/Walking States #485

Merged
merged 8 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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: 7 additions & 3 deletions Content.IntegrationTests/Tests/Slipping/SlippingTest.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#nullable enable
using System.Collections.Generic;
using Content.IntegrationTests.Tests.Interaction;
using Content.Shared.CCVar;
using Content.Shared.Movement.Components;
using Content.Shared.Slippery;
using Content.Shared.Stunnable;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.Input;
using Robust.Shared.IoC;
using Robust.Shared.Maths;

namespace Content.IntegrationTests.Tests.Slipping;
Expand All @@ -14,6 +17,7 @@ public sealed class SlippingTest : MovementTest
{
public sealed class SlipTestSystem : EntitySystem
{
[Dependency] public readonly IConfigurationManager Config = default!;
public HashSet<EntityUid> Slipped = new();
public override void Initialize()
{
Expand All @@ -30,6 +34,7 @@ private void OnSlip(EntityUid uid, SlipperyComponent component, ref SlipEvent ar
public async Task BananaSlipTest()
{
var sys = SEntMan.System<SlipTestSystem>();
var sprintWalks = sys.Config.GetCVar(CCVars.GamePressToSprint);
await SpawnTarget("TrashBananaPeel");

var modifier = Comp<MovementSpeedModifierComponent>(Player).SprintSpeedModifier;
Expand All @@ -42,7 +47,7 @@ public async Task BananaSlipTest()
#pragma warning restore NUnit2045

// Walking over the banana slowly does not trigger a slip.
await SetKey(EngineKeyFunctions.Walk, BoundKeyState.Down);
await SetKey(EngineKeyFunctions.Walk, sprintWalks ? BoundKeyState.Up : BoundKeyState.Down);
await Move(DirectionFlag.East, 1f);
#pragma warning disable NUnit2045
Assert.That(Delta(), Is.LessThan(0.5f));
Expand All @@ -51,10 +56,9 @@ public async Task BananaSlipTest()
AssertComp<KnockedDownComponent>(false, Player);

// Moving at normal speeds does trigger a slip.
await SetKey(EngineKeyFunctions.Walk, BoundKeyState.Up);
await SetKey(EngineKeyFunctions.Walk, sprintWalks ? BoundKeyState.Down : BoundKeyState.Up);
await Move(DirectionFlag.West, 1f);
Assert.That(sys.Slipped, Does.Contain(SEntMan.GetEntity(Player)));
AssertComp<KnockedDownComponent>(true, Player);
}
}

7 changes: 7 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,13 @@ public static readonly CVarDef<bool>
public static readonly CVarDef<bool> GameAutoEatDrinks =
CVarDef.Create("game.auto_eat_drinks", false, CVar.REPLICATED);


/// <summary>
/// When true, you have to press the change speed button to sprint.
/// </summary>
public static readonly CVarDef<bool> GamePressToSprint =
CVarDef.Create("game.press_to_sprint", true, CVar.REPLICATED);

#if EXCEPTION_TOLERANCE
/// <summary>
/// Amount of times round start must fail before the server is shut down.
Expand Down
11 changes: 0 additions & 11 deletions Content.Shared/Movement/Components/CanWalkComponent.cs

This file was deleted.

7 changes: 6 additions & 1 deletion Content.Shared/Movement/Components/InputMoverComponent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Numerics;
using Content.Shared.Alert;
using Content.Shared.CCVar;
using Content.Shared.Movement.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
Expand Down Expand Up @@ -72,7 +74,10 @@ public sealed partial class InputMoverComponent : Component

public const float LerpTime = 1.0f;

public bool Sprinting => (HeldMoveButtons & MoveButtons.Walk) == 0x0;
//NOTE I don't think I'm supposed to do this
public bool Sprinting => IoCManager.Resolve<IConfigurationManager>().GetCVar(CCVars.GamePressToSprint)
? (HeldMoveButtons & MoveButtons.Walk) != 0x0
: (HeldMoveButtons & MoveButtons.Walk) == 0x0;

[ViewVariables(VVAccess.ReadWrite)]
public bool CanMove = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public sealed partial class MovementSpeedModifierComponent : Component
public const float DefaultFriction = 20f;
public const float DefaultFrictionNoInput = 20f;

public const float DefaultBaseWalkSpeed = 2.5f;
public const float DefaultBaseSprintSpeed = 4.5f;
public const float DefaultBaseWalkSpeed = 3f;
DEATHB4DEFEAT marked this conversation as resolved.
Show resolved Hide resolved
public const float DefaultBaseSprintSpeed = 5f;

[AutoNetworkedField, ViewVariables]
public float WalkSpeedModifier = 1.0f;
Expand Down
8 changes: 3 additions & 5 deletions Content.Shared/Movement/Systems/SharedMoverController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,10 @@ protected void HandleMobMovement(
PhysicsSystem.SetAngularVelocity(physicsUid, 0, body: physicsComponent);
}

public void WalkingAlert(EntityUid player, bool walking)
private void WalkingAlert(EntityUid player, bool walking)
{
if (HasComp<CanWalkComponent>(player))
{
_alerts.ShowAlert(player, AlertType.Walking, walking ? (short) 0 : (short) 1);
}
walking = _configManager.GetCVar(CCVars.GamePressToSprint) ? !walking : walking;
_alerts.ShowAlert(player, AlertType.Walking, walking ? (short) 0 : (short) 1);
}

public void LerpRotation(EntityUid uid, InputMoverComponent mover, float frameTime)
Expand Down
4 changes: 2 additions & 2 deletions Resources/Locale/en-US/escape-menu/ui/options-menu.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ ui-options-header-dev = Development
ui-options-header-general = General

ui-options-hotkey-keymap = Use US QWERTY Keys
ui-options-hotkey-toggle-walk = Toggle Walk
ui-options-hotkey-toggle-walk = Toggle Speed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite sure about this, same reason with it being an optional change. You could make two separate Loc strings, one for walk and one for sprint, that wouldn't be unreasonable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an engine bind, I cannot make it switch between two locales.


ui-options-function-move-up = Move Up
ui-options-function-move-left = Move Left
ui-options-function-move-down = Move Down
ui-options-function-move-right = Move Right
ui-options-function-walk = Walk
ui-options-function-walk = Change Speed

ui-options-function-camera-rotate-left = Rotate left
ui-options-function-camera-rotate-right = Rotate right
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@
understands:
- GalacticCommon
- RobotTalk
- type: CanWalk

- type: entity
id: BaseBorgChassisNT
Expand Down
1 change: 0 additions & 1 deletion Resources/Prototypes/Entities/Mobs/NPCs/animals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,6 @@
tags:
- VimPilot
- DoorBumpOpener
- type: CanWalk

- type: entity
name: monkey
Expand Down
1 change: 0 additions & 1 deletion Resources/Prototypes/Entities/Mobs/NPCs/elemental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@
solution: bloodstream
- type: DrainableSolution
solution: bloodstream
- type: CanWalk

- type: entity
name: Reagent Slime Spawner
Expand Down
1 change: 0 additions & 1 deletion Resources/Prototypes/Entities/Mobs/NPCs/regalrat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@
understands:
- GalacticCommon
- Mouse
- type: CanWalk

- type: entity
id: MobRatKingBuff
Expand Down
1 change: 0 additions & 1 deletion Resources/Prototypes/Entities/Mobs/NPCs/slimes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
speechSounds: Slime
- type: TypingIndicator
proto: slime
- type: CanWalk

- type: entity
name: blue slime
Expand Down
1 change: 0 additions & 1 deletion Resources/Prototypes/Entities/Mobs/Species/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@
- CanPilot
- FootstepSound
- DoorBumpOpener
- type: CanWalk

- type: entity
save: false
Expand Down
5 changes: 2 additions & 3 deletions Resources/Prototypes/Entities/Mobs/Species/harpy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@
False: {visible: false}
True: {visible: true}
- type: MovementSpeedModifier
baseWalkSpeed: 2.5
baseSprintSpeed: 5.0
baseWalkSpeed: 3
baseSprintSpeed: 5.5
DEATHB4DEFEAT marked this conversation as resolved.
Show resolved Hide resolved
weightlessAcceleration: 2.5
- type: Inventory
speciesId: harpy
Expand All @@ -140,7 +140,6 @@
understands:
- GalacticCommon
- SolCommon

- type: entity
save: false
name: Urist McHands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
- type: GuideHelp
guides:
- Robotics
- type: CanWalk

- type: entity
id: MechRipley
Expand Down
Loading