Subscribe TransformComponent events by-ref (#4478)

This commit is contained in:
Vera Aguilera Puerto
2021-08-21 11:49:31 +02:00
committed by GitHub
parent bbbebbadf7
commit ad5f7bb71b
16 changed files with 25 additions and 22 deletions

View File

@@ -282,7 +282,7 @@ namespace Content.Client.ContextMenu.UI
} }
} }
public void HandleMoveEvent(MoveEvent ev) public void HandleMoveEvent(ref MoveEvent ev)
{ {
if (_contextMenuView.Elements.Count == 0) return; if (_contextMenuView.Elements.Count == 0) return;
var entity = ev.Sender; var entity = ev.Sender;

View File

@@ -91,7 +91,7 @@ namespace Content.Client.IconSmoothing
} }
} }
private static void HandleAnchorChanged(EntityUid uid, IconSmoothComponent component, AnchorStateChangedEvent args) private static void HandleAnchorChanged(EntityUid uid, IconSmoothComponent component, ref AnchorStateChangedEvent args)
{ {
component.AnchorStateChanged(); component.AnchorStateChanged();
} }

View File

@@ -25,7 +25,7 @@ namespace Content.Client.Window
} }
} }
private static void HandleAnchorChanged(EntityUid uid, WindowComponent component, AnchorStateChangedEvent args) private static void HandleAnchorChanged(EntityUid uid, WindowComponent component, ref AnchorStateChangedEvent args)
{ {
component.AnchorStateChanged(); component.AnchorStateChanged();
} }

View File

@@ -289,7 +289,7 @@ namespace Content.Server.AI.Pathfinding
_lastKnownPositions.Remove(entity); _lastKnownPositions.Remove(entity);
} }
private void QueueMoveEvent(MoveEvent moveEvent) private void QueueMoveEvent(ref MoveEvent moveEvent)
{ {
_moveUpdateQueue.Enqueue(moveEvent); _moveUpdateQueue.Enqueue(moveEvent);
} }

View File

@@ -26,7 +26,10 @@ namespace Content.Server.Atmos.EntitySystems
private void OnAirtightInit(EntityUid uid, AirtightComponent airtight, ComponentInit args) private void OnAirtightInit(EntityUid uid, AirtightComponent airtight, ComponentInit args)
{ {
if (airtight.FixAirBlockedDirectionInitialize) if (airtight.FixAirBlockedDirectionInitialize)
OnAirtightRotated(uid, airtight, new RotateEvent(airtight.Owner, Angle.Zero, airtight.Owner.Transform.WorldRotation)); {
var rotateEvent = new RotateEvent(airtight.Owner, Angle.Zero, airtight.Owner.Transform.WorldRotation);
OnAirtightRotated(uid, airtight, ref rotateEvent);
}
// Adding this component will immediately anchor the entity, because the atmos system // Adding this component will immediately anchor the entity, because the atmos system
// requires airtight entities to be anchored for performance. // requires airtight entities to be anchored for performance.
@@ -51,7 +54,7 @@ namespace Content.Server.Atmos.EntitySystems
{ {
} }
private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, AnchorStateChangedEvent args) private void OnAirtightPositionChanged(EntityUid uid, AirtightComponent airtight, ref AnchorStateChangedEvent args)
{ {
var gridId = airtight.Owner.Transform.GridID; var gridId = airtight.Owner.Transform.GridID;
var coords = airtight.Owner.Transform.Coordinates; var coords = airtight.Owner.Transform.Coordinates;
@@ -64,7 +67,7 @@ namespace Content.Server.Atmos.EntitySystems
InvalidatePosition(gridId, tilePos); InvalidatePosition(gridId, tilePos);
} }
private void OnAirtightRotated(EntityUid uid, AirtightComponent airtight, RotateEvent ev) private void OnAirtightRotated(EntityUid uid, AirtightComponent airtight, ref RotateEvent ev)
{ {
if (!airtight.RotateAirBlocked || airtight.InitialAirBlockedDirection == (int)AtmosDirection.Invalid) if (!airtight.RotateAirBlocked || airtight.InitialAirBlockedDirection == (int)AtmosDirection.Invalid)
return; return;

View File

@@ -98,7 +98,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
LeaveAtmosphere(component); LeaveAtmosphere(component);
} }
private void OnDeviceAnchorChanged(EntityUid uid, AtmosDeviceComponent component, AnchorStateChangedEvent args) private void OnDeviceAnchorChanged(EntityUid uid, AtmosDeviceComponent component, ref AnchorStateChangedEvent args)
{ {
// Do nothing if the component doesn't require being anchored to function. // Do nothing if the component doesn't require being anchored to function.
if (!component.RequireAnchored) if (!component.RequireAnchored)
@@ -110,7 +110,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems
LeaveAtmosphere(component); LeaveAtmosphere(component);
} }
private void OnDeviceParentChanged(EntityUid uid, AtmosDeviceComponent component, EntParentChangedMessage args) private void OnDeviceParentChanged(EntityUid uid, AtmosDeviceComponent component, ref EntParentChangedMessage args)
{ {
RejoinAtmosphere(component); RejoinAtmosphere(component);
} }

View File

@@ -45,7 +45,7 @@ namespace Content.Server.Buckle
} }
} }
private void MoveEvent(EntityUid uid, BuckleComponent buckle, MoveEvent ev) private void MoveEvent(EntityUid uid, BuckleComponent buckle, ref MoveEvent ev)
{ {
var strap = buckle.BuckledTo; var strap = buckle.BuckledTo;
@@ -64,7 +64,7 @@ namespace Content.Server.Buckle
buckle.TryUnbuckle(buckle.Owner, true); buckle.TryUnbuckle(buckle.Owner, true);
} }
private void RotateEvent(EntityUid uid, StrapComponent strap, RotateEvent ev) private void RotateEvent(EntityUid uid, StrapComponent strap, ref RotateEvent ev)
{ {
// On rotation of a strap, reattach all buckled entities. // On rotation of a strap, reattach all buckled entities.
// This fixes buckle offsets and draw depths. // This fixes buckle offsets and draw depths.

View File

@@ -97,7 +97,7 @@ namespace Content.Server.Gravity.EntitySystems
status.ClearAlert(AlertType.Weightless); status.ClearAlert(AlertType.Weightless);
} }
private void EntParentChanged(EntParentChangedMessage ev) private void EntParentChanged(ref EntParentChangedMessage ev)
{ {
if (!ev.Entity.TryGetComponent(out ServerAlertsComponent? status)) if (!ev.Entity.TryGetComponent(out ServerAlertsComponent? status))
{ {

View File

@@ -50,7 +50,7 @@ namespace Content.Server.NodeContainer.EntitySystems
private static void OnAnchorStateChanged( private static void OnAnchorStateChanged(
EntityUid uid, EntityUid uid,
NodeContainerComponent component, NodeContainerComponent component,
AnchorStateChangedEvent args) ref AnchorStateChangedEvent args)
{ {
foreach (var node in component.Nodes.Values) foreach (var node in component.Nodes.Values)
{ {
@@ -59,7 +59,7 @@ namespace Content.Server.NodeContainer.EntitySystems
} }
} }
private static void OnRotateEvent(EntityUid uid, NodeContainerComponent container, RotateEvent ev) private static void OnRotateEvent(EntityUid uid, NodeContainerComponent container, ref RotateEvent ev)
{ {
if (ev.NewRotation == ev.OldRotation) if (ev.NewRotation == ev.OldRotation)
{ {
@@ -69,7 +69,7 @@ namespace Content.Server.NodeContainer.EntitySystems
foreach (var node in container.Nodes.Values) foreach (var node in container.Nodes.Values)
{ {
if (node is not IRotatableNode rotatableNode) continue; if (node is not IRotatableNode rotatableNode) continue;
rotatableNode.RotateEvent(ev); rotatableNode.RotateEvent(ref ev);
} }
} }
} }

View File

@@ -11,6 +11,6 @@ namespace Content.Server.NodeContainer.Nodes
/// <summary> /// <summary>
/// Rotates this <see cref="Node"/>. /// Rotates this <see cref="Node"/>.
/// </summary> /// </summary>
void RotateEvent(RotateEvent ev); void RotateEvent(ref RotateEvent ev);
} }
} }

