Merge pull request #184 from frosty-dev/FoldedClothingHonkSpecialEdition

Очень важный момент для курток
This commit is contained in:
BIGZi0348
2024-11-24 19:02:11 +03:00
committed by GitHub
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.GameStates;
using Robust.Shared.Reflection;
using Content.Shared.Foldable;
namespace Content.Client._Amour.Hole;
@@ -13,15 +14,27 @@ public sealed class HoleSystem : SharedHoleSystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HoleContainerComponent,EntInsertedIntoContainerMessage>(OnInsert);
SubscribeLocalEvent<HoleContainerComponent,EntRemovedFromContainerMessage>(OnRemoved);
SubscribeLocalEvent<HoleContainerComponent, EntInsertedIntoContainerMessage>(OnInsert);
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;
component.IsExcited = componentState.IsExcited;
@@ -29,25 +42,25 @@ public sealed class HoleSystem : SharedHoleSystem
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)
{
if(!HasComp<HumanoidAppearanceComponent>(uid))
if (!HasComp<HumanoidAppearanceComponent>(uid))
return;
UpdateVisuals(uid);
if(args.Container != component.Slot)
if (args.Container != component.Slot)
return;
UpdateVisual(uid,args.Entity,true);
UpdateVisual(uid, args.Entity, true);
}
private void OnInsert(EntityUid uid, HoleContainerComponent component, EntInsertedIntoContainerMessage args)
{
if(!HasComp<HumanoidAppearanceComponent>(uid))
if (!HasComp<HumanoidAppearanceComponent>(uid))
return;
UpdateVisuals(uid);
@@ -55,18 +68,18 @@ public sealed class HoleSystem : SharedHoleSystem
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;
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;
var spriteComp = owner.Comp1;
@@ -87,11 +100,11 @@ public sealed class HoleSystem : SharedHoleSystem
if (holeComp.Prefixes.Count == 0)
{
if (clear)
spriteComp.LayerSetVisible(GenitalVisualLayers.DickFront,false);
spriteComp.LayerSetVisible(GenitalVisualLayers.DickFront, false);
else
{
spriteComp.LayerSetData(GenitalVisualLayers.DickFront, layer);
spriteComp.LayerSetVisible(GenitalVisualLayers.DickFront,true);
spriteComp.LayerSetVisible(GenitalVisualLayers.DickFront, true);
}
return;
}
@@ -106,7 +119,7 @@ public sealed class HoleSystem : SharedHoleSystem
if (clear)
{
spriteComp.LayerSetVisible(@enum,false);
spriteComp.LayerSetVisible(@enum, false);
}
else
{
@@ -120,7 +133,7 @@ public sealed class HoleSystem : SharedHoleSystem
layer.State = state + s + mainPrefix;
spriteComp.LayerSetData(@enum, layer);
spriteComp.LayerSetVisible(@enum,true);
spriteComp.LayerSetVisible(@enum, true);
layer.State = state;
}
@@ -130,7 +143,7 @@ public sealed class HoleSystem : SharedHoleSystem
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);
var netEntity = entity.Comp.Parent;
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;
[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);
}
}

View File

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

View File

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