private void RelocateEntity(GridAction action) { Debug.Assert(action.Entity.Map != null); MapGrid newGrid = GetGrid(action.Position); MapGrid oldGrid = GetGrid(action.Entity.Position); if (newGrid.Vector != oldGrid.Vector) { oldGrid.RemoveEntity(action.Entity); newGrid.AddEntity(action); } else { oldGrid.RelocateEntity(action); } action.Entity.OnRelocate(action.Position); }
private void RelocateEntity(GridEntity entity, Vector3 vector) { Debug.Assert(entity.Map != null); ActivateGrid(entity, vector); MapGrid newGrid = GetGrid(vector); MapGrid oldGrid = GetGrid(entity.Position); if (newGrid.Coord.X != oldGrid.Coord.X || newGrid.Coord.Z != oldGrid.Coord.Z) { oldGrid.RemoveEntity(entity); newGrid.AddEntity(entity, vector); } else { oldGrid.RelocateEntity(entity, vector); } entity.OnRelocate(vector); }