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:
py01
2021-01-04 22:32:59 -06:00
committed by GitHub
parent 350f7313be
commit 1032576a20
11 changed files with 126 additions and 87 deletions

View File

@@ -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();