diff --git a/Content.Client/GameObjects/Components/ClientEntitySpawnerComponent.cs b/Content.Client/GameObjects/Components/ClientEntitySpawnerComponent.cs new file mode 100644 index 0000000000..3ba2796272 --- /dev/null +++ b/Content.Client/GameObjects/Components/ClientEntitySpawnerComponent.cs @@ -0,0 +1,56 @@ +#nullable enable +using Robust.Shared.GameObjects; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Serialization; +using System.Collections.Generic; + +namespace Content.Client.GameObjects.Components +{ + /// + /// Spawns a set of entities on the client only, and removes them when this component is removed. + /// + [RegisterComponent] + public class ClientEntitySpawnerComponent : Component + { + public override string Name => "ClientEntitySpawner"; + + private List _prototypes = default!; + + private List _entity = new(); + + public override void ExposeData(ObjectSerializer serializer) + { + base.ExposeData(serializer); + serializer.DataField(ref _prototypes, "prototypes", new List { "HVDummyWire" }); + } + + public override void Initialize() + { + base.Initialize(); + SpawnEntities(); + } + + public override void OnRemove() + { + RemoveEntities(); + base.OnRemove(); + } + + private void SpawnEntities() + { + foreach (var proto in _prototypes) + { + var entity = Owner.EntityManager.SpawnEntity(proto, Owner.Transform.Coordinates); + _entity.Add(entity); + } + } + + private void RemoveEntities() + { + foreach (var entity in _entity) + { + Owner.EntityManager.DeleteEntity(entity); + } + } + } +} diff --git a/Content.Server/IgnoredComponents.cs b/Content.Server/IgnoredComponents.cs index 0be2eccd08..2a06e313f4 100644 --- a/Content.Server/IgnoredComponents.cs +++ b/Content.Server/IgnoredComponents.cs @@ -1,4 +1,4 @@ -namespace Content.Server +namespace Content.Server { public static class IgnoredComponents @@ -18,6 +18,7 @@ "Clickable", "RadiatingLight", "Icon", + "ClientEntitySpawner" }; } diff --git a/Resources/Prototypes/Entities/Constructible/Power/power_base.yml b/Resources/Prototypes/Entities/Constructible/Power/power_base.yml index 02680ecc4f..aa504efbe8 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/power_base.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/power_base.yml @@ -38,6 +38,9 @@ supplyRate: 3000 - type: Anchorable - type: Pullable + - type: ClientEntitySpawner + prototypes: + - HVDummyWire - type: entity id: BaseSmes @@ -93,7 +96,10 @@ activeSupplyRate: 1000 - type: Anchorable - type: Pullable - + - type: ClientEntitySpawner + prototypes: + - HVDummyWire + - type: entity id: BaseSubstation description: Reduces the voltage of electricity put into it. @@ -148,7 +154,11 @@ activeSupplyRate: 1000 - type: Anchorable - type: Pullable - + - type: ClientEntitySpawner + prototypes: + - HVDummyWire + - MVDummyWire + - type: entity id: BaseApc description: A control terminal for the area's electrical systems. @@ -201,7 +211,11 @@ - type: Construction graph: apc node: apc - + - type: ClientEntitySpawner + prototypes: + - MVDummyWire + - LVDummyWire + - type: entity id: SolarPanel name: solar panel @@ -249,3 +263,6 @@ acts: ["Breakage"] - type: Anchorable - type: Pullable + - type: ClientEntitySpawner + prototypes: + - HVDummyWire \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Constructible/Power/wires.yml b/Resources/Prototypes/Entities/Constructible/Power/wires.yml index eb7698f2e9..144c1e1550 100644 --- a/Resources/Prototypes/Entities/Constructible/Power/wires.yml +++ b/Resources/Prototypes/Entities/Constructible/Power/wires.yml @@ -138,3 +138,60 @@ max: 1 - !type:DoActsBehavior acts: [ "Destruction" ] + +#Dummy wires + +- type: entity + abstract: true + id: BaseDummyWire + placement: + mode: SnapgridCenter + components: + - type: SnapGrid + offset: Center + - type: Sprite + drawdepth: BelowFloor + - type: IconSmooth + mode: CardinalFlags + - type: SubFloorHide + +- type: entity + abstract: true + parent: BaseDummyWire + id: HVDummyWire + name: HV Connector Wire + components: + - type: Sprite + sprite: Constructible/Power/hv_cable.rsi + state: hvcable_0 + - type: IconSmooth + base: hvcable_ + key: hv_cables + +- type: entity + abstract: true + parent: BaseDummyWire + id: MVDummyWire + name: MV Connector Wire + components: + - type: Sprite + sprite: Constructible/Power/mv_cable.rsi + state: mvcable_0 + color: Yellow + - type: IconSmooth + base: mvcable_ + key: mv_cables + +- type: entity + abstract: true + parent: BaseDummyWire + id: LVDummyWire + name: LV Connector Wire + components: + - type: Sprite + sprite: Constructible/Power/lv_cable.rsi + state: lvcable_0 + color: Green + - type: IconSmooth + base: lvcable_ + key: lv_cables \ No newline at end of file