Skip to content

Commit

Permalink
Made anchor visuals generic (space-wizards#33810)
Browse files Browse the repository at this point in the history
Added a generic anchor visuals enum
  • Loading branch information
TGRCdev authored Dec 11, 2024
1 parent 7b681b6 commit 89522e7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ private void OnAnchorChanged(EntityUid uid, GasPortableComponent portable, ref A
return;

portableNode.ConnectionsEnabled = args.Anchored;

if (EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
{
_appearance.SetData(uid, GasPortableVisuals.ConnectedState, args.Anchored, appearance);
}
}

public bool FindGasPortIn(EntityUid? gridId, EntityCoordinates coordinates, [NotNullWhen(true)] out GasPortComponent? port)
Expand Down

This file was deleted.

19 changes: 19 additions & 0 deletions Content.Shared/Construction/EntitySystems/AnchorableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public sealed partial class AnchorableSystem : EntitySystem
[Dependency] private readonly SharedToolSystem _tool = default!;
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;

private EntityQuery<PhysicsComponent> _physicsQuery;

Expand All @@ -47,6 +48,18 @@ public override void Initialize()
SubscribeLocalEvent<AnchorableComponent, TryAnchorCompletedEvent>(OnAnchorComplete);
SubscribeLocalEvent<AnchorableComponent, TryUnanchorCompletedEvent>(OnUnanchorComplete);
SubscribeLocalEvent<AnchorableComponent, ExaminedEvent>(OnAnchoredExamine);
SubscribeLocalEvent<AnchorableComponent, ComponentStartup>(OnAnchorStartup);
SubscribeLocalEvent<AnchorableComponent, AnchorStateChangedEvent>(OnAnchorStateChange);
}

private void OnAnchorStartup(EntityUid uid, AnchorableComponent comp, ComponentStartup args)
{
_appearance.SetData(uid, AnchorVisuals.Anchored, Transform(uid).Anchored);
}

private void OnAnchorStateChange(EntityUid uid, AnchorableComponent comp, AnchorStateChangedEvent args)
{
_appearance.SetData(uid, AnchorVisuals.Anchored, args.Anchored);
}

/// <summary>
Expand Down Expand Up @@ -343,3 +356,9 @@ private sealed partial class TryAnchorCompletedEvent : SimpleDoAfterEvent
{
}
}

[Serializable, NetSerializable]
public enum AnchorVisuals : byte
{
Anchored
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- type: Appearance
- type: GenericVisualizer
visuals:
enum.GasPortableVisuals.ConnectedState:
enum.AnchorVisuals.Anchored:
connectedToPort:
False: { state: can-connector, visible: false }
True: { state: can-connector, visible: true }
Expand Down

0 comments on commit 89522e7

Please sign in to comment.