mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-06 17:58:05 +02:00
* Tile Placement box actually uses the mouse snapgrid, not the players. * Placement box only snaps to grids if cursor is over grid. First tile of new grid is centered on cursor, instead of bottom left on cursor. * Place square now sticks to the edge of a grid. Cannot place tiles that would touch two grid Bounds.
50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using Robust.Shared.Map;
|
|
|
|
namespace Robust.Client.Placement.Modes
|
|
{
|
|
public 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 mapGrid = pManager.MapManager.GetGrid(MouseCoords.GridID);
|
|
CurrentTile = mapGrid.GetTileRef(MouseCoords);
|
|
float tileSize = mapGrid.TileSize; //convert from ushort to float
|
|
GridDistancing = tileSize;
|
|
|
|
if (pManager.CurrentPermission.IsTile)
|
|
{
|
|
MouseCoords = new GridCoordinates(CurrentTile.X + tileSize / 2,
|
|
CurrentTile.Y + tileSize / 2,
|
|
MouseCoords.GridID);
|
|
}
|
|
else
|
|
{
|
|
MouseCoords = new GridCoordinates(CurrentTile.X + tileSize / 2 + pManager.PlacementOffset.X,
|
|
CurrentTile.Y + tileSize / 2 + pManager.PlacementOffset.Y,
|
|
MouseCoords.GridID);
|
|
}
|
|
}
|
|
|
|
public override bool IsValidPosition(GridCoordinates position)
|
|
{
|
|
if (!RangeCheck(position))
|
|
{
|
|
return false;
|
|
}
|
|
if (!pManager.CurrentPermission.IsTile && !IsColliding(position))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|