- add: change genitals on appearance
This commit is contained in:
19
Content.Shared/_Amour/Hole/Genital.cs
Normal file
19
Content.Shared/_Amour/Hole/Genital.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared._Amour.Hole;
|
||||
|
||||
[Serializable, NetSerializable, DataDefinition]
|
||||
public sealed partial class Genital
|
||||
{
|
||||
public Genital(EntProtoId genitalId, Color? color)
|
||||
{
|
||||
GenitalId = genitalId;
|
||||
Color = color;
|
||||
}
|
||||
|
||||
[DataField]
|
||||
public EntProtoId GenitalId { get; private set; }
|
||||
[DataField]
|
||||
public Color? Color { get; private set; }
|
||||
}
|
||||
10
Content.Shared/_Amour/Hole/GenitalsGroupPrototype.cs
Normal file
10
Content.Shared/_Amour/Hole/GenitalsGroupPrototype.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._Amour.Hole;
|
||||
|
||||
[Prototype("genitalsGroup")]
|
||||
public sealed class GenitalsGroupPrototype : IPrototype
|
||||
{
|
||||
[IdDataField] public string ID { get; private set; } = default!;
|
||||
[DataField(required:true)] public List<EntProtoId> Prototypes = default!;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ namespace Content.Shared._Amour.Hole;
|
||||
public abstract partial class SharedHoleSystem
|
||||
{
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
public void InitializeContainer()
|
||||
{
|
||||
SubscribeLocalEvent<HoleContainerComponent,ComponentInit>(OnContainerInit);
|
||||
@@ -20,13 +21,26 @@ public abstract partial class SharedHoleSystem
|
||||
}
|
||||
}
|
||||
|
||||
public void AddHole(Entity<HoleContainerComponent?> entity, EntProtoId protoId)
|
||||
public void AddHole(Entity<HoleContainerComponent?> entity, EntProtoId protoId, Color? color = null)
|
||||
{
|
||||
if (!Resolve(entity.Owner, ref entity.Comp))
|
||||
if (!_prototypeManager.TryIndex<EntityPrototype>(protoId, out _))
|
||||
{
|
||||
Log.Error(protoId + " NOT EXIST YOU BASTARD!");
|
||||
return;
|
||||
//entity.Comp = EnsureComp<HoleContainerComponent>(entity.Owner);
|
||||
}
|
||||
if (!Resolve(entity.Owner, ref entity.Comp,logMissing:false))
|
||||
entity.Comp = EnsureComp<HoleContainerComponent>(entity.Owner);
|
||||
|
||||
var spawned = Spawn(protoId);
|
||||
if (!TryComp<HoleComponent>(spawned, out var component))
|
||||
{
|
||||
QueueDel(spawned);
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Debug("ADDED " + protoId);
|
||||
_containerSystem.Insert(Spawn(protoId), entity.Comp.Slot);
|
||||
component.Layers[0].Color = color;
|
||||
|
||||
_containerSystem.Insert(spawned, entity.Comp.Slot);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user