-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* make draw depth stuff reusable and good * rodentia crawling refactor --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
- Loading branch information
1 parent
f95171c
commit 92a1e0d
Showing
9 changed files
with
250 additions
and
227 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
Content.Client/_DV/Abilities/DrawDepthVisualizerComponent.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,25 @@ | ||
using DrawDepth = Content.Shared.DrawDepth.DrawDepth; | ||
|
||
namespace Content.Client._DV.Abilities; | ||
|
||
/// <summary> | ||
/// Changes the sprite's draw depth when some appearance data becomes true, reverting it when false. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class DrawDepthVisualizerComponent : Component | ||
{ | ||
/// <summary> | ||
/// Appearance key to check. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public Enum Key; | ||
|
||
/// <summary> | ||
/// The draw depth to set the sprite to when the appearance data is true. | ||
/// </summary> | ||
[DataField(required: true)] | ||
public DrawDepth Depth; | ||
|
||
[DataField] | ||
public int? OriginalDrawDepth; | ||
} |
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,40 @@ | ||
using Content.Shared.DrawDepth; | ||
using Robust.Client.GameObjects; | ||
|
||
namespace Content.Client._DV.Abilities; | ||
|
||
/// <summary> | ||
/// Changes a sprite's draw depth when some appearance data becomes true. | ||
/// </summary> | ||
public sealed class DrawDepthVisualizerSystem : EntitySystem | ||
{ | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<DrawDepthVisualizerComponent, AppearanceChangeEvent>(OnAppearanceChange); | ||
} | ||
|
||
private void OnAppearanceChange(Entity<DrawDepthVisualizerComponent> ent, ref AppearanceChangeEvent args) | ||
{ | ||
if (args.Sprite is not {} sprite || !args.AppearanceData.TryGetValue(ent.Comp.Key, out var value)) | ||
return; | ||
|
||
if (value is true) | ||
{ | ||
if (ent.Comp.OriginalDrawDepth != null) | ||
return; | ||
|
||
ent.Comp.OriginalDrawDepth = sprite.DrawDepth; | ||
sprite.DrawDepth = (int) ent.Comp.Depth; | ||
} | ||
else | ||
{ | ||
if (ent.Comp.OriginalDrawDepth is not {} original) | ||
return; | ||
|
||
sprite.DrawDepth = original; | ||
ent.Comp.OriginalDrawDepth = null; | ||
} | ||
} | ||
} |
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
140 changes: 0 additions & 140 deletions
140
Content.Server/_DV/Abilities/CrawlUnderObjectsSystem.cs
This file was deleted.
Oops, something went wrong.
30 changes: 13 additions & 17 deletions
30
Content.Shared/_DV/Abilities/CrawlUnderObjectsComponent.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,47 +1,43 @@ | ||
using Content.Shared.Actions; | ||
using DrawDepth = Content.Shared.DrawDepth.DrawDepth; | ||
using Robust.Shared.GameStates; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared._DV.Abilities; | ||
|
||
/// <summary> | ||
/// Gives the player an action to sneak under tables at a slower move speed. | ||
/// </summary> | ||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
public sealed partial class CrawlUnderObjectsComponent : Component | ||
{ | ||
[DataField] | ||
public EntityUid? ToggleHideAction; | ||
|
||
[DataField] | ||
public EntProtoId? ActionProto; | ||
[DataField(required: true)] | ||
public EntProtoId ActionProto; | ||
|
||
[DataField] | ||
public bool Enabled = false; | ||
[DataField, AutoNetworkedField] | ||
public bool Enabled; | ||
|
||
/// <summary> | ||
/// List of fixtures that had their collision mask changed. | ||
/// Required for re-adding the collision mask. | ||
/// </summary> | ||
[DataField, AutoNetworkedField] | ||
public List<(string key, int originalMask)> ChangedFixtures = new(); | ||
|
||
[DataField] | ||
public int? OriginalDrawDepth; | ||
public List<(string key, int originalMask)> ChangedFixtures = new(); | ||
|
||
[DataField] | ||
public float SneakSpeedModifier = 0.7f; | ||
} | ||
|
||
[Serializable, NetSerializable] | ||
public enum SneakMode : byte | ||
public enum SneakingVisuals : byte | ||
{ | ||
Enabled | ||
Sneaking | ||
} | ||
|
||
public sealed partial class ToggleCrawlingStateEvent : InstantActionEvent { } | ||
public sealed partial class ToggleCrawlingStateEvent : InstantActionEvent; | ||
|
||
[Serializable, NetSerializable] | ||
public sealed partial class CrawlingUpdatedEvent(bool enabled = false) : EventArgs | ||
{ | ||
public readonly bool Enabled = enabled; | ||
} | ||
[ByRefEvent] | ||
public readonly record struct CrawlingUpdatedEvent(bool Enabled, CrawlUnderObjectsComponent Comp); |
Oops, something went wrong.