Merge remote-tracking branch 'upstream/stable' into ed-30-04-2025-upstream-sync
# Conflicts: # Content.Client/Parallax/ParallaxControl.cs # Content.Client/UserInterface/Systems/Storage/Controls/ItemGridPiece.cs # Content.IntegrationTests/Tests/PostMapInitTest.cs # Content.Server/Chat/Managers/ChatManager.cs # Content.Server/Fluids/EntitySystems/PuddleSystem.Evaporation.cs # Content.Server/Labels/Label/LabelSystem.cs # Content.Shared/Actions/SharedActionsSystem.cs # Content.Shared/Fluids/Components/EvaporationComponent.cs # Content.Shared/Labels/EntitySystems/SharedLabelSystem.cs # README.md # Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml # Resources/Prototypes/Maps/Pools/deathmatch.yml # Resources/Prototypes/Maps/arenas.yml
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Disposal;
|
||||
using Content.Shared.Disposal.Components;
|
||||
using Content.Shared.Disposal.Unit;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Item;
|
||||
@@ -40,7 +42,7 @@ public sealed class DumpableSystem : EntitySystem
|
||||
if (!args.CanReach || args.Handled)
|
||||
return;
|
||||
|
||||
if (!_disposalUnitSystem.HasDisposals(args.Target) && !HasComp<PlaceableSurfaceComponent>(args.Target))
|
||||
if (!HasComp<DisposalUnitComponent>(args.Target) && !HasComp<PlaceableSurfaceComponent>(args.Target))
|
||||
return;
|
||||
|
||||
if (!TryComp<StorageComponent>(uid, out var storage))
|
||||
@@ -81,7 +83,7 @@ public sealed class DumpableSystem : EntitySystem
|
||||
if (!TryComp<StorageComponent>(uid, out var storage) || !storage.Container.ContainedEntities.Any())
|
||||
return;
|
||||
|
||||
if (_disposalUnitSystem.HasDisposals(args.Target))
|
||||
if (HasComp<DisposalUnitComponent>(args.Target))
|
||||
{
|
||||
UtilityVerb verb = new()
|
||||
{
|
||||
@@ -146,7 +148,7 @@ public sealed class DumpableSystem : EntitySystem
|
||||
|
||||
var dumped = false;
|
||||
|
||||
if (_disposalUnitSystem.HasDisposals(args.Args.Target))
|
||||
if (HasComp<DisposalUnitComponent>(args.Args.Target))
|
||||
{
|
||||
dumped = true;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Construction.EntitySystems;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
@@ -6,6 +7,7 @@ using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Materials;
|
||||
using Content.Shared.Nutrition;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Storage.Components;
|
||||
using Content.Shared.Tools.EntitySystems;
|
||||
@@ -30,6 +32,7 @@ public sealed class SecretStashSystem : EntitySystem
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly ToolOpenableSystem _toolOpenableSystem = default!;
|
||||
[Dependency] private readonly EntityWhitelistSystem _whitelistSystem = default!;
|
||||
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -38,6 +41,7 @@ public sealed class SecretStashSystem : EntitySystem
|
||||
SubscribeLocalEvent<SecretStashComponent, DestructionEventArgs>(OnDestroyed);
|
||||
SubscribeLocalEvent<SecretStashComponent, GotReclaimedEvent>(OnReclaimed);
|
||||
SubscribeLocalEvent<SecretStashComponent, InteractUsingEvent>(OnInteractUsing, after: new[] { typeof(ToolOpenableSystem), typeof(AnchorableSystem) });
|
||||
SubscribeLocalEvent<SecretStashComponent, AfterFullyEatenEvent>(OnEaten);
|
||||
SubscribeLocalEvent<SecretStashComponent, InteractHandEvent>(OnInteractHand);
|
||||
SubscribeLocalEvent<SecretStashComponent, GetVerbsEvent<InteractionVerb>>(OnGetVerb);
|
||||
}
|
||||
@@ -57,6 +61,14 @@ public sealed class SecretStashSystem : EntitySystem
|
||||
DropContentsAndAlert(entity, args.ReclaimerCoordinates);
|
||||
}
|
||||
|
||||
private void OnEaten(Entity<SecretStashComponent> entity, ref AfterFullyEatenEvent args)
|
||||
{
|
||||
// TODO: When newmed is finished should do damage to teeth (Or something like that!)
|
||||
var damage = entity.Comp.DamageEatenItemInside;
|
||||
if (HasItemInside(entity) && damage != null)
|
||||
_damageableSystem.TryChangeDamage(args.User, damage, true);
|
||||
}
|
||||
|
||||
private void OnInteractUsing(Entity<SecretStashComponent> entity, ref InteractUsingEvent args)
|
||||
{
|
||||
if (args.Handled || !IsStashOpen(entity))
|
||||
|
||||
@@ -181,7 +181,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem
|
||||
|
||||
if (component.Open)
|
||||
{
|
||||
TryCloseStorage(target);
|
||||
TryCloseStorage(target, user);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -360,9 +360,9 @@ public abstract class SharedEntityStorageSystem : EntitySystem
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TryCloseStorage(EntityUid target)
|
||||
public bool TryCloseStorage(EntityUid target, EntityUid? user = null)
|
||||
{
|
||||
if (!CanClose(target))
|
||||
if (!CanClose(target, user))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -413,9 +413,9 @@ public abstract class SharedEntityStorageSystem : EntitySystem
|
||||
return !ev.Cancelled;
|
||||
}
|
||||
|
||||
public bool CanClose(EntityUid target, bool silent = false)
|
||||
public bool CanClose(EntityUid target, EntityUid? user = null, bool silent = false)
|
||||
{
|
||||
var ev = new StorageCloseAttemptEvent();
|
||||
var ev = new StorageCloseAttemptEvent(user);
|
||||
RaiseLocalEvent(target, ref ev, silent);
|
||||
|
||||
return !ev.Cancelled;
|
||||
|
||||
@@ -16,6 +16,7 @@ using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Components;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Item.ItemToggle.Components;
|
||||
using Content.Shared.Lock;
|
||||
using Content.Shared.Materials;
|
||||
using Content.Shared.Placeable;
|
||||
@@ -40,6 +41,7 @@ using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Shared.Rounding;
|
||||
|
||||
namespace Content.Shared.Storage.EntitySystems;
|
||||
|
||||
@@ -142,16 +144,16 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
SubscribeLocalEvent<StorageComponent, OpenStorageImplantEvent>(OnImplantActivate);
|
||||
SubscribeLocalEvent<StorageComponent, AfterInteractEvent>(AfterInteract);
|
||||
SubscribeLocalEvent<StorageComponent, DestructionEventArgs>(OnDestroy);
|
||||
SubscribeLocalEvent<BoundUserInterfaceMessageAttempt>(OnBoundUIAttempt);
|
||||
SubscribeLocalEvent<StorageComponent, BoundUserInterfaceMessageAttempt>(OnBoundUIAttempt);
|
||||
SubscribeLocalEvent<StorageComponent, BoundUIOpenedEvent>(OnBoundUIOpen);
|
||||
SubscribeLocalEvent<StorageComponent, LockToggledEvent>(OnLockToggled);
|
||||
SubscribeLocalEvent<MetaDataComponent, StackCountChangedEvent>(OnStackCountChanged);
|
||||
|
||||
SubscribeLocalEvent<StorageComponent, EntInsertedIntoContainerMessage>(OnEntInserted);
|
||||
SubscribeLocalEvent<StorageComponent, EntRemovedFromContainerMessage>(OnEntRemoved);
|
||||
SubscribeLocalEvent<StorageComponent, ContainerIsInsertingAttemptEvent>(OnInsertAttempt);
|
||||
|
||||
SubscribeLocalEvent<StorageComponent, AreaPickupDoAfterEvent>(OnDoAfter);
|
||||
SubscribeLocalEvent<StorageComponent, GotReclaimedEvent>(OnReclaimed);
|
||||
|
||||
SubscribeLocalEvent<MetaDataComponent, StackCountChangedEvent>(OnStackCountChanged);
|
||||
|
||||
SubscribeAllEvent<OpenNestedStorageEvent>(OnStorageNested);
|
||||
SubscribeAllEvent<StorageTransferItemEvent>(OnStorageTransfer);
|
||||
@@ -160,7 +162,7 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
SubscribeAllEvent<StorageInsertItemIntoLocationEvent>(OnInsertItemIntoLocation);
|
||||
SubscribeAllEvent<StorageSaveItemLocationEvent>(OnSaveItemLocation);
|
||||
|
||||
SubscribeLocalEvent<StorageComponent, GotReclaimedEvent>(OnReclaimed);
|
||||
SubscribeLocalEvent<ItemSizeChangedEvent>(OnItemSizeChanged);
|
||||
|
||||
CommandBinds.Builder
|
||||
.Bind(ContentKeyFunctions.OpenBackpack, InputCmdHandler.FromDelegate(HandleOpenBackpack, handle: false))
|
||||
@@ -172,6 +174,21 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
UpdatePrototypeCache();
|
||||
}
|
||||
|
||||
private void OnItemSizeChanged(ref ItemSizeChangedEvent ev)
|
||||
{
|
||||
var itemEnt = new Entity<ItemComponent?>(ev.Entity, null);
|
||||
|
||||
if (!TryGetStorageLocation(itemEnt, out var container, out var storage, out var loc))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ItemFitsInGridLocation((itemEnt.Owner, itemEnt.Comp), (container.Owner, storage), loc))
|
||||
{
|
||||
ContainerSystem.Remove(itemEnt.Owner, container, force: true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnNestedStorageCvar(bool obj)
|
||||
{
|
||||
NestedStorage = obj;
|
||||
@@ -321,6 +338,26 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get the storage location of an item.
|
||||
/// </summary>
|
||||
public bool TryGetStorageLocation(Entity<ItemComponent?> itemEnt, [NotNullWhen(true)] out BaseContainer? container, out StorageComponent? storage, out ItemStorageLocation loc)
|
||||
{
|
||||
loc = default;
|
||||
storage = null;
|
||||
|
||||
if (!ContainerSystem.TryGetContainingContainer(itemEnt, out container) ||
|
||||
container.ID != StorageComponent.ContainerId ||
|
||||
!TryComp(container.Owner, out storage) ||
|
||||
!_itemQuery.Resolve(itemEnt, ref itemEnt.Comp, false))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
loc = storage.StoredItems[itemEnt];
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OpenStorageUI(EntityUid uid, EntityUid actor, StorageComponent? storageComp = null, bool silent = true)
|
||||
{
|
||||
// Handle recursively opening nested storages.
|
||||
@@ -721,14 +758,23 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
|
||||
private void OnStorageTransfer(StorageTransferItemEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
if (!TryGetEntity(msg.ItemEnt, out var itemEnt))
|
||||
if (!TryGetEntity(msg.ItemEnt, out var itemUid) || !TryComp(itemUid, out ItemComponent? itemComp))
|
||||
return;
|
||||
|
||||
var localPlayer = args.SenderSession.AttachedEntity;
|
||||
var itemEnt = new Entity<ItemComponent?>(itemUid.Value, itemComp);
|
||||
|
||||
if (!TryComp(localPlayer, out HandsComponent? handsComp) || !_sharedHandsSystem.TryPickup(localPlayer.Value, itemEnt.Value, handsComp: handsComp, animate: false))
|
||||
// Validate the source storage
|
||||
if (!TryGetStorageLocation(itemEnt, out var container, out _, out _) ||
|
||||
!ValidateInput(args, GetNetEntity(container.Owner), out _, out _))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TryComp(localPlayer, out HandsComponent? handsComp) || !_sharedHandsSystem.TryPickup(localPlayer.Value, itemEnt, handsComp: handsComp, animate: false))
|
||||
return;
|
||||
|
||||
// Validate the target storage
|
||||
if (!ValidateInput(args, msg.StorageEnt, msg.ItemEnt, out var player, out var storage, out var item, held: true))
|
||||
return;
|
||||
|
||||
@@ -764,7 +810,7 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
UpdateAppearance((ent.Owner, ent.Comp, null));
|
||||
}
|
||||
|
||||
private void OnBoundUIAttempt(BoundUserInterfaceMessageAttempt args)
|
||||
private void OnBoundUIAttempt(Entity<StorageComponent> ent, ref BoundUserInterfaceMessageAttempt args)
|
||||
{
|
||||
if (args.UiKey is not StorageComponent.StorageUiKey.Key ||
|
||||
_openStorageLimit == -1 ||
|
||||
@@ -883,6 +929,12 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
_appearance.SetData(uid, StorageVisuals.Open, isOpen, appearance);
|
||||
_appearance.SetData(uid, SharedBagOpenVisuals.BagState, isOpen ? SharedBagState.Open : SharedBagState.Closed, appearance);
|
||||
|
||||
if (TryComp<StorageFillVisualizerComponent>(uid, out var storageFillVisualizerComp))
|
||||
{
|
||||
var level = ContentHelpers.RoundToLevels(used, capacity, storageFillVisualizerComp.MaxFillLevels);
|
||||
_appearance.SetData(uid, StorageFillVisuals.FillLevel, level, appearance);
|
||||
}
|
||||
|
||||
// HideClosedStackVisuals true sets the StackVisuals.Hide to the open state of the storage.
|
||||
// This is for containers that only show their contents when open. (e.g. donut boxes)
|
||||
if (storage.HideStackVisualsWhenClosed)
|
||||
@@ -1521,6 +1573,8 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void HandleOpenBackpack(ICommonSession? session)
|
||||
{
|
||||
HandleToggleSlotUI(session, "back");
|
||||
|
||||
Reference in New Issue
Block a user