174 | | var isOwn = (tileOwner == cmpPlayer.GetPlayerID()); |
175 | | var isNeutral = (tileOwner == 0); |
176 | | var isAlly = !isOwn && cmpPlayer.IsAlly(tileOwner); |
177 | | // We count neutral players as enemies, so you can't build in their territory. |
178 | | var isEnemy = !isNeutral && (cmpPlayer.IsEnemy(tileOwner) || cmpPlayer.IsNeutral(tileOwner)); |
| 174 | var isConnected = cmpTerritoryManager.IsConnected(pos.x, pos.y); |
| 175 | if (!isConnected) |
| 176 | { |
| 177 | // if the area itself isn't connected, check if it's connected to an ally |
| 178 | var neighbours = cmpTerritoryManager.GetNeighbours(pos.x, pos.y, true); |
| 179 | isConnected = neighbours.some((v, i) => v > 0 && cmpPlayer.IsMutualAlly(i)); |
| 180 | } |
182 | | if (isAlly && !this.HasTerritory("ally")) |
183 | | // Translation: territoryType being displayed in a translated sentence in the form: "House cannot be built in %(territoryType)s territory.". |
184 | | territoryType = markForTranslationWithContext("Territory type", "ally"); |
185 | | else if (isOwn && !this.HasTerritory("own")) |
186 | | // Translation: territoryType being displayed in a translated sentence in the form: "House cannot be built in %(territoryType)s territory.". |
187 | | territoryType = markForTranslationWithContext("Territory type", "own"); |
188 | | else if (isNeutral && !this.HasTerritory("neutral")) |
189 | | // Translation: territoryType being displayed in a translated sentence in the form: "House cannot be built in %(territoryType)s territory.". |
190 | | territoryType = markForTranslationWithContext("Territory type", "neutral"); |
191 | | else if (isEnemy && !this.HasTerritory("enemy")) |
192 | | // Translation: territoryType being displayed in a translated sentence in the form: "House cannot be built in %(territoryType)s territory.". |
193 | | territoryType = markForTranslationWithContext("Territory type", "enemy"); |
| 188 | if (isOwn) |
| 189 | { |
| 190 | if (!this.HasTerritory("own")) |
| 191 | { |
| 192 | territoryValid = false; |
| 193 | // Translation: territoryType being displayed in a translated sentence in the form: "House cannot be built in %(territoryType)s territory.". |
| 194 | territoryType = markForTranslationWithContext("Territory type", "own"); |
| 195 | } |
| 196 | else if (!isConnected) |
| 197 | { |
| 198 | territoryValid = false; |
| 199 | // Translation: territoryType being displayed in a translated sentence in the form: "House cannot be built in %(territoryType)s territory.". |
| 200 | territoryType = markForTranslationWithContext("Territory type", "unconnected"); |
| 201 | } |
| 202 | } |
| 203 | else if (isMutualAlly) |
| 204 | { |
| 205 | if (!this.HasTerritory("ally")) |
| 206 | { |
| 207 | territoryValid = false; |
| 208 | // Translation: territoryType being displayed in a translated sentence in the form: "House cannot be built in %(territoryType)s territory.". |
| 209 | territoryType = markForTranslationWithContext("Territory type", "allied"); |
| 210 | } |
| 211 | else if (!isConnected) |
| 212 | { |
| 213 | territoryValid = false; |
| 214 | // Translation: territoryType being displayed in a translated sentence in the form: "House cannot be built in %(territoryType)s territory.". |
| 215 | territoryType = markForTranslationWithContext("Territory type", "unconnected"); |
| 216 | } |
| 217 | } |
| 218 | else if (isNeutral) |
| 219 | { |
| 220 | if (!this.HasTerritory("neutral")) |
| 221 | { |
| 222 | territoryValid = false; |
| 223 | // Translation: territoryType being displayed in a translated sentence in the form: "House cannot be built in %(territoryType)s territory.". |
| 224 | territoryType = markForTranslationWithContext("Territory type", "neutral"); |
| 225 | } |
| 226 | } |