DummyWireComponent (#3011)

* DummyWireComponent

* connector wire proto names

* comment fix

* Uses IMapInit

* Removes unused icon components

* Moves component to client

* Renames component

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2021-01-18 04:51:16 -06:00
committed by GitHub
parent 2172d00409
commit a7354f8e0d
4 changed files with 135 additions and 4 deletions

View File

@@ -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
{
/// <summary>
/// Spawns a set of entities on the client only, and removes them when this component is removed.
/// </summary>
[RegisterComponent]
public class ClientEntitySpawnerComponent : Component
{
public override string Name => "ClientEntitySpawner";
private List<string> _prototypes = default!;
private List<IEntity> _entity = new();
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _prototypes, "prototypes", new List<string> { "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);
}
}
}
}

View File

@@ -1,4 +1,4 @@
namespace Content.Server namespace Content.Server
{ {
public static class IgnoredComponents public static class IgnoredComponents
@@ -18,6 +18,7 @@
"Clickable", "Clickable",
"RadiatingLight", "RadiatingLight",
"Icon", "Icon",
"ClientEntitySpawner"
}; };
} }

View File

@@ -38,6 +38,9 @@
supplyRate: 3000 supplyRate: 3000
- type: Anchorable - type: Anchorable
- type: Pullable - type: Pullable
- type: ClientEntitySpawner
prototypes:
- HVDummyWire
- type: entity - type: entity
id: BaseSmes id: BaseSmes
@@ -93,7 +96,10 @@
activeSupplyRate: 1000 activeSupplyRate: 1000
- type: Anchorable - type: Anchorable
- type: Pullable - type: Pullable
- type: ClientEntitySpawner
prototypes:
- HVDummyWire
- type: entity - type: entity
id: BaseSubstation id: BaseSubstation
description: Reduces the voltage of electricity put into it. description: Reduces the voltage of electricity put into it.
@@ -148,7 +154,11 @@
activeSupplyRate: 1000 activeSupplyRate: 1000
- type: Anchorable - type: Anchorable
- type: Pullable - type: Pullable
- type: ClientEntitySpawner
prototypes:
- HVDummyWire
- MVDummyWire
- type: entity - type: entity
id: BaseApc id: BaseApc
description: A control terminal for the area's electrical systems. description: A control terminal for the area's electrical systems.
@@ -201,7 +211,11 @@
- type: Construction - type: Construction
graph: apc graph: apc
node: apc node: apc
- type: ClientEntitySpawner
prototypes:
- MVDummyWire
- LVDummyWire
- type: entity - type: entity
id: SolarPanel id: SolarPanel
name: solar panel name: solar panel
@@ -249,3 +263,6 @@
acts: ["Breakage"] acts: ["Breakage"]
- type: Anchorable - type: Anchorable
- type: Pullable - type: Pullable
- type: ClientEntitySpawner
prototypes:
- HVDummyWire

View File

@@ -138,3 +138,60 @@
max: 1 max: 1
- !type:DoActsBehavior - !type:DoActsBehavior
acts: [ "Destruction" ] 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