GameMap Class

Inherits: LuaObject

buildings

startPoint

sunDir

unemployedCount

workerPopupsCount

workers

abilityBow

abilityDance

abilityEmpty

abilityRespect

abilityTreePlanting

addBuilding

addConstructedBuilding

addLight

addNewResource

addResourceOutToFreeQueue

addSizebleBuilding

addTerramorphingArea

addWorkerPopup

attachLight

cameraAnimationTransform

canBuild

changeProfession

chooseResourceToCreate

clearPlace

createBuilding

createLoot

createLootInBuilding

createResourceOut

createRoad

createUserMap

createVikingShip

deleteBigResources

deleteRoad

deleteSmallResources

findAnimals

findBuildingsWithProfession

findBuildingsWithType

findBuildingsWithWorkState

findEnemyStranger

findFarWayPoint

findFood

findFreeStable

findMostDangerEnemy

findNavmeshRandomPoint

findNearestDangerEnemy

findNearestResource

findResourceSources

findWorkBuildings

findWorkerPopup

findWorkers

fishing

getAnimal

getBarnsList

getBuilding

getCellType

getClayAmount

getHolderTransportStorage

getHuman

getLiveObject

getLiveObjectByUID

getNearestBarnToDeposit

getNearestBarnWithRes

getNearestBuilding

getNearestTargetBuilding

getNearestWorkingBuilding

getObject

getOreAmount

getProfessionalCount

getRandomPosInRadius

getStoneAmount

getStorageByUID

getTechnologiesBonus

getTerrainHeight

getTerrainHeight0

getUserMap

getWorker

hasActiveQuests

hitTest

initFirstPersonWindow

isNearWater

isTechnologyLearned

loadPrefab

onActionProcess

onCreateLevel

onLiveObjectDie

rand

randReset

randSeed

recreateGameMenu

refreshProfessionalCounts

relocateChild

removeBrush

removeBuildingOnUpdate

removeLight

setBrushTransform

setLuaListeners

setTechnologyLearned

setTerrainHeight

sketchRoad

spawnAnimal

spawnHuman

unreserveHolderTransportStorage

update

updateGUI

updateSunDir

updateSunParams

updateTechnologiesBonuses

updateVillageResurces

updateWorkerPopups

Type: [[std::vectorgetAnimals_lua@<ILuaClass>_Class|std::vectorgetAnimals_lua@<ILuaClass>]]
[Read Only]

```

### .buildings

```
Type: [[std::vectorgetBuildings_lua@<ILuaClass>_Class|std::vectorgetBuildings_lua@<ILuaClass>]]
[Read Only]

```

### .startPoint

```
Type: Vector2
[Read Only]

Returns village start point

```

### .sunDir

```
Type: Vector2

Direction of sun light

```

### .unemployedCount

```
Type: number
[Read Only]

Count of unemployed workers

```

### .workerPopupsCount

```
Type: number
[Read Only]

```

### .workers

```
Type: [[std::vectorgetWorkers_lua@<ILuaClass>_Class|std::vectorgetWorkers_lua@<ILuaClass>]]
[Read Only]

```

## Functions

### abilityBawl()

```
function **abilityBawl**(w, pos, radius, a)

```

### abilityBow()

```
function **abilityBow**(w, pos, radius, a)

```

### abilityDance()

```
function **abilityDance**(w, pos, radius, a)

```

### abilityEmpty()

```
function **abilityEmpty**(w, pos, radius, a)

```

### abilityRespect()

```
function **abilityRespect**(w, pos, radius, a)

```

### abilityTreePlanting()

```
function **abilityTreePlanting**(w, pos, radius, a)

```

### addBuilding()

```
function **addBuilding**(name string, x number, z number, angle number) -> Building

Add new construction yard of building on map
name: name of building class
x, z: position of building on map
anlge: rotation angle of building (in radians)

```

### addConstructedBuilding()

```
function **addConstructedBuilding**(name string, x number, z number, angle number, width number, length number) -> Building

Add completly constructed builiding on map
name: name of building class
x, z: position of building on map
anlge: rotation angle of building (in radians)
width: width of building
length: length of bulding

```

### addLight()

```
function **addLight**(pos Vector2, radius number, color Vector2, deprecated number) -> UID

Add light on map
pos: position on map
radius: radius of light
color: color of light. Represented by 3-component vector (rgb-values encoded in xyz components corresponding)
deprecated: deprecated parameter. leave it 0

