From a79f85248b27c3f0937be9d3aa823ef9ec6640b3 Mon Sep 17 00:00:00 2001 From: InsoPL Date: Sat, 20 Jun 2026 23:45:43 +0200 Subject: [PATCH] Directional arrow (#118) * arrow * yoink orginal arrow rsi * done * fixes * i just learnd about ignored components * Update Content.Client/DirectionalArrowIndicator/DirectionalArrowIndicatorComponent.cs Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> * customArrows * docs * more docs * teg and blue arrow * misc * fixes * remove color * imma dummy * meta * soon to obsolete * class not partial --------- Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> --- .../DirectionalArrowIndicatorComponent.cs | 49 ++++++++++++++++ .../DirectionalArrowIndicatorSystem.cs | 42 ++++++++++++++ Content.Client/Doors/TurnstileSystem.cs | 8 --- .../Generation/Teg/TegCirculatorComponent.cs | 8 --- .../Power/Generation/Teg/TegSystem.cs | 29 ---------- Content.Server/Entry/IgnoredComponents.cs | 3 +- .../Markers/directional_arrow_indicator.yml | 34 +++++++++++ .../Entities/Structures/Doors/turnstile.yml | 18 +----- .../Entities/Structures/Machines/recycler.yml | 6 +- .../Structures/Power/Generation/teg.yml | 27 +++------ .../blue_arrow.png} | Bin .../directional_arrow_indicator.rsi/meta.json | 53 ++++++++++++++++++ .../red_arrow.png} | Bin .../Textures/Markers/teg_arrow.rsi/meta.json | 15 ----- .../Structures/Doors/turnstile.rsi/meta.json | 20 +------ 15 files changed, 194 insertions(+), 118 deletions(-) create mode 100644 Content.Client/DirectionalArrowIndicator/DirectionalArrowIndicatorComponent.cs create mode 100644 Content.Client/DirectionalArrowIndicator/DirectionalArrowIndicatorSystem.cs delete mode 100644 Content.Client/Power/Generation/Teg/TegCirculatorComponent.cs delete mode 100644 Content.Client/Power/Generation/Teg/TegSystem.cs create mode 100644 Resources/Prototypes/Entities/Markers/directional_arrow_indicator.yml rename Resources/Textures/Markers/{teg_arrow.rsi/arrow.png => directional_arrow_indicator.rsi/blue_arrow.png} (100%) create mode 100644 Resources/Textures/Markers/directional_arrow_indicator.rsi/meta.json rename Resources/Textures/{Structures/Doors/turnstile.rsi/arrow.png => Markers/directional_arrow_indicator.rsi/red_arrow.png} (100%) delete mode 100644 Resources/Textures/Markers/teg_arrow.rsi/meta.json diff --git a/Content.Client/DirectionalArrowIndicator/DirectionalArrowIndicatorComponent.cs b/Content.Client/DirectionalArrowIndicator/DirectionalArrowIndicatorComponent.cs new file mode 100644 index 0000000000..4cff5fb501 --- /dev/null +++ b/Content.Client/DirectionalArrowIndicator/DirectionalArrowIndicatorComponent.cs @@ -0,0 +1,49 @@ +using Robust.Shared.Prototypes; +using System.Numerics; + +namespace Content.Client.DirectionalArrowIndicator; + +/// +/// Component that manages directional arrow indicators that spawn clientside when an entity is examined. +/// Handled by +/// +[RegisterComponent] +public sealed partial class DirectionalArrowIndicatorComponent : Component +{ + /// + /// The lifetime of the arrow indicator in seconds. + /// + [DataField] + public float Lifetime = 2f; + + /// + /// List of arrows to spawn. + /// + [DataField] + public List Arrows = new(); +} + +/// +/// Data for spawning a single directional arrow. +/// +[DataDefinition] +public sealed partial class ArrowSpawnData +{ + /// + /// Offset relative to entity's position where the arrow should appear. + /// + [DataField] + public Vector2 Offset = Vector2.Zero; + + /// + /// Rotation of the arrow. + /// + [DataField] + public Angle Rotation = Angle.Zero; + + /// + /// Prototype ID of the arrow entity to spawn. + /// + [DataField] + public EntProtoId ArrowType = "RedDirectionalArrowIndicator"; +} diff --git a/Content.Client/DirectionalArrowIndicator/DirectionalArrowIndicatorSystem.cs b/Content.Client/DirectionalArrowIndicator/DirectionalArrowIndicatorSystem.cs new file mode 100644 index 0000000000..aed285d7d5 --- /dev/null +++ b/Content.Client/DirectionalArrowIndicator/DirectionalArrowIndicatorSystem.cs @@ -0,0 +1,42 @@ +using Content.Shared.Examine; +using Robust.Client.GameObjects; +using Robust.Shared.Map; +using Robust.Shared.Spawners; + +namespace Content.Client.DirectionalArrowIndicator; + +/// +/// System responsible for handling s, +/// spawning directional arrow indicators clientside when an entity is examined. +/// +public sealed partial class DirectionalArrowIndicatorSystem : EntitySystem +{ + [Dependency] private TransformSystem _transform = default!; + + private const float EdgeOffset = 0.78125f; // Used for moving arrow to the edge of the tile by default. + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnExamined); + } + + private void OnExamined(Entity ent, ref ExaminedEvent args) + { + var arrows = ent.Comp.Arrows; + var lifetime = ent.Comp.Lifetime; + + if (arrows.Count == 0) + arrows.Add(new ArrowSpawnData()); + + foreach (var arrowData in ent.Comp.Arrows) + { + var spawnedEnt = Spawn(arrowData.ArrowType, new EntityCoordinates(ent, arrowData.Offset.X, arrowData.Offset.Y + EdgeOffset)); + + _transform.SetLocalRotation(spawnedEnt, arrowData.Rotation); + + EnsureComp(spawnedEnt, out var timedDespawn); + timedDespawn.Lifetime = lifetime; + } + } +} diff --git a/Content.Client/Doors/TurnstileSystem.cs b/Content.Client/Doors/TurnstileSystem.cs index 9b201547a3..b9c4af26ae 100644 --- a/Content.Client/Doors/TurnstileSystem.cs +++ b/Content.Client/Doors/TurnstileSystem.cs @@ -15,8 +15,6 @@ public sealed partial class TurnstileSystem : SharedTurnstileSystem [Dependency] private AnimationPlayerSystem _animationPlayer = default!; [Dependency] private SpriteSystem _sprite = default!; - private static readonly EntProtoId ExamineArrow = "TurnstileArrow"; - private const string AnimationKey = "Turnstile"; public override void Initialize() @@ -24,7 +22,6 @@ public sealed partial class TurnstileSystem : SharedTurnstileSystem base.Initialize(); SubscribeLocalEvent(OnAnimationCompleted); - SubscribeLocalEvent(OnExamined); } private void OnAnimationCompleted(Entity ent, ref AnimationCompletedEvent args) @@ -37,11 +34,6 @@ public sealed partial class TurnstileSystem : SharedTurnstileSystem _sprite.LayerSetRsiState((ent.Owner, sprite), TurnstileVisualLayers.Base, new RSI.StateId(ent.Comp.DefaultState)); } - private void OnExamined(Entity ent, ref ExaminedEvent args) - { - Spawn(ExamineArrow, new EntityCoordinates(ent, 0, 0)); - } - protected override void PlayAnimation(EntityUid uid, string stateId) { if (!TryComp(uid, out var animation) || !TryComp(uid, out var sprite)) diff --git a/Content.Client/Power/Generation/Teg/TegCirculatorComponent.cs b/Content.Client/Power/Generation/Teg/TegCirculatorComponent.cs deleted file mode 100644 index f11af1d730..0000000000 --- a/Content.Client/Power/Generation/Teg/TegCirculatorComponent.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Content.Client.Power.Generation.Teg; - -/// -[RegisterComponent] -public sealed partial class TegCirculatorComponent : Component -{ - -} diff --git a/Content.Client/Power/Generation/Teg/TegSystem.cs b/Content.Client/Power/Generation/Teg/TegSystem.cs deleted file mode 100644 index 0ae1b5e496..0000000000 --- a/Content.Client/Power/Generation/Teg/TegSystem.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Content.Client.Examine; -using Robust.Shared.Map; -using Robust.Shared.Prototypes; - -namespace Content.Client.Power.Generation.Teg; - -/// -/// Handles client-side logic for the thermo-electric generator (TEG). -/// -/// -/// -/// TEG circulators show which direction the in- and outlet port is by popping up two floating arrows when examined. -/// -/// -/// -public sealed class TegSystem : EntitySystem -{ - private static readonly EntProtoId ArrowPrototype = "TegCirculatorArrow"; - - public override void Initialize() - { - SubscribeLocalEvent(CirculatorExamined); - } - - private void CirculatorExamined(EntityUid uid, TegCirculatorComponent component, ClientExaminedEvent args) - { - Spawn(ArrowPrototype, new EntityCoordinates(uid, 0, 0)); - } -} diff --git a/Content.Server/Entry/IgnoredComponents.cs b/Content.Server/Entry/IgnoredComponents.cs index a34842c64f..b1bbc3dbd8 100644 --- a/Content.Server/Entry/IgnoredComponents.cs +++ b/Content.Server/Entry/IgnoredComponents.cs @@ -21,7 +21,8 @@ namespace Content.Server.Entry "HolidayRsiSwap", "OptionsVisualizer", "AnomalyScannerScreen", - "MultipartMachineGhost" + "MultipartMachineGhost", + "DirectionalArrowIndicator" }; } } diff --git a/Resources/Prototypes/Entities/Markers/directional_arrow_indicator.yml b/Resources/Prototypes/Entities/Markers/directional_arrow_indicator.yml new file mode 100644 index 0000000000..8141587937 --- /dev/null +++ b/Resources/Prototypes/Entities/Markers/directional_arrow_indicator.yml @@ -0,0 +1,34 @@ +- type: entity + id: RedDirectionalArrowIndicator + categories: [ HideSpawnMenu ] + components: + - type: Sprite + sprite: Markers/directional_arrow_indicator.rsi + layers: + - state: red_arrow + - type: Tag + tags: + - HideContextMenu + +- type: entity + id: BlueDirectionalArrowIndicator + categories: [ HideSpawnMenu ] + components: + - type: Sprite + sprite: Markers/directional_arrow_indicator.rsi + layers: + - state: blue_arrow + - type: Tag + tags: + - HideContextMenu + +- type: entity + id: RedDirectionPointer + name: red direction pointer + description: Holographic arrow that points the way + components: + - type: Sprite + sprite: Markers/directional_arrow_indicator.rsi + layers: + - state: red_arrow + - type: Clickable diff --git a/Resources/Prototypes/Entities/Structures/Doors/turnstile.yml b/Resources/Prototypes/Entities/Structures/Doors/turnstile.yml index 2ec3a0ec59..252fdee3c0 100644 --- a/Resources/Prototypes/Entities/Structures/Doors/turnstile.yml +++ b/Resources/Prototypes/Entities/Structures/Doors/turnstile.yml @@ -60,23 +60,7 @@ - type: Construction graph: Turnstile node: turnstile - -- # Spawned by the client-side turnstile examine code to indicate the direction to pass through. - type: entity - id: TurnstileArrow - categories: [ HideSpawnMenu ] - components: - - type: Sprite - sprite: Structures/Doors/turnstile.rsi - color: "#FFFFFFBB" - layers: - - state: arrow - offset: 0, 0.78125 - - type: TimedDespawn - lifetime: 2 - - type: Tag - tags: - - HideContextMenu + - type: DirectionalArrowIndicator # Genpop diff --git a/Resources/Prototypes/Entities/Structures/Machines/recycler.yml b/Resources/Prototypes/Entities/Structures/Machines/recycler.yml index 2058c3c050..4164a30b1a 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/recycler.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/recycler.yml @@ -1,4 +1,4 @@ -- type: entity +- type: entity id: Recycler parent: BaseMachinePowered name: recycler @@ -58,6 +58,10 @@ map: ["enum.RecyclerVisualLayers.Main"] - type: Appearance - type: RecyclerVisuals + - type: DirectionalArrowIndicator + arrows: + - offset: 0, -1.35 + - offset: 0, 0 - type: CollideMaterialReclaimer - type: MaterialReclaimer diff --git a/Resources/Prototypes/Entities/Structures/Power/Generation/teg.yml b/Resources/Prototypes/Entities/Structures/Power/Generation/teg.yml index 90c33838ca..dc537c35c2 100644 --- a/Resources/Prototypes/Entities/Structures/Power/Generation/teg.yml +++ b/Resources/Prototypes/Entities/Structures/Power/Generation/teg.yml @@ -1,4 +1,4 @@ -- type: entity +- type: entity id: TegCenter name: thermo-electric generator description: A high efficiency generator that uses energy transfer between hot and cold gases to produce electricity. @@ -185,22 +185,9 @@ - type: TegCirculator - type: StealTarget stealGroup: Teg - -- # Spawned by the client-side circulator examine code to indicate the inlet/outlet direction. - type: entity - id: TegCirculatorArrow - categories: [ HideSpawnMenu ] - components: - - type: Sprite - sprite: Markers/teg_arrow.rsi - color: "#FFFFFFBB" - layers: - - state: arrow - offset: 0, 0.75 - - state: arrow - offset: 0, -0.75 - - type: TimedDespawn - lifetime: 2 - - type: Tag - tags: - - HideContextMenu + - type: DirectionalArrowIndicator + arrows: + - offset: 0, -1.5 + arrowType: BlueDirectionalArrowIndicator + - offset: 0, 0 + arrowType: BlueDirectionalArrowIndicator diff --git a/Resources/Textures/Markers/teg_arrow.rsi/arrow.png b/Resources/Textures/Markers/directional_arrow_indicator.rsi/blue_arrow.png similarity index 100% rename from Resources/Textures/Markers/teg_arrow.rsi/arrow.png rename to Resources/Textures/Markers/directional_arrow_indicator.rsi/blue_arrow.png diff --git a/Resources/Textures/Markers/directional_arrow_indicator.rsi/meta.json b/Resources/Textures/Markers/directional_arrow_indicator.rsi/meta.json new file mode 100644 index 0000000000..0df5028f2b --- /dev/null +++ b/Resources/Textures/Markers/directional_arrow_indicator.rsi/meta.json @@ -0,0 +1,53 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "Red arrow by EmoGarbage404 (github), Blue arrow by PJB3005", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "red_arrow", + "delays": [ + [ + 0.5, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1, + 0.1 + ] + ] + }, + { + "name": "blue_arrow", + "delays": [ + [ + 0.033, + 0.033, + 0.033, + 0.033, + 0.033, + 0.033, + 0.033, + 0.033, + 0.033, + 0.033, + 0.033, + 0.033, + 0.033, + 0.033, + 0.033, + 0.033, + 0.033 + ] + ] + } + ] +} diff --git a/Resources/Textures/Structures/Doors/turnstile.rsi/arrow.png b/Resources/Textures/Markers/directional_arrow_indicator.rsi/red_arrow.png similarity index 100% rename from Resources/Textures/Structures/Doors/turnstile.rsi/arrow.png rename to Resources/Textures/Markers/directional_arrow_indicator.rsi/red_arrow.png diff --git a/Resources/Textures/Markers/teg_arrow.rsi/meta.json b/Resources/Textures/Markers/teg_arrow.rsi/meta.json deleted file mode 100644 index 366bdec16f..0000000000 --- a/Resources/Textures/Markers/teg_arrow.rsi/meta.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": 1, - "license": "CC-BY-SA-3.0", - "copyright": "Made by PJB3005", - "size": { - "x": 32, - "y": 32 - }, - "states": [ - { - "name": "arrow", - "delays": [[0.033, 0.033, 0.033, 0.033, 0.033, 0.033, 0.033, 0.033, 0.033, 0.033, 0.033, 0.033, 0.033, 0.033, 0.033, 0.033, 0.033]] - } - ] -} diff --git a/Resources/Textures/Structures/Doors/turnstile.rsi/meta.json b/Resources/Textures/Structures/Doors/turnstile.rsi/meta.json index dea5fb8946..93c4db4e57 100644 --- a/Resources/Textures/Structures/Doors/turnstile.rsi/meta.json +++ b/Resources/Textures/Structures/Doors/turnstile.rsi/meta.json @@ -1,30 +1,12 @@ { "version": 1, "license": "CC-BY-SA-3.0", - "copyright": "Taken from OracleStation at https://github.com/OracleStation/OracleStation/blob/c1046bdd14674dc5a8631074aaa6650770b2937e/icons/obj/turnstile.dmi. Arrow by EmoGarbage404 (github).", + "copyright": "Taken from OracleStation at https://github.com/OracleStation/OracleStation/blob/c1046bdd14674dc5a8631074aaa6650770b2937e/icons/obj/turnstile.dmi.", "size": { "x": 32, "y": 32 }, "states": [ - { - "name": "arrow", - "delays": [ - [ - 0.5, - 0.1, - 0.1, - 0.1, - 0.1, - 0.1, - 0.1, - 0.1, - 0.1, - 0.1, - 0.1 - ] - ] - }, { "name": "turnstile" },