Skip to content
Snippets Groups Projects
Commit 8701cc4f authored by Pőcze Barnabás's avatar Pőcze Barnabás
Browse files

Model: make some methods of Map static

parent 10b45a14
No related branches found
No related tags found
1 merge request!42Model misc changes
......@@ -108,7 +108,7 @@ namespace Model.Cartography
private bool IsInside(in Vec2i pos) => IsInside(pos.X, pos.Y);
private Vec2i GetNeighborPos(Vec2i pos, Orientation dir) {
private static Vec2i GetNeighborPos(Vec2i pos, Orientation dir) {
switch (dir) {
case Orientation.NORTH:
pos.Add(0, +1);
......@@ -127,7 +127,7 @@ namespace Model.Cartography
return pos;
}
private Vec2i GetAdjustedMapPosition(in Vec2i size, Orientation rotation, Vec2i pos) {
private static Vec2i GetAdjustedMapPosition(in Vec2i size, Orientation rotation, Vec2i pos) {
switch (rotation) {
case Orientation.NORTH:
/* nothing */
......@@ -149,7 +149,7 @@ namespace Model.Cartography
return pos;
}
private Orientation GetConnectableDirection(Orientation dir) {
private static Orientation GetConnectableDirection(Orientation dir) {
/* the eastern neighbor can be connected if it's open to west, etc. */
return dir.rotate(Orientation.SOUTH); /* 180 deg rotation */
}
......@@ -198,7 +198,7 @@ namespace Model.Cartography
return blueprint.CanPlace(this, mapPosition);
}
private Vec2i GetAdjustedSize(Vec2i size, Orientation rotation) {
private static Vec2i GetAdjustedSize(Vec2i size, Orientation rotation) {
switch (rotation) {
case Orientation.NORTH:
case Orientation.SOUTH:
......@@ -249,7 +249,7 @@ namespace Model.Cartography
}
}
public Vec2i InnerToWorldPosition(IMapObjectBlueprint blueprint, in MapPosition mapPosition, in Vec2i pos) {
public static Vec2i InnerToWorldPosition(IMapObjectBlueprint blueprint, in MapPosition mapPosition, in Vec2i pos) {
return GetAdjustedMapPosition(blueprint.GetSize(), mapPosition.Orientation, pos).Add(mapPosition.Coords);
}
}
......
......@@ -36,7 +36,7 @@ namespace Model.Landscape.Blueprints
return true;
foreach (var nc in navcells) {
var p = map.InnerToWorldPosition(this, mapPosition, nc.Position);
var p = Map.InnerToWorldPosition(this, mapPosition, nc.Position);
foreach (var n in map.GetNeighbors(p)) {
if (map.GetObjectAt(n) is QueuePavement)
......
......@@ -61,7 +61,7 @@ namespace Model.Landscape
Park.Instance.ModifyBalance(-blueprint.ConstructionCost);
var entrancePosition = blueprint.GetNavigableCells().Single().Position;
entrancePosition = Simulation.Instance.Map.InnerToWorldPosition(blueprint, position.MapPosition, entrancePosition);
entrancePosition = Map.InnerToWorldPosition(blueprint, position.MapPosition, entrancePosition);
ExitPosition = new Vector2(entrancePosition.X + 0.5f, entrancePosition.Y + 0.5f); // XXX: maybe improve
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment