- add: change genitals on appearance

This commit is contained in:
2024-02-16 13:22:43 +03:00
parent c9396e7b5a
commit 52628d0393
26 changed files with 5060 additions and 133 deletions

View 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; }
}

View 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!;
}

View File

@@ -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);
}
}