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

@@ -27,9 +27,9 @@ public sealed partial class InteractionRelayComponent : Component
[Serializable, NetSerializable]
public sealed class InteractionRelayComponentState : ComponentState
{
public EntityUid? RelayEntity;
public NetEntity? RelayEntity;
public InteractionRelayComponentState(EntityUid? relayEntity)
public InteractionRelayComponentState(NetEntity? relayEntity)
{
RelayEntity = relayEntity;
}

View File

@@ -32,7 +32,7 @@ namespace Content.Shared.Interaction.Helpers
public static bool InRangeUnOccluded(
this EntityUid origin,
IContainer other,
BaseContainer other,
float range = InteractionRange,
Ignored? predicate = null,
bool ignoreInsideBlocker = true)
@@ -90,7 +90,7 @@ namespace Content.Shared.Interaction.Helpers
public static bool InRangeUnOccluded(
this IComponent origin,
IContainer other,
BaseContainer other,
float range = InteractionRange,
Ignored? predicate = null,
bool ignoreInsideBlocker = true)
@@ -130,7 +130,7 @@ namespace Content.Shared.Interaction.Helpers
#region Containers
public static bool InRangeUnOccluded(
this IContainer origin,
this BaseContainer origin,
EntityUid other,
float range = InteractionRange,
Ignored? predicate = null,
@@ -143,7 +143,7 @@ namespace Content.Shared.Interaction.Helpers
}
public static bool InRangeUnOccluded(
this IContainer origin,
this BaseContainer origin,
IComponent other,
float range = InteractionRange,
Ignored? predicate = null,
@@ -155,8 +155,8 @@ namespace Content.Shared.Interaction.Helpers
}
public static bool InRangeUnOccluded(
this IContainer origin,
IContainer other,
this BaseContainer origin,
BaseContainer other,
float range = InteractionRange,
Ignored? predicate = null,
bool ignoreInsideBlocker = true)
@@ -169,7 +169,7 @@ namespace Content.Shared.Interaction.Helpers
}
public static bool InRangeUnOccluded(
this IContainer origin,
this BaseContainer origin,
EntityCoordinates other,
float range = InteractionRange,
Ignored? predicate = null,
@@ -181,7 +181,7 @@ namespace Content.Shared.Interaction.Helpers
}
public static bool InRangeUnOccluded(
this IContainer origin,
this BaseContainer origin,
MapCoordinates other,
float range = InteractionRange,
Ignored? predicate = null,
@@ -226,7 +226,7 @@ namespace Content.Shared.Interaction.Helpers
public static bool InRangeUnOccluded(
this EntityCoordinates origin,
IContainer other,
BaseContainer other,
float range = InteractionRange,
Ignored? predicate = null,
bool ignoreInsideBlocker = true)
@@ -304,7 +304,7 @@ namespace Content.Shared.Interaction.Helpers
public static bool InRangeUnOccluded(
this MapCoordinates origin,
IContainer other,
BaseContainer other,
float range = InteractionRange,
Ignored? predicate = null,
bool ignoreInsideBlocker = true)

View File

@@ -13,7 +13,7 @@ public abstract partial class SharedInteractionSystem
private void OnGetState(EntityUid uid, InteractionRelayComponent component, ref ComponentGetState args)
{
args.State = new InteractionRelayComponentState(component.RelayEntity);
args.State = new InteractionRelayComponentState(GetNetEntity(component.RelayEntity));
}
private void OnHandleState(EntityUid uid, InteractionRelayComponent component, ref ComponentHandleState args)
@@ -21,7 +21,7 @@ public abstract partial class SharedInteractionSystem
if (args.Current is not InteractionRelayComponentState state)
return;
component.RelayEntity = state.RelayEntity;
component.RelayEntity = EnsureEntity<InteractionRelayComponent>(state.RelayEntity, uid);
}
public void SetRelay(EntityUid uid, EntityUid? relayEntity, InteractionRelayComponent? component = null)

View File

@@ -205,8 +205,10 @@ namespace Content.Shared.Interaction
/// </summary>
private void HandleInteractInventorySlotEvent(InteractInventorySlotEvent msg, EntitySessionEventArgs args)
{
var item = GetEntity(msg.ItemUid);
// client sanitization
if (!TryComp(msg.ItemUid, out TransformComponent? itemXform) || !ValidateClientInput(args.SenderSession, itemXform.Coordinates, msg.ItemUid, out var user))
if (!TryComp(item, out TransformComponent? itemXform) || !ValidateClientInput(args.SenderSession, itemXform.Coordinates, item, out var user))
{
Logger.InfoS("system.interaction", $"Inventory interaction validation failed. Session={args.SenderSession}");
return;
@@ -219,10 +221,10 @@ namespace Content.Shared.Interaction
if (msg.AltInteract)
// Use 'UserInteraction' function - behaves as if the user alt-clicked the item in the world.
UserInteraction(user.Value, itemXform.Coordinates, msg.ItemUid, msg.AltInteract);
UserInteraction(user.Value, itemXform.Coordinates, item, msg.AltInteract);
else
// User used 'E'. We want to activate it, not simulate clicking on the item
InteractionActivate(user.Value, msg.ItemUid);
InteractionActivate(user.Value, item);
}
public bool HandleAltUseInteraction(ICommonSession? session, EntityCoordinates coords, EntityUid uid)
@@ -1093,7 +1095,7 @@ namespace Content.Shared.Interaction
return false;
}
if (uid.IsClientSide())
if (IsClientSide(uid))
{
Logger.WarningS("system.interaction",
$"Client sent interaction with client-side entity. Session={session}, Uid={uid}");
@@ -1148,14 +1150,14 @@ namespace Content.Shared.Interaction
/// <summary>
/// Entity that was interacted with.
/// </summary>
public EntityUid ItemUid { get; }
public NetEntity ItemUid { get; }
/// <summary>
/// Whether the interaction used the alt-modifier to trigger alternative interactions.
/// </summary>
public bool AltInteract { get; }
public InteractInventorySlotEvent(EntityUid itemUid, bool altInteract = false)
public InteractInventorySlotEvent(NetEntity itemUid, bool altInteract = false)
{
ItemUid = itemUid;
AltInteract = altInteract;