Replaces AnchoredChanged C# event with ComponentMessage (#2905)
* Replaces AnchoredChanged C# event with ComponentMessage * Removes unneeded fields Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
using Content.Server.Utility;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -10,7 +11,6 @@ namespace Content.Server.GameObjects.Components.PA
|
||||
{
|
||||
public abstract class ParticleAcceleratorPartComponent : Component
|
||||
{
|
||||
[ViewVariables] private PhysicsComponent? _collidableComponent;
|
||||
[ViewVariables] public ParticleAcceleratorControlBoxComponent? Master;
|
||||
[ViewVariables] protected SnapGridComponent? SnapGrid;
|
||||
|
||||
@@ -18,14 +18,6 @@ namespace Content.Server.GameObjects.Components.PA
|
||||
{
|
||||
base.Initialize();
|
||||
// FIXME: this has to be an entity system, full stop.
|
||||
if (!Owner.TryGetComponent(out _collidableComponent))
|
||||
{
|
||||
Logger.Error("ParticleAcceleratorPartComponent created with no CollidableComponent");
|
||||
}
|
||||
else
|
||||
{
|
||||
_collidableComponent.AnchoredChanged += OnAnchorChanged;
|
||||
}
|
||||
|
||||
if (!Owner.TryGetComponent(out SnapGrid))
|
||||
{
|
||||
@@ -33,6 +25,17 @@ namespace Content.Server.GameObjects.Components.PA
|
||||
}
|
||||
}
|
||||
|
||||
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
||||
{
|
||||
base.HandleMessage(message, component);
|
||||
switch (message)
|
||||
{
|
||||
case AnchoredChangedMessage:
|
||||
OnAnchorChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAnchorChanged()
|
||||
{
|
||||
RescanIfPossible();
|
||||
|
||||
Reference in New Issue
Block a user