Skip to content

Commit 1bb0227

Browse files
author
clusterfack
authored
Makes Coordinates more Structy (#417)
More readonly-ish and less write-ish
1 parent 4c26327 commit 1bb0227

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

SS14.Client/Placement/Modes/AlignSnapgridBorder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public override bool Update(ScreenCoordinates mouseS)
6060
(float)Math.Round((mouseCoords.Y / (double)snapsize), MidpointRounding.AwayFromZero) * snapsize);
6161

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

6666
if (!RangeCheck())

SS14.Shared/Map/Coordinates.cs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,11 @@ public struct LocalCoordinates
1414
{
1515
public readonly int GridID;
1616
public readonly int MapID;
17-
public Vector2 Position;
17+
public readonly Vector2 Position;
1818

19-
public float X
20-
{
21-
get => Position.X;
22-
set => new LocalCoordinates(value, Position.Y, GridID, MapID);
23-
}
19+
public float X => Position.X;
2420

25-
public float Y
26-
{
27-
get => Position.Y;
28-
set => new LocalCoordinates(Position.X, value, GridID, MapID);
29-
}
21+
public float Y => Position.Y;
3022

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

@@ -90,19 +82,11 @@ public bool InRange(LocalCoordinates localpos, int range)
9082
public struct ScreenCoordinates
9183
{
9284
public readonly int MapID;
93-
public Vector2 Position;
85+
public readonly Vector2 Position;
9486

95-
public float X
96-
{
97-
get => Position.X;
98-
set => new ScreenCoordinates(value, Position.Y, MapID);
99-
}
87+
public float X => Position.X;
10088

101-
public float Y
102-
{
103-
get => Position.Y;
104-
set => new ScreenCoordinates(Position.X, value, MapID);
105-
}
89+
public float Y => Position.Y;
10690

10791
public ScreenCoordinates(Vector2 argPosition, int argMap)
10892
{

0 commit comments

Comments
 (0)