- add: improve system

This commit is contained in:
2024-02-14 23:27:46 +03:00
parent 40d813de44
commit c9396e7b5a
13 changed files with 322 additions and 74 deletions

View File

@@ -0,0 +1,16 @@
namespace Content.Shared._Amour.Hole;
public enum GenitalVisualLayers : byte
{
ButtBehind,
BreastBehind,
VaginaBehind,
TesticlesBehind,
DickBehind,
ButtFront,
BreastFront,
VaginaFront,
TesticlesFront,
DickFront,
}

View File

@@ -11,14 +11,28 @@ namespace Content.Shared._Amour.Hole;
[RegisterComponent]
public sealed partial class HoleComponent : Component
{
[ViewVariables] public NetEntity Parent;
[ViewVariables] public NetEntity? Parent;
[DataField] public string HoleName = "";
[DataField] public List<string> HoleNotVisibleIn = new();
// Father can be in mother, its like in audiofil shit
[DataField] public HoleType HoleType = HoleType.Flat;
[DataField("sprite")] public string? RsiPath;
[DataField] public List<PrototypeLayerData> FrontLayer = new();
[DataField] public List<PrototypeLayerData> BehindLayer = new();
[DataField] public List<PrototypeLayerData> Layers = new();
// this shit just for sprite prefix like state: dildo_FRONT
[DataField] public List<HolePrefix> Prefixes = new();
}
[Serializable, NetSerializable, DataDefinition]
public sealed partial class HolePrefix
{
[DataField]
public string Layer;
[DataField]
public string Prefix;
}
public enum HoleType : byte

View File

@@ -1,4 +1,5 @@
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared._Amour.Hole;

View File

@@ -0,0 +1,51 @@
using Content.Shared.Inventory;
namespace Content.Shared._Amour.Hole;
public partial class SharedHoleSystem
{
[Dependency] private readonly InventorySystem _inventory = default!;
public bool HasAccessTo(Entity<HoleContainerComponent?,InventoryComponent?> entity, string to)
{
if (!Resolve(entity.Owner, ref entity.Comp1) || !TryFind(entity,to,out var hole))
return false;
return HasAccessTo(entity, new Entity<HoleComponent?>(hole.Owner,hole.Comp));
}
public bool HasAccessTo(Entity<HoleContainerComponent?,InventoryComponent?> entity, Entity<HoleComponent?> hole)
{
if (!Resolve(entity, ref entity.Comp1) || !Resolve(hole,ref hole.Comp))
return false;
if (!Resolve(entity, ref entity.Comp2))
return true;
foreach (var slot in hole.Comp.HoleNotVisibleIn)
{
if (_inventory.TryGetSlotEntity(entity, slot, out _, entity))
return false;
}
return true;
}
public bool TryFind(Entity<HoleContainerComponent?> entity,string to, out Entity<HoleComponent> hole)
{
hole = new Entity<HoleComponent>();
if (!Resolve(entity.Owner, ref entity.Comp))
return false;
foreach (var holeUid in entity.Comp.Slot.ContainedEntities)
{
if (!TryComp<HoleComponent>(holeUid, out var holeComponent) || holeComponent.HoleName != to)
continue;
hole.Owner = holeUid;
hole.Comp = holeComponent;
return true;
}
return false;
}
}

View File

@@ -0,0 +1,32 @@
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
namespace Content.Shared._Amour.Hole;
public abstract partial class SharedHoleSystem
{
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
public void InitializeContainer()
{
SubscribeLocalEvent<HoleContainerComponent,ComponentInit>(OnContainerInit);
}
private void OnContainerInit(EntityUid uid, HoleContainerComponent component, ComponentInit args)
{
component.Slot = _containerSystem.EnsureContainer<Container>(uid, HoleContainerComponent.SlotName);
foreach (var protoId in component.HolePrototypes)
{
AddHole(new Entity<HoleContainerComponent?>(uid,component),protoId);
}
}
public void AddHole(Entity<HoleContainerComponent?> entity, EntProtoId protoId)
{
if (!Resolve(entity.Owner, ref entity.Comp))
return;
//entity.Comp = EnsureComp<HoleContainerComponent>(entity.Owner);
Log.Debug("ADDED " + protoId);
_containerSystem.Insert(Spawn(protoId), entity.Comp.Slot);
}
}

View File

@@ -1,9 +1,23 @@
using Robust.Shared.Containers;
using Robust.Shared.Timing;
namespace Content.Shared._Amour.Hole;
public abstract class SharedHoleSystem : EntitySystem
public abstract partial class SharedHoleSystem : EntitySystem
{
public override void Initialize()
{
InitializeContainer();
SubscribeLocalEvent<HoleComponent,EntGotInsertedIntoContainerMessage>(OnInsert);
SubscribeLocalEvent<HoleComponent,EntGotRemovedFromContainerMessage>(OnRemoved);
}
private void OnRemoved(EntityUid uid, HoleComponent component, EntGotRemovedFromContainerMessage args)
{
component.Parent = null;
}
private void OnInsert(EntityUid uid, HoleComponent component, EntGotInsertedIntoContainerMessage args)
{
component.Parent = GetNetEntity(args.Container.Owner);
}
}