diff --git a/Content.Server/_White/Carrying/CarryingSystem.cs b/Content.Server/_White/Carrying/CarryingSystem.cs index 2b0220e90f..fb53311206 100644 --- a/Content.Server/_White/Carrying/CarryingSystem.cs +++ b/Content.Server/_White/Carrying/CarryingSystem.cs @@ -11,6 +11,7 @@ using Content.Shared.Climbing.Events; using Content.Shared.DoAfter; using Content.Shared.Hands; using Content.Shared.Hands.Components; +using Content.Shared.IdentityManagement; using Content.Shared.Interaction.Events; using Content.Shared.Inventory.VirtualItem; using Content.Shared.Mobs; @@ -226,14 +227,15 @@ public sealed class CarryingSystem : EntitySystem var ev = new CarryDoAfterEvent(); var args = new DoAfterArgs(EntityManager, carrier, length, ev, carried, target: carried) { + BreakOnDamage = true, BreakOnMove = true, NeedHand = true }; - if(_doAfterSystem.TryStartDoAfter(args)) + if (_doAfterSystem.TryStartDoAfter(args)) { - _popupSystem.PopupEntity(Loc.GetString("carry-start", ("carrier", carrier)), carried, carried, - Shared.Popups.PopupType.SmallCaution); + _popupSystem.PopupEntity(Loc.GetString("carry-start", ("carrier", Identity.Entity(carrier, EntityManager))), + carried, carried, Shared.Popups.PopupType.SmallCaution); } } diff --git a/Content.Server/_White/Items/PseudoItem/PseudoItemSystem.cs b/Content.Server/_White/Items/PseudoItem/PseudoItemSystem.cs index b75ca9f652..8a13afe57b 100644 --- a/Content.Server/_White/Items/PseudoItem/PseudoItemSystem.cs +++ b/Content.Server/_White/Items/PseudoItem/PseudoItemSystem.cs @@ -1,12 +1,17 @@ using Content.Server._White.Carrying; +using Content.Server.DoAfter; using Content.Shared.Verbs; using Content.Shared.Item; -using Content.Shared.Hands; using Content.Server.Storage.EntitySystems; using Content.Server.Item; using Content.Server.Popups; using Content.Server.Resist; +using Content.Shared._White.Carrying; using Content.Shared._White.Item.PseudoItem; +using Content.Shared.DoAfter; +using Content.Shared.Hands.Components; +using Content.Shared.IdentityManagement; +using Content.Shared.Inventory.VirtualItem; using Content.Shared.Resist; using Content.Shared.Storage; using Robust.Server.GameObjects; @@ -21,32 +26,52 @@ public sealed class PseudoItemSystem : SharedPseudoItemSystem [Dependency] private readonly ItemSystem _itemSystem = default!; [Dependency] private readonly CarryingSystem _carrying = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; + [Dependency] private readonly DoAfterSystem _doAfter = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnEntRemoved); - SubscribeLocalEvent(OnDropAttempt); - SubscribeLocalEvent(OnEscape); + SubscribeLocalEvent(OnInsert); + SubscribeLocalEvent(OnCarryEvent, + after: new[] {typeof(CarryingSystem)}); SubscribeLocalEvent>(AddAltVerb); SubscribeLocalEvent>(AddVerb); SubscribeLocalEvent(OnInteract); } + private void OnCarryEvent(Entity ent, ref CarryDoAfterEvent args) + { + if (args.Handled || args.Cancelled) + return; + + args.Handled = true; + _transform.AttachToGridOrMap(ent); + } + + private void OnInsert(Entity ent, ref PseudoItemInsertEvent args) + { + if (args.Cancelled || args.Handled) + return; + + args.Handled = true; + + if (!TryComp(args.Target, out StorageComponent? storage)) + return; + + if (!TryInsert(args.Target.Value, ent.Owner, args.User, ent.Comp, storage)) + return; + + if (args.User != ent.Owner) + _carrying.DropCarried(args.User, ent.Owner, false, false); + } + private void OnInteract(Entity ent, ref PseudoItemInteractEvent args) { if (!TryComp(args.Used, out PseudoItemComponent? pseudoItem)) return; - if (!TryInsert(ent.Owner, args.Used, args.User, pseudoItem, ent.Comp)) - return; - - _carrying.DropCarried(args.User, args.Used, false, false); - } - - private void OnEscape(Entity ent, ref EscapeInventoryEvent args) - { - NoLongerInContainer(ent.Owner, ent.Comp); + TryStartInsertDoAfter(ent.Owner, args.Used, args.User, pseudoItem, ent.Comp, args.VirtualItem); } private void AddAltVerb(Entity ent, ref GetVerbsEvent args) @@ -68,7 +93,7 @@ public sealed class PseudoItemSystem : SharedPseudoItemSystem { Act = () => { - TryInsert(uid, user, user, pseudoItem, comp); + TryStartInsertDoAfter(uid, user, user, pseudoItem, comp); }, Text = Loc.GetString("action-name-insert-self"), }; @@ -87,6 +112,9 @@ public sealed class PseudoItemSystem : SharedPseudoItemSystem if (!TryComp(user, out CarryingComponent? carrying)) return; + if (!TryComp(user, out HandsComponent? hands) || !HasComp(hands.ActiveHandEntity)) + return; + var carried = carrying.Carried; if (!TryComp(carried, out PseudoItemComponent? pseudoItem)) @@ -96,8 +124,7 @@ public sealed class PseudoItemSystem : SharedPseudoItemSystem { Act = () => { - if (TryInsert(uid, carried, user, pseudoItem, comp)) - _carrying.DropCarried(user, carried, false, false); + TryStartInsertDoAfter(uid, carried, user, pseudoItem, comp, hands.ActiveHandEntity.Value); }, Text = Loc.GetString("action-name-insert-other"), }; @@ -106,7 +133,45 @@ public sealed class PseudoItemSystem : SharedPseudoItemSystem private void OnEntRemoved(EntityUid uid, PseudoItemComponent component, EntGotRemovedFromContainerMessage args) { - NoLongerInContainer(uid, component); + if (!component.Active) + return; + + RemComp(uid); + RemComp(uid); + component.Active = false; + Dirty(uid, component); + } + + private void TryStartInsertDoAfter(EntityUid storageUid, + EntityUid toInsert, + EntityUid user, + PseudoItemComponent component, + StorageComponent storage, + EntityUid? used = null) + { + if (!FitsInContainer(storageUid, storage, component)) + { + _popupSystem.PopupEntity(Loc.GetString("comp-storage-too-big"), user, user); + return; + } + + var args = new DoAfterArgs(EntityManager, user, TimeSpan.FromSeconds(1), new PseudoItemInsertEvent(), + toInsert, storageUid, used) + { + BreakOnDamage = true, + BreakOnMove = true, + NeedHand = user != toInsert + }; + + if (!_doAfter.TryStartDoAfter(args)) + return; + + var message = toInsert == user + ? Loc.GetString("action-start-insert-self", ("storage", storageUid)) + : Loc.GetString("action-start-insert-other", + ("storage", storageUid), ("user", Identity.Entity(user, EntityManager))); + + _popupSystem.PopupEntity(message, toInsert, toInsert); } protected override void OnGettingPickedUp(Entity ent, GettingPickedUpAttemptEvent args) @@ -118,24 +183,18 @@ public sealed class PseudoItemSystem : SharedPseudoItemSystem if (!TryComp(ent, out CarriableComponent? carriable)) _transform.AttachToGridOrMap(ent); - else if (_carrying.CanCarry(args.User, ent)) + else _carrying.StartCarryDoAfter(args.User, ent, carriable); } - private void OnDropAttempt(EntityUid uid, PseudoItemComponent component, DropAttemptEvent args) - { - if (component.Active) - args.Cancel(); - } - public bool TryInsert(EntityUid storageUid, EntityUid toInsert, EntityUid user, PseudoItemComponent component, - StorageComponent? storage = null) + StorageComponent storage) { - if (!Resolve(storageUid, ref storage)) - return false; + if (TryComp(toInsert, out CanEscapeInventoryComponent? canEscape) && canEscape.DoAfter != null) + _doAfter.Cancel(canEscape.DoAfter); var item = EnsureComp(toInsert); _itemSystem.SetSize(toInsert, component.Size, item); @@ -151,18 +210,12 @@ public sealed class PseudoItemSystem : SharedPseudoItemSystem } component.Active = true; - EnsureComp(toInsert); + EnsureComp(toInsert).BaseResistTime = 3f; return true; } - private void NoLongerInContainer(EntityUid uid, PseudoItemComponent component) + private bool FitsInContainer(EntityUid storageUid, StorageComponent storage, PseudoItemComponent pseudoItem) { - if (!component.Active) - return; - - RemCompDeferred(uid); - RemCompDeferred(uid); - component.Active = false; - Dirty(uid, component); + return _storageSystem.GetMaxItemSize((storageUid, storage)) >= _itemSystem.GetSizePrototype(pseudoItem.Size); } } diff --git a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs index 2a9b335c9f..0764543fb1 100644 --- a/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs @@ -227,7 +227,7 @@ public abstract class SharedStorageSystem : EntitySystem if (TryComp(args.Used, out var virtualItem)) // WD { - RaiseLocalEvent(uid, new PseudoItemInteractEvent(virtualItem.BlockingEntity, args.User)); + RaiseLocalEvent(uid, new PseudoItemInteractEvent(virtualItem.BlockingEntity, args.User, args.Used)); return; } @@ -517,6 +517,9 @@ public abstract class SharedStorageSystem : EntitySystem if (!ActionBlocker.CanInteract(player, itemEnt)) return; + if (HasComp(itemEnt)) // WD + return; + TransformSystem.DropNextTo(itemEnt, player); Audio.PlayPredicted(storageComp.StorageRemoveSound, storageEnt, player); } @@ -681,6 +684,8 @@ public abstract class SharedStorageSystem : EntitySystem foreach (var entity in entities.ToArray()) { + if (HasComp(entity)) // WD + continue; Insert(target, entity, out _, user: user, targetComp, playSound: false); } diff --git a/Content.Shared/Stunnable/SharedStunSystem.cs b/Content.Shared/Stunnable/SharedStunSystem.cs index 1a226ef28f..56d2b796e2 100644 --- a/Content.Shared/Stunnable/SharedStunSystem.cs +++ b/Content.Shared/Stunnable/SharedStunSystem.cs @@ -16,6 +16,7 @@ using Content.Shared.Standing.Systems; using Content.Shared.StatusEffect; using Content.Shared.Throwing; using Robust.Shared.Audio.Systems; +using Robust.Shared.Containers; namespace Content.Shared.Stunnable; @@ -27,6 +28,7 @@ public abstract class SharedStunSystem : EntitySystem [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedStandingStateSystem _standingState = default!; [Dependency] private readonly StatusEffectsSystem _statusEffect = default!; + [Dependency] private readonly SharedContainerSystem _container = default!; /// /// Friction modifier for knocked down players. @@ -115,7 +117,7 @@ public abstract class SharedStunSystem : EntitySystem if (!TryComp(uid, out StandingStateComponent? standing) || !(!standing.CanLieDown || standing.AutoGetUp)) // WD EDIT return; - if (standing.AutoGetUp) // WD EDIT + if (standing.AutoGetUp && !_container.IsEntityInContainer(uid)) // WD EDIT { _standingState.TryStandUp(uid, standing); return; diff --git a/Content.Shared/_White/Item/PseudoItem/SharedPseudoItemSystem.cs b/Content.Shared/_White/Item/PseudoItem/SharedPseudoItemSystem.cs index 5c7a1c4779..11afdb7078 100644 --- a/Content.Shared/_White/Item/PseudoItem/SharedPseudoItemSystem.cs +++ b/Content.Shared/_White/Item/PseudoItem/SharedPseudoItemSystem.cs @@ -1,5 +1,7 @@ +using Content.Shared.DoAfter; using Content.Shared.Interaction.Events; using Content.Shared.Item; +using Robust.Shared.Serialization; namespace Content.Shared._White.Item.PseudoItem; @@ -28,9 +30,15 @@ public abstract class SharedPseudoItemSystem : EntitySystem protected virtual void OnGettingPickedUp(Entity ent, GettingPickedUpAttemptEvent args) {} } -public sealed class PseudoItemInteractEvent(EntityUid used, EntityUid user) +public sealed class PseudoItemInteractEvent(EntityUid used, EntityUid user, EntityUid virtualItem) : EntityEventArgs { public EntityUid Used { get; } = used; public EntityUid User { get; } = user; + public EntityUid VirtualItem { get; } = virtualItem; +} + +[Serializable, NetSerializable] +public sealed partial class PseudoItemInsertEvent : SimpleDoAfterEvent +{ } diff --git a/Resources/Locale/ru-RU/_white/white-shit.ftl b/Resources/Locale/ru-RU/_white/white-shit.ftl index c333a1dc3c..bde173579e 100644 --- a/Resources/Locale/ru-RU/_white/white-shit.ftl +++ b/Resources/Locale/ru-RU/_white/white-shit.ftl @@ -11,4 +11,6 @@ ent-EnergyBola = энергобола action-name-insert-self = Залезть внутрь. action-name-insert-other = Засунуть внутрь. +action-start-insert-self = Вы начинаете залазить в {$storage}. +action-start-insert-other = {$user} начинает засовывать вас в {$storage}. carry-start = { $carrier } пытается взять вас на руки!