Small tweak and cleanup of spells and actions (#15943)
This commit is contained in:
@@ -5,12 +5,9 @@ using Content.Shared.Database;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using System.Linq;
|
||||
@@ -25,8 +22,8 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly RotateToFaceSystem _rotateToFaceSystem = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -98,7 +95,7 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
/// </summary>
|
||||
private void OnActionRequest(RequestPerformActionEvent ev, EntitySessionEventArgs args)
|
||||
{
|
||||
if (args.SenderSession.AttachedEntity is not EntityUid user)
|
||||
if (args.SenderSession.AttachedEntity is not { } user)
|
||||
return;
|
||||
|
||||
if (!TryComp(user, out ActionsComponent? component))
|
||||
@@ -134,7 +131,8 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
_rotateToFaceSystem.TryFaceCoordinates(user, Transform(entityTarget).WorldPosition);
|
||||
var targetWorldPos = _transformSystem.GetWorldPosition(entityTarget);
|
||||
_rotateToFaceSystem.TryFaceCoordinates(user, targetWorldPos);
|
||||
|
||||
if (!ValidateEntityTarget(user, entityTarget, entityAction))
|
||||
return;
|
||||
@@ -156,7 +154,7 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
|
||||
case WorldTargetAction worldAction:
|
||||
|
||||
if (ev.EntityCoordinatesTarget is not EntityCoordinates entityCoordinatesTarget)
|
||||
if (ev.EntityCoordinatesTarget is not { } entityCoordinatesTarget)
|
||||
{
|
||||
Logger.Error($"Attempted to perform a world-targeted action without a target! Action: {worldAction.DisplayName}");
|
||||
return;
|
||||
@@ -231,7 +229,8 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
if (action.Range <= 0)
|
||||
return true;
|
||||
|
||||
return (xform.WorldPosition - targetXform.WorldPosition).Length <= action.Range;
|
||||
var distance = (_transformSystem.GetWorldPosition(xform) - _transformSystem.GetWorldPosition(targetXform)).Length;
|
||||
return distance <= action.Range;
|
||||
}
|
||||
|
||||
if (_interactionSystem.InRangeUnobstructed(user, target, range: action.Range)
|
||||
@@ -259,7 +258,7 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
if (action.Range <= 0)
|
||||
return true;
|
||||
|
||||
return coords.InRange(EntityManager, Transform(user).Coordinates, action.Range);
|
||||
return coords.InRange(EntityManager, _transformSystem, Transform(user).Coordinates, action.Range);
|
||||
}
|
||||
|
||||
return _interactionSystem.InRangeUnobstructed(user, coords, range: action.Range);
|
||||
@@ -354,7 +353,7 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
{
|
||||
comp ??= EnsureComp<ActionsComponent>(uid);
|
||||
|
||||
bool allClientExclusive = true;
|
||||
var allClientExclusive = true;
|
||||
|
||||
foreach (var action in actions)
|
||||
{
|
||||
@@ -400,7 +399,7 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
private void OnDidEquip(EntityUid uid, ActionsComponent component, DidEquipEvent args)
|
||||
{
|
||||
var ev = new GetItemActionsEvent(args.SlotFlags);
|
||||
RaiseLocalEvent(args.Equipment, ev, false);
|
||||
RaiseLocalEvent(args.Equipment, ev);
|
||||
|
||||
if (ev.Actions.Count == 0)
|
||||
return;
|
||||
@@ -411,7 +410,7 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
private void OnHandEquipped(EntityUid uid, ActionsComponent component, DidEquipHandEvent args)
|
||||
{
|
||||
var ev = new GetItemActionsEvent();
|
||||
RaiseLocalEvent(args.Equipped, ev, false);
|
||||
RaiseLocalEvent(args.Equipped, ev);
|
||||
|
||||
if (ev.Actions.Count == 0)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user