mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using Robust.Shared.Map;
|
|
|
|
namespace Robust.Client.Placement.Modes
|
|
{
|
|
public sealed class AlignTileDense : PlacementMode
|
|
{
|
|
public override bool HasLineMode => true;
|
|
public override bool HasGridMode => true;
|
|
|
|
public AlignTileDense(PlacementManager pMan) : base(pMan) { }
|
|
|
|
public override void AlignPlacementMode(ScreenCoordinates mouseScreen)
|
|
{
|
|
MouseCoords = ScreenToCursorGrid(mouseScreen);
|
|
|
|
var tileSize = 1f;
|
|
var gridId = MouseCoords.GetGridId(pManager.EntityManager);
|
|
|
|
if (gridId.IsValid())
|
|
{
|
|
var mapGrid = pManager.MapManager.GetGrid(MouseCoords.GetGridId(pManager.EntityManager));
|
|
tileSize = mapGrid.TileSize; //convert from ushort to float
|
|
}
|
|
|
|
CurrentTile = GetTileRef(MouseCoords);
|
|
GridDistancing = tileSize;
|
|
|
|
if (pManager.CurrentPermission!.IsTile)
|
|
{
|
|
MouseCoords = new EntityCoordinates(MouseCoords.EntityId,
|
|
(CurrentTile.X + tileSize / 2, CurrentTile.Y + tileSize / 2));
|
|
}
|
|
else
|
|
{
|
|
MouseCoords = new EntityCoordinates(MouseCoords.EntityId,
|
|
(CurrentTile.X + tileSize / 2 + pManager.PlacementOffset.X,
|
|
CurrentTile.Y + tileSize / 2 + pManager.PlacementOffset.Y));
|
|
}
|
|
}
|
|
|
|
public override bool IsValidPosition(EntityCoordinates position)
|
|
{
|
|
if (!RangeCheck(position))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return pManager.CurrentPermission!.IsTile || IsColliding(position);
|
|
}
|
|
}
|
|
}
|