View File

@@ -121,7 +121,7 @@ namespace Content.Server.NodeContainer.Nodes
/// <summary> /// <summary>
/// Rotates the <see cref="PipeDirection"/> when the entity is rotated, and re-calculates the <see cref="IPipeNet"/>. /// Rotates the <see cref="PipeDirection"/> when the entity is rotated, and re-calculates the <see cref="IPipeNet"/>.
/// </summary> /// </summary>
void IRotatableNode.RotateEvent(RotateEvent ev) void IRotatableNode.RotateEvent(ref RotateEvent ev)
{ {
if (!RotationsEnabled) return; if (!RotationsEnabled) return;
var diff = ev.NewRotation - ev.OldRotation; var diff = ev.NewRotation - ev.OldRotation;

View File

@@ -23,7 +23,7 @@ namespace Content.Server.ParticleAccelerator.EntitySystems
component.OnAnchorChanged(); component.OnAnchorChanged();
} }
private static void RotateEvent(RotateEvent ev) private static void RotateEvent(ref RotateEvent ev)
{ {
if (ev.Sender.TryGetComponent(out ParticleAcceleratorPartComponent? part)) if (ev.Sender.TryGetComponent(out ParticleAcceleratorPartComponent? part))
{ {

View File

@@ -58,7 +58,7 @@ namespace Content.Server.Shuttles
/// <summary> /// <summary>
/// If pilot is moved then we'll stop them from piloting. /// If pilot is moved then we'll stop them from piloting.
/// </summary> /// </summary>
private void HandlePilotMove(EntityUid uid, PilotComponent component, MoveEvent args) private void HandlePilotMove(EntityUid uid, PilotComponent component, ref MoveEvent args)
{ {
if (component.Console == null) return; if (component.Console == null) return;
RemovePilot(component); RemovePilot(component);

View File

@@ -125,7 +125,7 @@ namespace Content.Shared.Pulling
_stoppedMoving.Add(component); _stoppedMoving.Add(component);
} }
private void PullerMoved(MoveEvent ev) private void PullerMoved(ref MoveEvent ev)
{ {
var puller = ev.Sender; var puller = ev.Sender;
if (!TryGetPulled(ev.Sender, out var pulled)) if (!TryGetPulled(ev.Sender, out var pulled))

View File

@@ -81,7 +81,7 @@ namespace Content.Shared.SubFloor
UpdateEntity(uid, true); UpdateEntity(uid, true);
} }
private void HandleAnchorChanged(EntityUid uid, SubFloorHideComponent component, AnchorStateChangedEvent args) private void HandleAnchorChanged(EntityUid uid, SubFloorHideComponent component, ref AnchorStateChangedEvent args)
{ {
var transform = ComponentManager.GetComponent<ITransformComponent>(uid); var transform = ComponentManager.GetComponent<ITransformComponent>(uid);