Content update for NetEntities (#18935)

This commit is contained in:
metalgearsloth
2023-09-11 09:42:41 +10:00
committed by GitHub
parent 389c8d1a2c
commit 5a0fc68be2
526 changed files with 3058 additions and 2215 deletions

View File

@@ -246,6 +246,9 @@ namespace Content.Shared.Containers.ItemSlots
/// </remarks>
public bool CanInsert(EntityUid uid, EntityUid usedUid, EntityUid? user, ItemSlot slot, bool swap = false, EntityUid? popup = null)
{
if (slot.ContainerSlot == null)
return false;
if (slot.Locked)
return false;
@@ -265,7 +268,7 @@ namespace Content.Shared.Containers.ItemSlots
if (ev.Cancelled)
return false;
return slot.ContainerSlot?.CanInsertIfEmpty(usedUid, EntityManager) ?? false;
return _containers.CanInsert(usedUid, slot.ContainerSlot, assumeEmpty: true);
}
/// <summary>
@@ -325,16 +328,16 @@ namespace Content.Shared.Containers.ItemSlots
public bool CanEject(EntityUid uid, EntityUid? user, ItemSlot slot)
{
if (slot.Locked || slot.Item == null)
if (slot.Locked || slot.ContainerSlot?.ContainedEntity is not {} item)
return false;
var ev = new ItemSlotEjectAttemptEvent(uid, slot.Item.Value, user, slot);
var ev = new ItemSlotEjectAttemptEvent(uid, item, user, slot);
RaiseLocalEvent(uid, ref ev);
RaiseLocalEvent(slot.Item.Value, ref ev);
RaiseLocalEvent(item, ref ev);
if (ev.Cancelled)
return false;
return slot.ContainerSlot?.CanRemove(slot.Item.Value, EntityManager) ?? false;
return _containers.CanRemove(item, slot.ContainerSlot);
}
/// <summary>
@@ -435,11 +438,13 @@ namespace Content.Shared.Containers.ItemSlots
var verbSubject = slot.Name != string.Empty
? Loc.GetString(slot.Name)
: Name(args.Using.Value) ?? string.Empty;
: Name(args.Using.Value);
AlternativeVerb verb = new();
verb.IconEntity = args.Using;
verb.Act = () => Insert(uid, slot, args.Using.Value, args.User, excludeUserAudio: true);
AlternativeVerb verb = new()
{
IconEntity = GetNetEntity(args.Using),
Act = () => Insert(uid, slot, args.Using.Value, args.User, excludeUserAudio: true)
};
if (slot.InsertVerbText != null)
{
@@ -491,7 +496,7 @@ namespace Content.Shared.Containers.ItemSlots
AlternativeVerb verb = new()
{
IconEntity = slot.Item,
IconEntity = GetNetEntity(slot.Item),
Act = () => TryEjectToHands(uid, slot, args.User, excludeUserAudio: true)
};
@@ -528,9 +533,11 @@ namespace Content.Shared.Containers.ItemSlots
? Loc.GetString(slot.Name)
: Name(slot.Item!.Value);
InteractionVerb takeVerb = new();
takeVerb.IconEntity = slot.Item;
takeVerb.Act = () => TryEjectToHands(uid, slot, args.User, excludeUserAudio: true);
InteractionVerb takeVerb = new()
{
IconEntity = GetNetEntity(slot.Item),
Act = () => TryEjectToHands(uid, slot, args.User, excludeUserAudio: true)
};
if (slot.EjectVerbText == null)
takeVerb.Text = Loc.GetString("take-item-verb-text", ("subject", verbSubject));
@@ -556,7 +563,7 @@ namespace Content.Shared.Containers.ItemSlots
InteractionVerb insertVerb = new()
{
IconEntity = args.Using,
IconEntity = GetNetEntity(args.Using),
Act = () => Insert(uid, slot, args.Using.Value, args.User, excludeUserAudio: true)
};