mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-06 17:58:05 +02:00
* 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.
26 lines
743 B
C#
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);
|
|
}
|
|
}
|
|
}
|