Files
RobustToolbox/Robust.Client/Placement/Modes/AlignTileDense.cs
T
AcruidandPieter-Jan Briers c4fb96b5e8 Tile Placement Improvements (#808)
* 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.
2019-05-11 15:58:28 +02:00

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;
}
}
}