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

rodentia crawling refactor #2754

Merged
merged 2 commits into from
Jan 16, 2025
Merged
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
44 changes: 0 additions & 44 deletions Content.Client/_DV/Abilities/CrawlUnderObjectsSystem.cs

This file was deleted.

25 changes: 25 additions & 0 deletions Content.Client/_DV/Abilities/DrawDepthVisualizerComponent.cs
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;
}
40 changes: 40 additions & 0 deletions Content.Client/_DV/Abilities/DrawDepthVisualizerSystem.cs
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;
}
}
}
3 changes: 2 additions & 1 deletion Content.Server/Entry/IgnoredComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public static class IgnoredComponents
"InventorySlots",
"LightFade",
"HolidayRsiSwap",
"OptionsVisualizer"
"OptionsVisualizer",
"DrawDepthVisualizer" // DeltaV
};
}
}
140 changes: 0 additions & 140 deletions Content.Server/_DV/Abilities/CrawlUnderObjectsSystem.cs

This file was deleted.

30 changes: 13 additions & 17 deletions Content.Shared/_DV/Abilities/CrawlUnderObjectsComponent.cs
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);
Loading
Loading