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

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

@@ -4,6 +4,7 @@ using Robust.Client.GameObjects;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Reflection; using Robust.Shared.Reflection;
using Content.Shared.Foldable;
namespace Content.Client._Amour.Hole; namespace Content.Client._Amour.Hole;
@@ -13,15 +14,27 @@ public sealed class HoleSystem : SharedHoleSystem
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<HoleContainerComponent,EntInsertedIntoContainerMessage>(OnInsert); SubscribeLocalEvent<HoleContainerComponent, EntInsertedIntoContainerMessage>(OnInsert);
SubscribeLocalEvent<HoleContainerComponent,EntRemovedFromContainerMessage>(OnRemoved); SubscribeLocalEvent<HoleContainerComponent, EntRemovedFromContainerMessage>(OnRemoved);
SubscribeLocalEvent<HoleComponent,ComponentHandleState>(OnHandleState); SubscribeLocalEvent<HoleComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<HoleBlockerComponent, FoldedEvent>(OnFolded);
} }
private void OnHandleState(EntityUid uid, HoleComponent component,ref ComponentHandleState args) private void OnFolded(Entity<HoleBlockerComponent> ent, ref FoldedEvent args)
{ {
if(args.Current is not HoleComponentState componentState) if (ent.Comp.Equipee == NetEntity.Invalid)
return;
var equipee = GetEntity(ent.Comp.Equipee);
if (!HasComp<HoleContainerComponent>(equipee))
return;
UpdateVisuals(equipee);
}
private void OnHandleState(EntityUid uid, HoleComponent component, ref ComponentHandleState args)
{
if (args.Current is not HoleComponentState componentState)
return; return;
component.IsExcited = componentState.IsExcited; component.IsExcited = componentState.IsExcited;
@@ -29,25 +42,25 @@ public sealed class HoleSystem : SharedHoleSystem
if (component.Parent is not null) if (component.Parent is not null)
{ {
UpdateVisual(GetEntity(component.Parent.Value),uid,!HasAccessTo(GetEntity(component.Parent.Value),uid)); UpdateVisual(GetEntity(component.Parent.Value), uid, !HasAccessTo(GetEntity(component.Parent.Value), uid));
} }
} }
private void OnRemoved(EntityUid uid, HoleContainerComponent component, EntRemovedFromContainerMessage args) private void OnRemoved(EntityUid uid, HoleContainerComponent component, EntRemovedFromContainerMessage args)
{ {
if(!HasComp<HumanoidAppearanceComponent>(uid)) if (!HasComp<HumanoidAppearanceComponent>(uid))
return; return;
UpdateVisuals(uid); UpdateVisuals(uid);
if(args.Container != component.Slot) if (args.Container != component.Slot)
return; return;
UpdateVisual(uid,args.Entity,true); UpdateVisual(uid, args.Entity, true);
} }
private void OnInsert(EntityUid uid, HoleContainerComponent component, EntInsertedIntoContainerMessage args) private void OnInsert(EntityUid uid, HoleContainerComponent component, EntInsertedIntoContainerMessage args)
{ {
if(!HasComp<HumanoidAppearanceComponent>(uid)) if (!HasComp<HumanoidAppearanceComponent>(uid))
return; return;
UpdateVisuals(uid); UpdateVisuals(uid);
@@ -55,18 +68,18 @@ public sealed class HoleSystem : SharedHoleSystem
private void UpdateVisuals(Entity<HoleContainerComponent?> entity) private void UpdateVisuals(Entity<HoleContainerComponent?> entity)
{ {
if(!Resolve(entity,ref entity.Comp) || entity.Comp.Slot == null) if (!Resolve(entity, ref entity.Comp) || entity.Comp.Slot == null)
return; return;
foreach (var hole in entity.Comp.Slot.ContainedEntities) foreach (var hole in entity.Comp.Slot.ContainedEntities)
{ {
UpdateVisual(entity.Owner,hole,!HasAccessTo(entity,hole)); UpdateVisual(entity.Owner, hole, !HasAccessTo(entity, hole));
} }
} }
private void UpdateVisual(Entity<SpriteComponent?,HumanoidAppearanceComponent?,HoleContainerComponent?> owner, Entity<HoleComponent?> entity, bool clear = false) private void UpdateVisual(Entity<SpriteComponent?, HumanoidAppearanceComponent?, HoleContainerComponent?> owner, Entity<HoleComponent?> entity, bool clear = false)
{ {
if(!Resolve(owner.Owner,ref owner.Comp1, ref owner.Comp3) || !Resolve(entity.Owner,ref entity.Comp)) if (!Resolve(owner.Owner, ref owner.Comp1, ref owner.Comp3) || !Resolve(entity.Owner, ref entity.Comp))
return; return;
var spriteComp = owner.Comp1; var spriteComp = owner.Comp1;
@@ -87,11 +100,11 @@ public sealed class HoleSystem : SharedHoleSystem
if (holeComp.Prefixes.Count == 0) if (holeComp.Prefixes.Count == 0)
{ {
if (clear) if (clear)
spriteComp.LayerSetVisible(GenitalVisualLayers.DickFront,false); spriteComp.LayerSetVisible(GenitalVisualLayers.DickFront, false);
else else
{ {
spriteComp.LayerSetData(GenitalVisualLayers.DickFront, layer); spriteComp.LayerSetData(GenitalVisualLayers.DickFront, layer);
spriteComp.LayerSetVisible(GenitalVisualLayers.DickFront,true); spriteComp.LayerSetVisible(GenitalVisualLayers.DickFront, true);
} }
return; return;
} }
@@ -106,7 +119,7 @@ public sealed class HoleSystem : SharedHoleSystem
if (clear) if (clear)
{ {
spriteComp.LayerSetVisible(@enum,false); spriteComp.LayerSetVisible(@enum, false);
} }
else else
{ {
@@ -120,7 +133,7 @@ public sealed class HoleSystem : SharedHoleSystem
layer.State = state + s + mainPrefix; layer.State = state + s + mainPrefix;
spriteComp.LayerSetData(@enum, layer); spriteComp.LayerSetData(@enum, layer);
spriteComp.LayerSetVisible(@enum,true); spriteComp.LayerSetVisible(@enum, true);
layer.State = state; layer.State = state;
} }
@@ -130,7 +143,7 @@ public sealed class HoleSystem : SharedHoleSystem
public override void Exide(Entity<HoleComponent?> entity, bool value = true) public override void Exide(Entity<HoleComponent?> entity, bool value = true)
{ {
if(!Resolve(entity.Owner,ref entity.Comp)) return; if (!Resolve(entity.Owner, ref entity.Comp)) return;
base.Exide(entity, value); base.Exide(entity, value);
var netEntity = entity.Comp.Parent; var netEntity = entity.Comp.Parent;
if (netEntity != null) if (netEntity != null)

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

View File

@@ -1,4 +1,5 @@
using Content.Shared.Inventory; using Content.Shared.Inventory;
using Content.Shared.Foldable;
namespace Content.Shared._Amour.Hole; namespace Content.Shared._Amour.Hole;
@@ -6,30 +7,35 @@ public partial class SharedHoleSystem
{ {
[Dependency] private readonly InventorySystem _inventory = default!; [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 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; return false;
if (!Resolve(entity, ref entity.Comp2)) if (!Resolve(entity, ref entity.Comp2))
return true; return true;
foreach (var slot in hole.Comp.HoleNotVisibleIn) 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)) if (_inventory.TryGetSlotEntity(entity, slot, out var item, entity) && !(HasComp<VisibleHoleComponent>(item) && hole.Comp.IsVisibleInSkirt))
{
return false; return false;
} }
}
return true; 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>(); hole = new Entity<HoleComponent>();
if (!Resolve(entity.Owner, ref entity.Comp)) if (!Resolve(entity.Owner, ref entity.Comp))

View File

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

View File

@@ -95,4 +95,5 @@
- state: icon_folded - state: icon_folded
map: ["foldedLayer"] map: ["foldedLayer"]
visible: false visible: false
- type: HoleBlocker # AMOUR EDIT
# WD End # WD End

View File

@@ -88,6 +88,7 @@
prefix: "_0_FRONT" prefix: "_0_FRONT"
excitedPrefix: "_1_FRONT" excitedPrefix: "_1_FRONT"
isVisibleInSkirt: false isVisibleInSkirt: false
isVisibleInFoldedJumpsuit: true
- type: HoleSolution - type: HoleSolution
- type: HoleInventory - type: HoleInventory