```

### addNewResource()

```
function **addNewResource**(pos Vector2, resName string, lifeTime number, angle number)

Add new growing resource on map
pos: position on map
resName: name of resource
lifeTime: life time of resource (optional)
angle: rotation angle of resource in radians (optional)

```

### addResourceOutToFreeQueue()

```
function **addResourceOutToFreeQueue**(pile ResourceOut)

Add resource pile to free transport queue

```

### addSizebleBuilding()

```
function **addSizebleBuilding**(name string, x1 number, z1 number, x2 number, z2 number, angleNum number) -> Building

Add new construction yard of sizable building on map
name: name of building class
x1, z1: position of start building corner
x2, z2: position of opposite building corner
angleNum: count of 90-degrees rotations of building (from 0 to 3)

```

### addTerramorphingArea()

```
function **addTerramorphingArea**(terramorphingType number, x number, z number, width number, length number, angleNum number, K number) -> Building

Add new terramorphing area on map
terramorphingType: one of TerramorphingType values
x: x-position of terramorphing area on map
z: z-position of terramorphing area on map
width: width of terramorphing area
length: length of terramorphing area
angleNum: count of 90-degrees rotations of building (from 0 to 3)
K: coefficient of terramorphing intensity

```

### addWorkerPopup()

```
function **addWorkerPopup**(text string, h Human, showTime number, width number, height number)

```

### attachLight()

```
function **attachLight**(lightUID UID, brushHandle BrushHandle, relativePosition Vector2) -> boolean

Attach light source to brush.
lightUID: uid of light source
brushHandle: handle of brush
relativePosition: relative position at brush
returns ture if succeeded @

```

### cameraAnimationTransform()

```
function **cameraAnimationTransform**(pos, time)

```

### canBuild()

```
function **canBuild**(buildingClass string, x number, z number, angleNum number, width number, length number) -> boolean

Check if building can be built at given position
buildingClass: class (name) of building to build
x, z: position on map
angleNum: count of 90-degrees rotations of building (from 0 to 3)
width: width of building
length: length of building

```

### changeProfession()

```
function **changeProfession**(profession string, count number, building Building) -> boolean

Change number of employers of given profession. Changing this value cause workers redistribution between buildings.
profession: name of profession to change
count: new employer count of this profession
building: priority building if set

```

### chooseResourceToCreate()

```
function **chooseResourceToCreate**(pos Vector2, filter number) -> string

Returns name of resource prefered to create at given point
pos: map position
filter: combination of allowed resource classes (sum of ResourceClasses values)

```

### clearPlace()

```
function **clearPlace**(bldArea BuildingArea)

Delete all big and small resources at building area

```

### createBuilding()

```
function **createBuilding**(buildingName string, x number, z number, angle number, width number, length number, terramorphingData [[std::vector<TerramorphingCell>\_Class|std::vector<TerramorphingCell>]], buildingID UID, loadNode pugi::xml\_node, ver number) -> Building

Create new construction yard of building on map
buildingName: name of building class
x, z: position of building on map
angle: rotation angle of building in radians (optional)
width: width for sizable buildings (optional)
length: length for sizable buildings (optional)

```

### createLoot()

```
function **createLoot**(pos Vector2, animalName string, lootMultiplier number, hunterUid UID, buildingHolderUID UID)

Create loot pile from animal on map
pos: map position to place loot
animalName: name of animal which config used for loot settings
lootMultiplier: multiplier for loot amount
hunterUid: uid of animal hunter
buildingHolderUID: uid of building that used as holder to loot pile

```

### createLootInBuilding()

```
function **createLootInBuilding**(animalName string, lootMultiplier number, buildingUid UID)

Create loot from animal in building
animalName: name of animal which config used for loot settings
lootMultiplier: multiplier for loot amount
buildingUid: uid of building to place loot in

```

### createResourceOut()

```
function **createResourceOut**(pos Vector2, resName string, count number, holderUid UID)

Create new resource pile on map
pos: position at map
resName: name of resource in pile
count: amount of resource in pile
holderUid: uid of holder object

```

### createRoad()

```
function **createRoad**(roadName string, x1 number, z1 number, x2 number, z2 number)

Create road on map
type: name of road class
x1, z1: position of start point
x2, z2: position of end point

```

### createUserMap()

```
function **createUserMap**(name string) -> Array2DUint8

