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:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server
|
||||
namespace Content.Server
|
||||
{
|
||||
|
||||
public static class IgnoredComponents
|
||||
@@ -18,6 +18,7 @@
|
||||
"Clickable",
|
||||
"RadiatingLight",
|
||||
"Icon",
|
||||
"ClientEntitySpawner"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
supplyRate: 3000
|
||||
- type: Anchorable
|
||||
- type: Pullable
|
||||
- type: ClientEntitySpawner
|
||||
prototypes:
|
||||
- HVDummyWire
|
||||
|
||||
- type: entity
|
||||
id: BaseSmes
|
||||
@@ -93,6 +96,9 @@
|
||||
activeSupplyRate: 1000
|
||||
- type: Anchorable
|
||||
- type: Pullable
|
||||
- type: ClientEntitySpawner
|
||||
prototypes:
|
||||
- HVDummyWire
|
||||
|
||||
- type: entity
|
||||
id: BaseSubstation
|
||||
@@ -148,6 +154,10 @@
|
||||
activeSupplyRate: 1000
|
||||
- type: Anchorable
|
||||
- type: Pullable
|
||||
- type: ClientEntitySpawner
|
||||
prototypes:
|
||||
- HVDummyWire
|
||||
- MVDummyWire
|
||||
|
||||
- type: entity
|
||||
id: BaseApc
|
||||
@@ -201,6 +211,10 @@
|
||||
- type: Construction
|
||||
graph: apc
|
||||
node: apc
|
||||
- type: ClientEntitySpawner
|
||||
prototypes:
|
||||
- MVDummyWire
|
||||
- LVDummyWire
|
||||
|
||||
- type: entity
|
||||
id: SolarPanel
|
||||
@@ -249,3 +263,6 @@
|
||||
acts: ["Breakage"]
|
||||
- type: Anchorable
|
||||
- type: Pullable
|
||||
- type: ClientEntitySpawner
|
||||
prototypes:
|
||||
- HVDummyWire
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user