2021-01-04 22:32:59 -06:00
|
|
|
#nullable enable
|
2020-10-28 19:19:47 +01:00
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.Log;
|
|
|
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects.Components.PA
|
|
|
|
|
{
|
|
|
|
|
public abstract class ParticleAcceleratorPartComponent : Component
|
|
|
|
|
{
|
|
|
|
|
[ViewVariables] public ParticleAcceleratorControlBoxComponent? Master;
|
|
|
|
|
[ViewVariables] protected SnapGridComponent? SnapGrid;
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
|
|
|
|
// FIXME: this has to be an entity system, full stop.
|
|
|
|
|
|
|
|
|
|
if (!Owner.TryGetComponent(out SnapGrid))
|
|
|
|
|
{
|
|
|
|
|
Logger.Error("ParticleAcceleratorControlBox was created without SnapGridComponent");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-04 22:32:59 -06:00
|
|
|
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
|
|
|
|
{
|
|
|
|
|
base.HandleMessage(message, component);
|
|
|
|
|
switch (message)
|
|
|
|
|
{
|
|
|
|
|
case AnchoredChangedMessage:
|
|
|
|
|
OnAnchorChanged();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-28 19:19:47 +01:00
|
|
|
public void OnAnchorChanged()
|
|
|
|
|
{
|
|
|
|
|
RescanIfPossible();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnRemove()
|
|
|
|
|
{
|
|
|
|
|
base.OnRemove();
|
|
|
|
|
|
|
|
|
|
RescanIfPossible();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RescanIfPossible()
|
|
|
|
|
{
|
|
|
|
|
Master?.RescanParts();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void Rotated()
|
|
|
|
|
{
|
|
|
|
|
RescanIfPossible();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|