```

### createVikingShip()

```
function **createVikingShip**(startPos, landingPos, vikingCount)

```

### deleteBigResources()

```
function **deleteBigResources**(bldArea BuildingArea)

Delete all big resources at building area

```

### deleteRoad()

```
function **deleteRoad**(x number, z number)

Delete road from map at given point

```

### deleteSmallResources()

```
function **deleteSmallResources**(bldArea BuildingArea)

Delete all small resources at building area

```

### findAnimals()

```
function **findAnimals**(pos Vector2, radius number, ignore LiveObject) -> [[std::vector<ILuaClass>_Class|std::vector<ILuaClass>]]

Returns table of animals which are located nerby to given live object
pos: position that used as center point of search
radius: radius of search
obj: ignore live object

```

### findBuildingsWithProfession()

```
function **findBuildingsWithProfession**(pos Vector2, radius number, type string) -> [[std::vector<ILuaClass>_Class|std::vector<ILuaClass>]]

Returns table of buildings with given worker's profession
pos: position at map that used as center point of search
radius: raduis of search
state: name of required worker's profession

```

### findBuildingsWithType()

```
function **findBuildingsWithType**(pos Vector2, radius number, type BuildingType) -> [[std::vector<ILuaClass>_Class|std::vector<ILuaClass>]]

Returns table of buildings with given building type
pos: position at map that used as center point of search
radius: raduis of search
state: required building type of building. One of BuildingType values

```

### findBuildingsWithWorkState()

```
function **findBuildingsWithWorkState**(pos Vector2, radius number, state number) -> [[std::vector<ILuaClass>_Class|std::vector<ILuaClass>]]

Returns table of buildings with given work status
pos: position at map that used as center point of search
radius: raduis of search
state: required working status of building. One of BuildingStatus values

```

### findEnemyStranger()

```
function **findEnemyStranger**(h Human, searchPosition Vector2, radius number) -> Human

Returns nearest enemy stranger in the given radius
human: human which can reach enemy stranger
searchPosition: search center point
radius: radius of search

```

### findFarWayPoint()

```
function **findFarWayPoint**(objectPos Vector2, dangerPos Vector2, radius number) -> Vector2

Returns prefered position to flee from danger
objectPos: world position of live object
dangerPos: map position of danger
radius: search radius

```

### findFood()

```
function **findFood**(human Human, radius number) -> Building

Returns nearest food building to given human.
Food building is building that has STORAGE_RESOURCE storage class.
See Building:getStorageClass() for more info.
Return nil if there are no such buildings.

human: human that used as center point of search
radius: radius of search

```

### findFreeStable()

```
function **findFreeStable**() -> Building

Returns free stable of nil on fails

```

### findMostDangerEnemy()

```
function **findMostDangerEnemy**(h Human, pos Vector2, radius number) -> LiveObject

Returns nearest danger enemy which doesn't reserved by another workers
human: human which can reach animal position
pos: position on map that used as search starting point
radius: radius of search

```

### findNavmeshRandomPoint()

```
function **findNavmeshRandomPoint**(pos Vector2, radius number, flags number) -> Vector2

Returns random world position reachable by navigation system at given zone
pos: position at map that used as center of zone
redius: radius of zone
flags: combination of allowed cell types (sum of CellType values)

```

### findNearestDangerEnemy()

```
function **findNearestDangerEnemy**(pos Vector2, fRadius number) -> LiveObject

Returns nearest danger enemy
pos: position on map that used as search starting point
radius: radius of search

```

### findNearestResource()

```
function **findNearestResource**(human Human, resClass number, radius number, preferOlder boolean) -> GameResourceSource

Returns nearest reachable resource source to given worker
human: human which used as search starting point
resClass: required resorce class,
radius: radius of search,
preferOlder: if set return oldest reachable source in search area instead of nearest

```

### findResourceSources()

```
function **findResourceSources**(pos Vector2, human Human, resClass number, radius number) -> [[std::vector<ILuaClass>_Class|std::vector<ILuaClass>]]

Returns table of resource sources that are located nerby to given position and satisfy various requirement
pos: position at map that used as center point of search
human: human that can reach that resource
resClass: required resorce class
radius: radius of search

```

### findWorkBuildings()

```
function **findWorkBuildings**(pos Vector2, radius number) -> [[std::vector<ILuaClass>_Class|std::vector<ILuaClass>]]

