make CollisionTargets an auto property
GitOrigin-RevId: ca7bf8f68bdc9cacef191cff5efe930ca7942b34
This commit is contained in:
parent
76dbdc6913
commit
bb8cf9e63b
@ -83,7 +83,6 @@ namespace SemiColinGames {
|
|||||||
|
|
||||||
public const int TileSize = 16;
|
public const int TileSize = 16;
|
||||||
readonly Tile[] tiles;
|
readonly Tile[] tiles;
|
||||||
readonly Aabb[] collisionTargets;
|
|
||||||
|
|
||||||
// Size of World in terms of tile grid.
|
// Size of World in terms of tile grid.
|
||||||
private readonly int tileWidth;
|
private readonly int tileWidth;
|
||||||
@ -160,24 +159,24 @@ namespace SemiColinGames {
|
|||||||
}
|
}
|
||||||
tiles = tilesList.ToArray();
|
tiles = tilesList.ToArray();
|
||||||
|
|
||||||
// Because we added tiles from left to right, the collisionTargets are sorted by x-position.
|
// Because we added tiles from left to right, the CollisionTargets are sorted by x-position.
|
||||||
// We maintain this invariant so that it's possible to efficiently find collisionTargets that
|
// We maintain this invariant so that it's possible to efficiently find CollisionTargets that
|
||||||
// are nearby a given x-position.
|
// are nearby a given x-position.
|
||||||
collisionTargets = new Aabb[tiles.Length + 2];
|
CollisionTargets = new Aabb[tiles.Length + 2];
|
||||||
|
|
||||||
// Add a synthetic collisionTarget on the left side of the world.
|
// Add a synthetic collisionTarget on the left side of the world.
|
||||||
collisionTargets[0] = new Aabb(new Vector2(-1, 0), new Vector2(1, float.MaxValue));
|
CollisionTargets[0] = new Aabb(new Vector2(-1, 0), new Vector2(1, float.MaxValue));
|
||||||
|
|
||||||
// Now add all the normal collisionTargets for every static terrain tile.
|
// Now add all the normal collisionTargets for every static terrain tile.
|
||||||
Vector2 halfSize = new Vector2(TileSize / 2, TileSize / 2);
|
Vector2 halfSize = new Vector2(TileSize / 2, TileSize / 2);
|
||||||
for (int i = 0; i < tiles.Length; i++) {
|
for (int i = 0; i < tiles.Length; i++) {
|
||||||
Vector2 center = new Vector2(
|
Vector2 center = new Vector2(
|
||||||
tiles[i].Position.Left + halfSize.X, tiles[i].Position.Top + halfSize.Y);
|
tiles[i].Position.Left + halfSize.X, tiles[i].Position.Top + halfSize.Y);
|
||||||
collisionTargets[i + 1] = new Aabb(center, halfSize);
|
CollisionTargets[i + 1] = new Aabb(center, halfSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a final synthetic collisionTarget on the right side of the world.
|
// Add a final synthetic collisionTarget on the right side of the world.
|
||||||
collisionTargets[tiles.Length + 1] = new Aabb(
|
CollisionTargets[tiles.Length + 1] = new Aabb(
|
||||||
new Vector2(Width + 1, 0), new Vector2(1, float.MaxValue));
|
new Vector2(Width + 1, 0), new Vector2(1, float.MaxValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,8 +186,6 @@ namespace SemiColinGames {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Aabb[] CollisionTargets {
|
public Aabb[] CollisionTargets { get; }
|
||||||
get { return collisionTargets; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user