Add PlaceCentered bool to PlaceableSurfaceComponent (#2771)
* Added bool _placeCentered to check if an entity must be placed at mouse position or center of the PlaceableSurface (+ offset) when dropped. * private variables formatted to camel case * Use EqualsApprox in the setter for PositionOffset * -Changed client-side SurfaceComponent to camelCase -Added placeCentered and positionOffset to PlaceableSurfaceComponentState -Getter and setters for placeCentered and positionOffset client-side * Update Content.Client/GameObjects/Components/PlaceableSurfaceComponent.cs Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> * Add "_" to private vars name * Made YAML properties camelCase * Add "_" to private vars name * Call Dirty() when IsPlaceable,PlaceCentered and PositionOffset are changed. * Removed Dirty() from client. Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#nullable enable
|
||||
using Content.Shared.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.GameObjects.Components
|
||||
{
|
||||
@@ -9,6 +10,8 @@ namespace Content.Client.GameObjects.Components
|
||||
public class PlaceableSurfaceComponent : SharedPlaceableSurfaceComponent
|
||||
{
|
||||
private bool _isPlaceable;
|
||||
private bool _placeCentered;
|
||||
private Vector2 _positionOffset;
|
||||
|
||||
public override bool IsPlaceable
|
||||
{
|
||||
@@ -22,7 +25,36 @@ namespace Content.Client.GameObjects.Components
|
||||
|
||||
_isPlaceable = value;
|
||||
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +68,8 @@ namespace Content.Client.GameObjects.Components
|
||||
}
|
||||
|
||||
_isPlaceable = state.IsPlaceable;
|
||||
_placeCentered = state.PlaceCentered;
|
||||
_positionOffset = state.PositionOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user