Skip to content

Commit

Permalink
Makes Coordinates more Structy (#417)
Browse files Browse the repository at this point in the history
More readonly-ish and less write-ish
  • Loading branch information
clusterfack authored Sep 14, 2017
1 parent 4c26327 commit 1bb0227
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
2 changes: 1 addition & 1 deletion SS14.Client/Placement/Modes/AlignSnapgridBorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override bool Update(ScreenCoordinates mouseS)
(float)Math.Round((mouseCoords.Y / (double)snapsize), MidpointRounding.AwayFromZero) * snapsize);

//Convert back to original world and screen coordinates after applying offset
mouseCoords.Position = mouselocal + new Vector2(pManager.CurrentPrototype.PlacementOffset.X, pManager.CurrentPrototype.PlacementOffset.Y);
mouseCoords = new LocalCoordinates(mouselocal + new Vector2(pManager.CurrentPrototype.PlacementOffset.X, pManager.CurrentPrototype.PlacementOffset.Y), mouseCoords.Grid);
mouseScreen = CluwneLib.WorldToScreen(mouseCoords);

if (!RangeCheck())
Expand Down
28 changes: 6 additions & 22 deletions SS14.Shared/Map/Coordinates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,11 @@ public struct LocalCoordinates
{
public readonly int GridID;
public readonly int MapID;
public Vector2 Position;
public readonly Vector2 Position;

public float X
{
get => Position.X;
set => new LocalCoordinates(value, Position.Y, GridID, MapID);
}
public float X => Position.X;

public float Y
{
get => Position.Y;
set => new LocalCoordinates(Position.X, value, GridID, MapID);
}
public float Y => Position.Y;

public IMap Map => IoCManager.Resolve<IMapManager>().GetMap(MapID);

Expand Down Expand Up @@ -90,19 +82,11 @@ public bool InRange(LocalCoordinates localpos, int range)
public struct ScreenCoordinates
{
public readonly int MapID;
public Vector2 Position;
public readonly Vector2 Position;

public float X
{
get => Position.X;
set => new ScreenCoordinates(value, Position.Y, MapID);
}
public float X => Position.X;

public float Y
{
get => Position.Y;
set => new ScreenCoordinates(Position.X, value, MapID);
}
public float Y => Position.Y;

public ScreenCoordinates(Vector2 argPosition, int argMap)
{
Expand Down

0 comments on commit 1bb0227

Please sign in to comment.