protected override void OnPaintTile(Vector2Int tileXY) { UnitData structure = GetStructureData(); structure.position = new LOCATION(tileXY.x + 1, tileXY.y + 1); // Add game coordinates RectInt structureArea = StructureData.GetStructureArea(tileXY, structure.typeID); RectInt bulldozedArea = structureArea; bulldozedArea.min -= Vector2Int.one; bulldozedArea.max += Vector2Int.one; // Check if area is not buildable if (!TileMapData.IsAreaPassable(bulldozedArea)) { return; } // Check if area is blocked by units or structures if (AreUnitsInArea(structureArea)) { return; } // Check if area is blocked by walls if (AreWallsInArea(structureArea)) { return; } // Add structure to tile PlayerData player = UserData.current.selectedVariant.players[m_DropdownPlayer.value]; UserData.current.GetPlayerResourceData(player.id).units.Add(structure); UserData.current.SetUnsaved(); m_UnitRenderer.AddUnit(player, structure); m_MapRenderer.RefreshTiles(bulldozedArea); }