/// <inheritdoc /> public IUnit SpawnUnit(UnitType unitType, ITile tile, Quaternion initRotation, IPlayer player) { if (!unitType.CanSpawnAt(tile)) { return(null); } IUnit newUnit = null; try { newUnit = unitType.CreateNewUnit(GetNewID(entities), this, tile, initRotation, player); } catch (CreationException) { return(null); } //Could not spawn unit, user restrictions if (newUnit == null) { return(null); } RegisterEntity(newUnit); units.Add(newUnit.ID, newUnit); player.AddUnit(newUnit); tile.AddUnit(newUnit); return(newUnit); }