From 8474db1598debd9aadf8f18632c09552ea344610 Mon Sep 17 00:00:00 2001 From: metalgearsloth Date: Sun, 8 May 2022 15:46:59 +1000 Subject: [PATCH] PlaceableSurface ECS --- .../Placeable/PlaceableSurfaceComponent.cs | 12 ------------ Content.Shared/Placeable/PlaceableSurfaceSystem.cs | 12 +++++++++--- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/Content.Shared/Placeable/PlaceableSurfaceComponent.cs b/Content.Shared/Placeable/PlaceableSurfaceComponent.cs index 0f56a346e02e..f4e64f240a38 100644 --- a/Content.Shared/Placeable/PlaceableSurfaceComponent.cs +++ b/Content.Shared/Placeable/PlaceableSurfaceComponent.cs @@ -1,12 +1,5 @@ -using System; -using Robust.Shared.Analyzers; -using Robust.Shared.GameObjects; using Robust.Shared.GameStates; -using Robust.Shared.Maths; -using Robust.Shared.Players; using Robust.Shared.Serialization; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.ViewVariables; namespace Content.Shared.Placeable { @@ -25,11 +18,6 @@ public sealed class PlaceableSurfaceComponent : Component [ViewVariables] [DataField("positionOffset")] public Vector2 PositionOffset { get; set; } - - public override ComponentState GetComponentState() - { - return new PlaceableSurfaceComponentState(IsPlaceable,PlaceCentered, PositionOffset); - } } [Serializable, NetSerializable] diff --git a/Content.Shared/Placeable/PlaceableSurfaceSystem.cs b/Content.Shared/Placeable/PlaceableSurfaceSystem.cs index 949b28b93b1f..8ea09407634c 100644 --- a/Content.Shared/Placeable/PlaceableSurfaceSystem.cs +++ b/Content.Shared/Placeable/PlaceableSurfaceSystem.cs @@ -14,16 +14,22 @@ public override void Initialize() base.Initialize(); SubscribeLocalEvent(OnAfterInteractUsing); + SubscribeLocalEvent(OnGetState); SubscribeLocalEvent(OnHandleState); } + private void OnGetState(EntityUid uid, PlaceableSurfaceComponent component, ref ComponentGetState args) + { + args.State = new PlaceableSurfaceComponentState(component.IsPlaceable, component.PlaceCentered, component.PositionOffset); + } + public void SetPlaceable(EntityUid uid, bool isPlaceable, PlaceableSurfaceComponent? surface = null) { if (!Resolve(uid, ref surface)) return; surface.IsPlaceable = isPlaceable; - surface.Dirty(); + Dirty(surface); } public void SetPlaceCentered(EntityUid uid, bool placeCentered, PlaceableSurfaceComponent? surface = null) @@ -32,7 +38,7 @@ public void SetPlaceCentered(EntityUid uid, bool placeCentered, PlaceableSurface return; surface.PlaceCentered = placeCentered; - surface.Dirty(); + Dirty(surface); } public void SetPositionOffset(EntityUid uid, Vector2 offset, PlaceableSurfaceComponent? surface = null) @@ -41,7 +47,7 @@ public void SetPositionOffset(EntityUid uid, Vector2 offset, PlaceableSurfaceCom return; surface.PositionOffset = offset; - surface.Dirty(); + Dirty(surface); } private void OnAfterInteractUsing(EntityUid uid, PlaceableSurfaceComponent surface, AfterInteractUsingEvent args)