2020-10-14 15:24:07 +02:00
|
|
|
#nullable enable
|
2020-07-06 14:27:03 -07:00
|
|
|
using Content.Shared.GameObjects.Components;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-01-10 13:07:33 +01:00
|
|
|
using Robust.Shared.Maths;
|
2020-07-06 14:27:03 -07:00
|
|
|
|
|
|
|
|
namespace Content.Client.GameObjects.Components
|
|
|
|
|
{
|
|
|
|
|
[RegisterComponent]
|
2020-10-14 15:24:07 +02:00
|
|
|
[ComponentReference(typeof(SharedPlaceableSurfaceComponent))]
|
2020-07-06 14:27:03 -07:00
|
|
|
public class PlaceableSurfaceComponent : SharedPlaceableSurfaceComponent
|
|
|
|
|
{
|
2020-10-14 15:24:07 +02:00
|
|
|
private bool _isPlaceable;
|
2021-01-10 13:07:33 +01:00
|
|
|
private bool _placeCentered;
|
|
|
|
|
private Vector2 _positionOffset;
|
2020-07-06 14:27:03 -07:00
|
|
|
|
2020-10-14 15:24:07 +02:00
|
|
|
public override bool IsPlaceable
|
|
|
|
|
{
|
|
|
|
|
get => _isPlaceable;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_isPlaceable == value)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_isPlaceable = value;
|
|
|
|
|
|
2021-01-10 13:07:33 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool PlaceCentered
|
|
|
|
|
{
|
|
|
|
|
get => _placeCentered;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_placeCentered == value)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_placeCentered = value;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Vector2 PositionOffset
|
|
|
|
|
{
|
|
|
|
|
get => _positionOffset;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (_positionOffset.EqualsApprox(value))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_positionOffset = value;
|
|
|
|
|
|
2020-10-14 15:24:07 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
|
|
|
|
{
|
|
|
|
|
base.HandleComponentState(curState, nextState);
|
|
|
|
|
|
2020-11-26 14:33:31 +01:00
|
|
|
if (curState is not PlaceableSurfaceComponentState state)
|
2020-10-14 15:24:07 +02:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_isPlaceable = state.IsPlaceable;
|
2021-01-10 13:07:33 +01:00
|
|
|
_placeCentered = state.PlaceCentered;
|
|
|
|
|
_positionOffset = state.PositionOffset;
|
2020-10-14 15:24:07 +02:00
|
|
|
}
|
2020-07-06 14:27:03 -07:00
|
|
|
}
|
|
|
|
|
}
|