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.
|
|
|
|
|
|
2021-03-31 12:41:23 -07:00
|
|
|
Owner.EnsureComponent<SnapGridComponent>(out SnapGrid);
|
2020-10-28 19:19:47 +01:00
|
|
|
}
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|