Returns table of buildings with working type category
Working type category include following BuildingType values:
  Work, Apiary, Pasture, FixedPasture, Planting,
  Stable, Harbor, HarborShip, HarborExpedition

pos: position at map that used as center point of search
radius: raduis of search

```

### findWorkerPopup()

```
function **findWorkerPopup**(objectUID UID) -> boolean

```

### findWorkers()

```
function **findWorkers**(pos Vector2, radius number, ignore LiveObject) -> [[std::vector<ILuaClass>_Class|std::vector<ILuaClass>]]

Returns table of workers which are located nerby to given live object
pos: position that used as center point of search
radius: radius of search
obj: ignore live object

```

### fishing()

```
function **fishing**(pos Vector2) -> boolean

```

### getAnimal()

```
function **getAnimal**(uid UID) -> Animal

Returns animal by its uid or nil if fails

```

### getBarnsList()

```
function **getBarnsList**(uid UID) -> BarnsList

```

### getBuilding()

```
function **getBuilding**(uid UID) -> Building

Returns building by its uid or nil if fails

```

### getCellType()

```
function **getCellType**(x number, y number) -> number

Get cell type by given position on map
Return one ov CellType values

```

### getClayAmount()

```
function **getClayAmount**(x number, z number) -> number

Clay amount at the given position on map

```

### getHolderTransportStorage()

```
function **getHolderTransportStorage**(holderUid UID) -> ResourceOut

Returns resource pile by holder uid

```

### getHuman()

```
function **getHuman**(uid UID) -> Human

Returns human by its uid or nil if fails

```

### getLiveObject()

```
function **getLiveObject**(uid UID) -> LiveObject

Returns liveobject by its uid or nil if fails

```

### getLiveObjectByUID()

```
function **getLiveObjectByUID**(liveObjectUID UID) -> LiveObject

Returns living object by its uid or nil on fails

```

### getNearestBarnToDeposit()

```
function **getNearestBarnToDeposit**(human Human, pos Vector2, resName string, count number, checkVisitors boolean, ignore Building) -> Building

Returns nearest barn to given position that satisfies various requirement
human: human that can reach that barn
pos: position at map that used as center point of search
resName: name of resource that can be put to barn
amount: amount of resource that can be put to barn
checkVisitors: if set search excludes building with maximum count of visitors
ignore: building that will be ignore at search

```

### getNearestBarnWithRes()

```
function **getNearestBarnWithRes**(human Human, pos Vector2, resName string, checkVisitors boolean, deprecated boolean, radius number) -> Building

Returns nearest barn to given position that satisfies various requirement
human: human that can reach that barn
pos: position at map that used as center point of search
resName: name of resource that can be retrieved from barn
checkVisitors: if set search excludes building with maximum count of visitors
deprecated: deprecated parameter. leave it false
radius: radius of search

```

### getNearestBuilding()

```
function **getNearestBuilding**(human Human, pos Vector2) -> Building

```

### getNearestTargetBuilding()

```
function **getNearestTargetBuilding**(human Human, pos Vector2) -> Building

```

### getNearestWorkingBuilding()

```
function **getNearestWorkingBuilding**(human Human, pos Vector2) -> Building

```

### getObject()

```
function **getObject**(uid)

```

### getOreAmount()

```
function **getOreAmount**(x number, z number) -> number

Ore amount at the given position on map

```

### getProfessionalCount()

```
function **getProfessionalCount**(profession string) -> number

Count of employers of given profession

```

### getRandomPosInRadius()

```
function **getRandomPosInRadius**(pos Vector2, radius number) -> Vector2

Returns random position in given zone
pos: center position of zone
radius: radius of zone

```

### getStoneAmount()

```
function **getStoneAmount**(x number, z number) -> number

Stone amount at the given position on map

```

### getStorageByUID()

```
function **getStorageByUID**(inventoryUID UID) -> ResourceStorage

Returns resource storage (building, pile, etc) by its uid or nil on fails

```

### getTechnologiesBonus()

```
function **getTechnologiesBonus**(num number) -> number

```

### getTerrainHeight()

```
function **getTerrainHeight**(x number, z number) -> number

Returns terrain height at given position on map

```

### getTerrainHeight0()

```
function **getTerrainHeight0**(x number, z number) -> number

Returns terrain height at given position on map rounded up to 1-meters grid

```

### getUserMap()

```
function **getUserMap**(name string) -> Array2DUint8

```

### getWorker()

```
function **getWorker**(uid UID) -> Human

