Merge remote-tracking branch 'upstream/master' into ed-05-08-2024-upstream

# Conflicts:
#	Content.Shared/Inventory/InventorySystem.Equip.cs
#	Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs
This commit is contained in:
Ed
2024-08-12 14:40:15 +03:00
830 changed files with 27583 additions and 19536 deletions

View File

@@ -26,6 +26,7 @@ using Content.Shared.Popups;
using Content.Shared.Stacks;
using Content.Shared.Storage.Components;
using Content.Shared.Timing;
using Content.Shared.Storage.Events;
using Content.Shared.Verbs;
using Content.Shared.Whitelist;
using Robust.Shared.Audio;
@@ -373,7 +374,7 @@ public abstract class SharedStorageSystem : EntitySystem
if (_whitelistSystem.IsWhitelistPass(storageComp.CP14Ignorelist, args.Used))
return;
PlayerInsertHeldEntity(uid, args.User, storageComp);
PlayerInsertHeldEntity((uid, storageComp), args.User);
// Always handle it, even if insertion fails.
// We don't want to trigger any AfterInteract logic here.
// Example issue would be placing wires if item doesn't fit in backpack.
@@ -457,7 +458,7 @@ public abstract class SharedStorageSystem : EntitySystem
{
BreakOnDamage = true,
BreakOnMove = true,
NeedHand = true
NeedHand = true,
};
_doAfterSystem.TryStartDoAfter(doAfterArgs);
@@ -613,7 +614,15 @@ public abstract class SharedStorageSystem : EntitySystem
$"{ToPrettyString(player):player} is interacting with {ToPrettyString(item):item} while it is stored in {ToPrettyString(storage):storage} using {ToPrettyString(player.Comp.ActiveHandEntity):used}");
// Else, interact using the held item
_interactionSystem.InteractUsing(player, player.Comp.ActiveHandEntity.Value, item, Transform(item).Coordinates, checkCanInteract: false);
if (_interactionSystem.InteractUsing(player,
player.Comp.ActiveHandEntity.Value,
item,
Transform(item).Coordinates,
checkCanInteract: false))
return;
var failedEv = new StorageInsertFailedEvent((storage, storage.Comp), (player, player.Comp));
RaiseLocalEvent(storage, ref failedEv);
}
private void OnSetItemLocation(StorageSetItemLocationEvent msg, EntitySessionEventArgs args)
@@ -995,35 +1004,36 @@ public abstract class SharedStorageSystem : EntitySystem
/// <summary>
/// Inserts an entity into storage from the player's active hand
/// </summary>
/// <param name="uid"></param>
/// <param name="player">The player to insert an entity from</param>
/// <param name="storageComp"></param>
/// <returns>true if inserted, false otherwise</returns>
public bool PlayerInsertHeldEntity(EntityUid uid, EntityUid player, StorageComponent? storageComp = null)
/// <param name="ent">The storage entity and component to insert into.</param>
/// <param name="player">The player and hands component to insert the held entity from.</param>
/// <returns>True if inserted, otherwise false.</returns>
public bool PlayerInsertHeldEntity(Entity<StorageComponent?> ent, Entity<HandsComponent?> player)
{
if (!Resolve(uid, ref storageComp) || !TryComp(player, out HandsComponent? hands) || hands.ActiveHandEntity == null)
if (!Resolve(ent.Owner, ref ent.Comp)
|| !Resolve(player.Owner, ref player.Comp)
|| player.Comp.ActiveHandEntity == null)
return false;
var toInsert = hands.ActiveHandEntity;
var toInsert = player.Comp.ActiveHandEntity;
if (!CanInsert(uid, toInsert.Value, out var reason, storageComp))
if (!CanInsert(ent, toInsert.Value, out var reason, ent.Comp))
{
_popupSystem.PopupClient(Loc.GetString(reason ?? "comp-storage-cant-insert"), uid, player);
_popupSystem.PopupClient(Loc.GetString(reason ?? "comp-storage-cant-insert"), ent, player);
return false;
}
if (!_sharedHandsSystem.CanDrop(player, toInsert.Value, hands))
if (!_sharedHandsSystem.CanDrop(player, toInsert.Value, player.Comp))
{
_popupSystem.PopupClient(Loc.GetString("comp-storage-cant-drop", ("entity", toInsert.Value)), uid, player);
_popupSystem.PopupClient(Loc.GetString("comp-storage-cant-drop", ("entity", toInsert.Value)), ent, player);
return false;
}
return PlayerInsertEntityInWorld((uid, storageComp), player, toInsert.Value);
return PlayerInsertEntityInWorld((ent, ent.Comp), player, toInsert.Value);
}
/// <summary>
/// Inserts an Entity (<paramref name="toInsert"/>) in the world into storage, informing <paramref name="player"/> if it fails.
/// <paramref name="toInsert"/> is *NOT* held, see <see cref="PlayerInsertHeldEntity(EntityUid,EntityUid,StorageComponent)"/>.
/// <paramref name="toInsert"/> is *NOT* held, see <see cref="PlayerInsertHeldEntity(Entity{StorageComponent?},Entity{HandsComponent?})"/>.
/// </summary>
/// <param name="uid"></param>
/// <param name="player">The player to insert an entity with</param>