mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Vector3, Vector4, Matrix4, and Quaternion are now gone. Use System.Numerics instead. This commit is just replacing usages, cleaning up using declarations, and moving over the (couple) helpers that are actually important.
60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
using System.Linq;
|
|
using System.Numerics;
|
|
using Robust.Shared.Map;
|
|
|
|
namespace Robust.Client.Placement.Modes
|
|
{
|
|
/// <summary>
|
|
/// Snaps in edge on one axis, center in the other.
|
|
/// </summary>
|
|
public sealed class AlignWallProper : PlacementMode
|
|
{
|
|
public AlignWallProper(PlacementManager pMan) : base(pMan)
|
|
{
|
|
}
|
|
|
|
public override void AlignPlacementMode(ScreenCoordinates mouseScreen)
|
|
{
|
|
MouseCoords = ScreenToCursorGrid(mouseScreen);
|
|
CurrentTile = GetTileRef(MouseCoords);
|
|
|
|
if (pManager.CurrentPermission!.IsTile)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var tileCoordinates = new EntityCoordinates(MouseCoords.EntityId, CurrentTile.GridIndices);
|
|
|
|
var offsets = new Vector2[]
|
|
{
|
|
new(0f, 0.5f),
|
|
new(0.5f, 0f),
|
|
new(0, -0.5f),
|
|
new(-0.5f, 0f)
|
|
};
|
|
|
|
var closestNode = offsets
|
|
.Select(o => tileCoordinates.Offset(o))
|
|
.MinBy(node => node.TryDistance(pManager.EntityManager, MouseCoords, out var distance) ?
|
|
distance :
|
|
(float?) null);
|
|
|
|
MouseCoords = closestNode;
|
|
}
|
|
|
|
public override bool IsValidPosition(EntityCoordinates position)
|
|
{
|
|
if (pManager.CurrentPermission!.IsTile)
|
|
{
|
|
return false;
|
|
}
|
|
else if (!RangeCheck(position))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|