-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(traits): add new trait Slow and Steady
Also fixes a bug with Sluggish and Snail-Paced not applying their speed modifiers until an entity gets their movement speed adjusted.
- Loading branch information
1 parent
ba9a937
commit aa28b49
Showing
11 changed files
with
129 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
Content.Server/Traits/Assorted/TraitSpeedModifierSystem.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
Content.Shared/Traits/Assorted/Components/SlipImmunityComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Traits.Assorted.Components; | ||
|
||
/// <summary> | ||
/// This is used for traits that make an entity immune to slips | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class SlipImmunityComponent : Component | ||
{ | ||
} |
12 changes: 12 additions & 0 deletions
12
Content.Shared/Traits/Assorted/Components/SpeedModifierImmunityComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Traits.Assorted.Components; | ||
|
||
/// <summary> | ||
/// This is used to make an entity's movement speed constant and | ||
/// never affected by almost all movement speed modifiers. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent] | ||
public sealed partial class SpeedModifierImmunityComponent : Component | ||
{ | ||
} |
10 changes: 6 additions & 4 deletions
10
...s/Assorted/TraitSpeedModifierComponent.cs → ...Components/TraitSpeedModifierComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
namespace Content.Server.Traits.Assorted; | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Traits.Assorted.Components; | ||
|
||
/// <summary> | ||
/// This component is used for traits that modify movement speed. | ||
/// </summary> | ||
[RegisterComponent] | ||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
public sealed partial class TraitSpeedModifierComponent : Component | ||
{ | ||
[DataField(required: true)] | ||
[DataField, AutoNetworkedField] | ||
public float WalkModifier = 1.0f; | ||
|
||
[DataField(required: true)] | ||
[DataField, AutoNetworkedField] | ||
public float SprintModifier = 1.0f; | ||
} |
19 changes: 19 additions & 0 deletions
19
Content.Shared/Traits/Assorted/Systems/SlipImmunitySystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Content.Shared.Slippery; | ||
using Content.Shared.Traits.Assorted.Components; | ||
|
||
namespace Content.Shared.Traits.Assorted.Systems; | ||
|
||
public sealed class SlipImmunitySystem : EntitySystem | ||
{ | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<SlipImmunityComponent, SlipAttemptEvent>(OnSlipAttempt); | ||
} | ||
|
||
private void OnSlipAttempt(EntityUid uid, SlipImmunityComponent component, ref SlipAttemptEvent args) | ||
{ | ||
args.Cancel(); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Content.Shared/Traits/Assorted/Systems/TraitSpeedModifierSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Content.Shared.Movement.Components; | ||
using Content.Shared.Movement.Systems; | ||
using Content.Shared.Traits.Assorted.Components; | ||
|
||
namespace Content.Shared.Traits.Assorted.Systems; | ||
|
||
public sealed class TraitSpeedModifierSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly MovementSpeedModifierSystem _movement = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<TraitSpeedModifierComponent, ComponentStartup>(OnStartup); | ||
SubscribeLocalEvent<TraitSpeedModifierComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeed); | ||
} | ||
|
||
private void OnRefreshMovementSpeed(EntityUid uid, TraitSpeedModifierComponent component, RefreshMovementSpeedModifiersEvent args) | ||
{ | ||
args.ModifySpeed(component.WalkModifier, component.SprintModifier, bypassImmunity: true); | ||
} | ||
|
||
private void OnStartup(EntityUid uid, TraitSpeedModifierComponent component, ComponentStartup args) | ||
{ | ||
if (!TryComp<MovementSpeedModifierComponent>(uid, out var move)) | ||
return; | ||
|
||
_movement.RefreshMovementSpeedModifiers(uid, move); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters