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

@@ -24,14 +24,16 @@ namespace Content.Shared.Verbs
if (user == null)
return;
var target = GetEntity(args.Target);
// It is possible that client-side prediction can cause this event to be raised after the target entity has
// been deleted. So we need to check that the entity still exists.
if (Deleted(args.Target) || Deleted(user))
if (Deleted(target) || Deleted(user))
return;
// Get the list of verbs. This effectively also checks that the requested verb is in fact a valid verb that
// the user can perform.
var verbs = GetLocalVerbs(args.Target, user.Value, args.RequestedVerb.GetType());
var verbs = GetLocalVerbs(target, user.Value, args.RequestedVerb.GetType());
// Note that GetLocalVerbs might waste time checking & preparing unrelated verbs even though we know
// precisely which one we want to run. However, MOST entities will only have 1 or 2 verbs of a given type.
@@ -39,7 +41,7 @@ namespace Content.Shared.Verbs
// Find the requested verb.
if (verbs.TryGetValue(args.RequestedVerb, out var verb))
ExecuteVerb(verb, user.Value, args.Target);
ExecuteVerb(verb, user.Value, target);
}
/// <summary>

View File

@@ -112,7 +112,7 @@ namespace Content.Shared.Verbs
/// If this is not null, and no icon or icon texture were specified, a sprite view of this entity will be
/// used as the icon for this verb.
/// </summary>
public EntityUid? IconEntity;
public NetEntity? IconEntity;
/// <summary>
/// Whether or not to close the context menu after using it to run this verb.
@@ -221,7 +221,7 @@ namespace Content.Shared.Verbs
typeof(AlternativeVerb),
typeof(ActivationVerb),
typeof(ExamineVerb),
typeof(EquipmentVerb)
typeof(EquipmentVerb)
};
}

View File

@@ -10,7 +10,7 @@ namespace Content.Shared.Verbs
[Serializable, NetSerializable]
public sealed class RequestServerVerbsEvent : EntityEventArgs
{
public readonly EntityUid EntityUid;
public readonly NetEntity EntityUid;
public readonly List<string> VerbTypes = new();
@@ -18,11 +18,11 @@ namespace Content.Shared.Verbs
/// If the target item is inside of some storage (e.g., backpack), this is the entity that owns that item
/// slot. Needed for validating that the user can access the target item.
/// </summary>
public readonly EntityUid? SlotOwner;
public readonly NetEntity? SlotOwner;
public readonly bool AdminRequest;
public RequestServerVerbsEvent(EntityUid entityUid, IEnumerable<Type> verbTypes, EntityUid? slotOwner = null, bool adminRequest = false)
public RequestServerVerbsEvent(NetEntity entityUid, IEnumerable<Type> verbTypes, NetEntity? slotOwner = null, bool adminRequest = false)
{
EntityUid = entityUid;
SlotOwner = slotOwner;
@@ -40,9 +40,9 @@ namespace Content.Shared.Verbs
public sealed class VerbsResponseEvent : EntityEventArgs
{
public readonly List<Verb>? Verbs;
public readonly EntityUid Entity;
public readonly NetEntity Entity;
public VerbsResponseEvent(EntityUid entity, SortedSet<Verb>? verbs)
public VerbsResponseEvent(NetEntity entity, SortedSet<Verb>? verbs)
{
Entity = entity;
@@ -57,10 +57,10 @@ namespace Content.Shared.Verbs
[Serializable, NetSerializable]
public sealed class ExecuteVerbEvent : EntityEventArgs
{
public readonly EntityUid Target;
public readonly NetEntity Target;
public readonly Verb RequestedVerb;
public ExecuteVerbEvent(EntityUid target, Verb requestedVerb)
public ExecuteVerbEvent(NetEntity target, Verb requestedVerb)
{
Target = target;
RequestedVerb = requestedVerb;