Random offset for DefaultGrid every round (#4411)

* Random offset for DefaultGrid every round

This is useful to make coders aware of entitycoordinates and mapcoordinates being different and to help spot problems early. It also puts the onus of fixing positioning bugs back onto the original coder rather than someone else if they happen to spot it.

* Fix clickable test

* Fix entitysystemextensions
This commit is contained in:
metalgearsloth
2021-08-03 18:49:25 +10:00
committed by GitHub
parent 3d2f05e3e4
commit af05332b36
5 changed files with 31 additions and 9 deletions

View File

@@ -48,6 +48,8 @@ namespace Content.IntegrationTests.Tests.Utility
var mapId = new MapId(1);
var grid = sMapManager.GetGrid(new GridId(1));
grid.SetTile(new Vector2i(0, 0), new Tile(1));
var gridEnt = sEntityManager.GetEntity(grid.GridEntityId);
var gridPos = gridEnt.Transform.WorldPosition;
var entityCoordinates = new EntityCoordinates(grid.GridEntityId, 0, 0);
// Nothing blocking it, only entity is the grid
@@ -55,7 +57,7 @@ namespace Content.IntegrationTests.Tests.Utility
Assert.True(sEntityManager.TrySpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable, out var entity));
Assert.NotNull(entity);
var mapCoordinates = new MapCoordinates(0, 0, mapId);
var mapCoordinates = new MapCoordinates(gridPos.X, gridPos.Y, mapId);
// Nothing blocking it, only entity is the grid
Assert.NotNull(sEntityManager.SpawnIfUnobstructed(null, mapCoordinates, CollisionGroup.Impassable));