Files
RobustToolbox/Robust.Shared/GameObjects/Systems/SnapGridSystem.cs
T
AcruidandGitHub 713f702064 Engine Entity Anchoring (#1829)
* Added unit tests for the new anchor system design.

* Amend ME!

* SnapGridComponent now anchors the entity when added or removed.
TransformComponent.Anchored properly replicates it's state to clients.

* Converted all SnapGridPositionChangedEvent subscriptions to AnchorStateChangedEvent.
Removed SnapGridPositionChangedEvent.
Obsoleted SnapGridComponent.

* Allows setting Transform.Anchored in prototypes.

* Changing tile to empty under anchored ents unanchors them.

* More unit testing.

* Migrated transform gamestate tests to RobustServerSimulation.

* Fixed nasty off-by-one error when sending a full server state.

* Adds lifetime stages to Component.

* More test fixing.

* Review changes.
2021-06-19 17:26:18 -07:00

26 lines
743 B
C#

using JetBrains.Annotations;
namespace Robust.Shared.GameObjects
{
[UsedImplicitly]
internal class SnapGridSystem : EntitySystem
{
/// <inheritdoc />
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SnapGridComponent, ComponentStartup>(HandleComponentStartup);
}
private void HandleComponentStartup(EntityUid uid, SnapGridComponent component, ComponentStartup args)
{
var transform = ComponentManager.GetComponent<ITransformComponent>(uid);
transform.Anchored = true;
// Remove us, we have been migrated.
ComponentManager.RemoveComponent<SnapGridComponent>(uid);
}
}
}