PlaceableSurface ECS (#8013)
This commit is contained in:
@@ -1,12 +1,5 @@
|
|||||||
using System;
|
|
||||||
using Robust.Shared.Analyzers;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Players;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
|
||||||
using Robust.Shared.ViewVariables;
|
|
||||||
|
|
||||||
namespace Content.Shared.Placeable
|
namespace Content.Shared.Placeable
|
||||||
{
|
{
|
||||||
@@ -25,11 +18,6 @@ namespace Content.Shared.Placeable
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
[DataField("positionOffset")]
|
[DataField("positionOffset")]
|
||||||
public Vector2 PositionOffset { get; set; }
|
public Vector2 PositionOffset { get; set; }
|
||||||
|
|
||||||
public override ComponentState GetComponentState()
|
|
||||||
{
|
|
||||||
return new PlaceableSurfaceComponentState(IsPlaceable,PlaceCentered, PositionOffset);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
|
|||||||
@@ -14,16 +14,22 @@ namespace Content.Shared.Placeable
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<PlaceableSurfaceComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
|
SubscribeLocalEvent<PlaceableSurfaceComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
|
||||||
|
SubscribeLocalEvent<PlaceableSurfaceComponent, ComponentGetState>(OnGetState);
|
||||||
SubscribeLocalEvent<PlaceableSurfaceComponent, ComponentHandleState>(OnHandleState);
|
SubscribeLocalEvent<PlaceableSurfaceComponent, ComponentHandleState>(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)
|
public void SetPlaceable(EntityUid uid, bool isPlaceable, PlaceableSurfaceComponent? surface = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref surface))
|
if (!Resolve(uid, ref surface))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
surface.IsPlaceable = isPlaceable;
|
surface.IsPlaceable = isPlaceable;
|
||||||
surface.Dirty();
|
Dirty(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPlaceCentered(EntityUid uid, bool placeCentered, PlaceableSurfaceComponent? surface = null)
|
public void SetPlaceCentered(EntityUid uid, bool placeCentered, PlaceableSurfaceComponent? surface = null)
|
||||||
@@ -32,7 +38,7 @@ namespace Content.Shared.Placeable
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
surface.PlaceCentered = placeCentered;
|
surface.PlaceCentered = placeCentered;
|
||||||
surface.Dirty();
|
Dirty(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPositionOffset(EntityUid uid, Vector2 offset, PlaceableSurfaceComponent? surface = null)
|
public void SetPositionOffset(EntityUid uid, Vector2 offset, PlaceableSurfaceComponent? surface = null)
|
||||||
@@ -41,7 +47,7 @@ namespace Content.Shared.Placeable
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
surface.PositionOffset = offset;
|
surface.PositionOffset = offset;
|
||||||
surface.Dirty();
|
Dirty(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAfterInteractUsing(EntityUid uid, PlaceableSurfaceComponent surface, AfterInteractUsingEvent args)
|
private void OnAfterInteractUsing(EntityUid uid, PlaceableSurfaceComponent surface, AfterInteractUsingEvent args)
|
||||||
|
|||||||
Reference in New Issue
Block a user