Territory

Territories are one of the key components of Mega-Risk. They are the various pieces of land that the players fight over using armies.

## Detailed Description and Abilities

Territories are added to the map manually by map makers. They use a Reference Mesh (which will have already been placed in the level) to determine their shape and location.

Territories can hold a number of garrison troops, which are used to defend against attacking armies as well as spawning new armies.

Territories belong to teams, although they frequently change hands. They also belong to a Continent and are used to determine whether or not that continent has been conquered.

### Full Abilities List

* Used during Main Gameplay
* Holds Garrison troops
* Spawns armies
* Hosts armies
* Belongs to a team
* Belongs to a continent
* Changes teams
* Is attacked by armies
* Has adjacent territories

## Code Documentation

### Properties and Variables

* int32 **garrisonTroops:** the number of troops in the territory's garrison. UProperty
* int32 **~~terrTeamNum~~:** the id of the territory's Team. DEPRECATED as teams no longer use ids. Replaced by 'team'. UProperty
* bool **isPort:** determines if the territory has an adjacent across the sea. Used for Sea Lines. UProperty
* bool **isWraparound:** determines if the territory has an adjacent on the other side of the world. Used for Sea Lines. UProperty
* bool **isFort:** determines if the territory holds a Fortress. UProperty
* FName **name:** the territory's name. UProperty
* FName **continentName:** the name of the territory's continent. May be unnecessary depending on how continents are made. UProperty
* AController\* **~~ownerController~~:** pointer to the owning controller of the territory. May be unnecessary depending on how Teams are made. DEPRECATED because there is already a variable('controller') for this. UProperty
* TArray<ATerritory\*> **adjacents:** array of adjacent territories. UProperty
* TArray<AArmy\*> **armyArray:** array of all armies hosted in territory. UProperty
* FLinearColor **baseColor:** the color that the territory will always revert back to if the color is temporarily changed for any other reason (E.G. moused over or selected). UProperty
* FLinearColor **color:** the color that the territory currently is. May not always be equal to 'baseColor'. UProperty
* AStaticMeshActor\* **refMesh:** pointer to a mesh that has been placed in the world. Used to determine shape and location of territory. UProperty
* UTeamObj\* **team:** the territory's Team-Object. UProperty
* UMaterialInterface\* **baseMaterial:** pointer to the territory's material. UProperty
* UGameInstance\* **gameInstance:** pointer to the current Game Instance
* AGameState\* **gameState:** pointer to the current Game State
* AGameMode\* **gameMode:** pointer to the current Game Mode
* AController\* **controller:** pointer to the Player/AI Controller that owns the territory
* UStaticMeshComponent\* **terrMeshComponent:** the territory's mesh/shape. Currently not working. UProperty
* UTextRenderComponent\* **troopTextComponent:** the territory's troop number, displayed above the territory. Currently not working. UProperty

### Functions

* void **Invasion**(AArmy\* attacker, int32 withdrawTroops, bool isGeneral, bool isMarshal): Runs an invasion of the territory by an army.
	+ attacker: pointer to the attacking army
	+ withdrawTroops: if the army's troop count reaches this number, the invasion ends
	+ isGeneral: whether or not a general is affecting the attacking army
	+ isMarshal: whether or not a marshal is affecting the defending territory
* void **DisplayTroops**(): used to update 'troopTextComponent'. NOT YET IMPLEMENTED. UFunction
* void **UpdateTroops**(): used to..idk. IDK. UFunction
* void **ChangeOwner**(UPARAM(ref) UTeamObj\* &newOwner): transfers the territory to a different team. UFunction
	+ newOwner: pointer to the territory's new team-object
* AArmy\* **spawnArmy**(int32 troopNum): spawns an Army belonging to the territory's team on the territory, taking from the garrison troops. UFunction
	+ troopNum: the number of troops that will be transferred from the territory to the new army
	+ Returns the newly-created army.
* void **ChangeColor\_code**(FLinearColor inColor, FLinearColor &oldColor): changes the color of the territory. NOT YET IMPLEMENTED. UFunction
	+ inColor: the color that the territory will change to
	+ oldColor: the color that the territory used to be. Output