Returns citizen by its uid or nil if fails

```

### hasActiveQuests()

```
function **hasActiveQuests**()

```

### hitTest()

```
function **hitTest**(from Vector2, to Vector2, testLiveObjects boolean, testBuildings boolean) -> Hit

```

### initFirstPersonWindow()

```
function **initFirstPersonWindow**(w, win)

```

### isNearWater()

```
function **isNearWater**(pos Vector2, radius number) -> boolean

Check if there are water nearby
pos: center of search area
radius: radius of search area

```

### isTechnologyLearned()

```
function **isTechnologyLearned**(name string) -> boolean

```

### loadPrefab()

```
function **loadPrefab**(path string, pos Vector2, randomRotate boolean, angle number, scale number) -> BrushHandle

Create prefab on map
path: path to prefab file,
pos: world position to place prefab
randomRotate: if true random rotation enabled (optional)
angle: rotation angle of prefab in radians (optional)
scale: scale of prefab (optional)

```

### onActionProcess()

```
function **onActionProcess**(actionType)

```

### onCreateLevel()

```
function **onCreateLevel**(levelNew)

```

### onLiveObjectDie()

```
function **onLiveObjectDie**(obj)

```

### rand()

```
function **rand**(min number, max number) -> number

Returns random number from [min; max] range inclusive (use map internal random generator)

```

### randReset()

```
function **randReset**()

Reset map internal random generator and set seed to its generation code

```

### randSeed()

```
function **randSeed**(reandSeed number)

Set new seed for map internal random generator

```

### recreateGameMenu()

```
function **recreateGameMenu**()

```

### refreshProfessionalCounts()

```
function **refreshProfessionalCounts**()

Recalculate count of employers of all professions

```

### relocateChild()

```
function **relocateChild**(child Human, ignoredBuilding Building) -> boolean

Relocates a child to new home if posible
child: child to relocate
ignoredBuilding: building that will be excluded from home search. For instance, current home (optional)
returns true if successed

```

### removeBrush()

```
function **removeBrush**(brushHandle BrushHandle)

Delete prefab from map by brush handle

```

### removeBuildingOnUpdate()

```
function **removeBuildingOnUpdate**(bld Building)

Remove building from map on next frame

```

### removeLight()

```
function **removeLight**(uid UID)

Remove light from map by its uid

```

### setBrushTransform()

```
function **setBrushTransform**(brushHandle BrushHandle, matrix glm::mat4)

```

### setLuaListeners()

```
function **setLuaListeners**(eventType number, state boolean)

Enable or disable lua listeners of given event type
eventType: one of EVENT\_TYPE values
state: enabling state of listeners

```

### setTechnologyLearned()

```
function **setTechnologyLearned**(name string)

```

### setTerrainHeight()

```
function **setTerrainHeight**(x number, z number, height number)

Set terrain at given position on map
x: x-coordinate of map
z: z-coordinate of map
height: new height value at given position

```

### sketchRoad()

```
function **sketchRoad**(x1 number, z1 number, x2 number, z2 number) -> [[std::vector<D3DXVECTOR2>_Class|std::vector<D3DXVECTOR2>]]

Returns table of 2D-positions of cells on map that represent road from one point to another
x1, z1: position of start point
x2, z2: position of end point

```

### spawnAnimal()

```
function **spawnAnimal**(type string, pos Vector2, age number) -> Animal

Spawn and return new animal on map
type: lua class of spawned animal
pos: 3D world position to spawn on
age: age of animal

```

### spawnHuman()

```
function **spawnHuman**(type string, pos Vector2, isMale boolean, age number) -> Human

Spawn and return new human on map
type: lua class of spawned human
pos: 3D world position to spawn on
isMale: sex of worker (true = male, false = female)
age: age of worker

```

### unreserveHolderTransportStorage()

```
function **unreserveHolderTransportStorage**(holderUid UID)

Unreserve transport storage by holder uid

```

### update()

```
function **update**(dt)

```

### updateGUI()

```
function **updateGUI**(dt)

```

### updateSunDir()

```
function **updateSunDir**()

```

### updateSunParams()

```
function **updateSunParams**()

```

### updateTechnologiesBonuses()

```
function **updateTechnologiesBonuses**()

```

### updateVillageResurces()

```
function **updateVillageResurces**()

```

### updateWorkerPopups()

```
function **updateWorkerPopups**()

```