Очень важный момент для курток

This commit is contained in:
BIGZi0348
2024-11-24 18:58:00 +03:00
parent 30180b2e2a
commit 8339fd5672
8 changed files with 91 additions and 36 deletions

View File

@@ -0,0 +1,10 @@
using Robust.Shared.GameStates;
namespace Content.Shared._Amour.Hole;
[RegisterComponent, AutoGenerateComponentState, NetworkedComponent]
public sealed partial class HoleBlockerComponent : Component
{
[ViewVariables(VVAccess.ReadOnly), AutoNetworkedField]
public NetEntity Equipee = NetEntity.Invalid;
}

View File

@@ -0,0 +1,23 @@
using Content.Shared.Inventory.Events;
namespace Content.Shared._Amour.Hole;
public sealed class HoleBlockerSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HoleBlockerComponent, GotEquippedEvent>(OnHoleBlockerEquipped);
SubscribeLocalEvent<HoleBlockerComponent, GotUnequippedEvent>(OnHoleBlockerUnequipped);
}
private void OnHoleBlockerEquipped(Entity<HoleBlockerComponent> ent, ref GotEquippedEvent args)
{
ent.Comp.Equipee = GetNetEntity(args.Equipee);
}
private void OnHoleBlockerUnequipped(Entity<HoleBlockerComponent> ent, ref GotUnequippedEvent args)
{
ent.Comp.Equipee = NetEntity.Invalid;
}
}

View File

@@ -29,6 +29,7 @@ public sealed partial class HoleComponent : Component
[ViewVariables(VVAccess.ReadWrite)] public bool IsExcited = false;
[DataField] public bool IsMainHole = false;
[DataField] public bool IsVisibleInSkirt = true;
[DataField] public bool IsVisibleInFoldedJumpsuit = false;
}
[Serializable, NetSerializable, DataDefinition]
@@ -51,7 +52,7 @@ public enum HoleType : byte
Mother
}
[Serializable,NetSerializable]
[Serializable, NetSerializable]
public sealed partial class HoleComponentState : ComponentState
{
public readonly NetEntity? Parent;

View File

@@ -1,4 +1,5 @@
using Content.Shared.Inventory;
using Content.Shared.Foldable;
namespace Content.Shared._Amour.Hole;
@@ -6,30 +7,35 @@ public partial class SharedHoleSystem
{
[Dependency] private readonly InventorySystem _inventory = default!;
public bool HasAccessTo(Entity<HoleContainerComponent?,InventoryComponent?> entity, string to)
public bool HasAccessTo(Entity<HoleContainerComponent?, InventoryComponent?> entity, string to)
{
if (!Resolve(entity.Owner, ref entity.Comp1) || !TryFind(entity,to,out var hole))
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));
return HasAccessTo(entity, new Entity<HoleComponent?>(hole.Owner, hole.Comp));
}
public bool HasAccessTo(Entity<HoleContainerComponent?,InventoryComponent?> entity, Entity<HoleComponent?> hole)
public bool HasAccessTo(Entity<HoleContainerComponent?, InventoryComponent?> entity, Entity<HoleComponent?> hole)
{
if (!Resolve(entity, ref entity.Comp1) || !Resolve(hole,ref hole.Comp))
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 (slot == "jumpsuit" && _inventory.TryGetSlotEntity(entity, "jumpsuit", out var jumpsuit, entity) && TryComp<FoldableComponent>(jumpsuit, out var foldedItem) && foldedItem.IsFolded && hole.Comp.IsVisibleInFoldedJumpsuit)
continue;
if (_inventory.TryGetSlotEntity(entity, slot, out var item, entity) && !(HasComp<VisibleHoleComponent>(item) && hole.Comp.IsVisibleInSkirt))
{
return false;
}
}
return true;
}
public bool TryFind(Entity<HoleContainerComponent?> entity,string to, out Entity<HoleComponent> hole)
public bool TryFind(Entity<HoleContainerComponent?> entity, string to, out Entity<HoleComponent> hole)
{
hole = new Entity<HoleComponent>();
if (!Resolve(entity.Owner, ref entity.Comp))

View File

@@ -11,8 +11,8 @@ public abstract partial class SharedHoleSystem
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public void InitializeContainer()
{
SubscribeLocalEvent<HoleContainerComponent,ComponentInit>(OnContainerInit);
SubscribeLocalEvent<HoleContainerComponent,HumanoidAppearanceLoadedEvent>(OnAppearanceLoaded);
SubscribeLocalEvent<HoleContainerComponent, ComponentInit>(OnContainerInit);
SubscribeLocalEvent<HoleContainerComponent, HumanoidAppearanceLoadedEvent>(OnAppearanceLoaded);
SubscribeLocalEvent<HoleContainerComponent, HumanoidAppearanceClonedEvent>(OnClone);
}
@@ -22,19 +22,19 @@ public abstract partial class SharedHoleSystem
foreach (var entity in component.Slot.ContainedEntities)
{
var meta = MetaData(entity);
if(meta.EntityPrototype is null || !TryComp<HoleComponent>(entity, out var holeComponent))
if (meta.EntityPrototype is null || !TryComp<HoleComponent>(entity, out var holeComponent))
continue;
AddHole(new Entity<HoleContainerComponent?>(args.Target,holeContainerComponent), meta.EntityPrototype.ID, holeComponent.Layers[0].Color);
AddHole(new Entity<HoleContainerComponent?>(args.Target, holeContainerComponent), meta.EntityPrototype.ID, holeComponent.Layers[0].Color);
}
Dirty(args.Target,holeContainerComponent);
Dirty(args.Target, holeContainerComponent);
}
private void OnAppearanceLoaded(EntityUid uid, HoleContainerComponent component, HumanoidAppearanceLoadedEvent args)
{
foreach (var genitals in args.Profile.Appearance.Genitals)
{
AddHole(new Entity<HoleContainerComponent?>(uid,component),genitals.GenitalId,genitals.Color);
AddHole(new Entity<HoleContainerComponent?>(uid, component), genitals.GenitalId, genitals.Color);
}
}
@@ -43,7 +43,7 @@ public abstract partial class SharedHoleSystem
component.Slot = _containerSystem.EnsureContainer<Container>(uid, HoleContainerComponent.SlotName);
foreach (var protoId in component.HolePrototypes)
{
AddHole(new Entity<HoleContainerComponent?>(uid,component),protoId);
AddHole(new Entity<HoleContainerComponent?>(uid, component), protoId);
}
}
@@ -54,8 +54,8 @@ public abstract partial class SharedHoleSystem
Log.Error(protoId + " NOT EXIST YOU BASTARD!");
return;
}
if (!Resolve(entity.Owner, ref entity.Comp,logMissing:false))
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))
@@ -70,6 +70,6 @@ public abstract partial class SharedHoleSystem
entity.Comp.MainHole = GetNetEntity(spawned);
_containerSystem.Insert(spawned, entity.Comp.Slot);
Dirty(spawned,component);
Dirty(spawned, component);
}
}