company_util¶
Source: base/tealdef/game_mechanics/company/company_util.d.tl
Notes
Permit counting, disable reasons and state access of the company.
CompanyUtil¶
record global base/tealdef/game_mechanics/company/company_util.d.tl:3
global record CompanyUtil
Load: local company_util = ug_require "/game_mechanics/company/company_util.tl"
Notes
Permit counting, disable reasons and state access of the company.
Fields
Functions
getActualPermitKey(constructionRes : ResName, metadata : ConstructionDescMetadata) : ResName base/tealdef/game_mechanics/company/company_util.d.tl:9
Call as company_util.getActualPermitKey
Notes
Returns the permit key of a construction. It is the permitKey, or the construction file if the metadata has rankAndPermits or companyRank.
| Parameter | Type | Description |
|---|---|---|
constructionRes |
ResName |
Construction file. |
metadata |
ConstructionDescMetadata |
Metadata of the construction resource. |
Returns ResName: Permit key, or nil if the construction needs no permit.
getMaximumNumberOfPermits(companyProgress : CompaniesGrowthState.CompanyData, actualPermitKey : ResName, metadata : ConstructionDescMetadata) : integer, boolean base/tealdef/game_mechanics/company/company_util.d.tl:10
Call as company_util.getMaximumNumberOfPermits
Notes
Returns how many permits of a key the company has, from the construction's rankAndPermits up to its rank plus the extra permits of the key.
| Parameter | Type | Description |
|---|---|---|
companyProgress |
CompaniesGrowthState.CompanyData |
Progression of the company. |
actualPermitKey |
ResName |
Permit key. |
metadata |
ConstructionDescMetadata |
Metadata of the construction resource. |
Returns integer, boolean: Number of permits, and true if the metadata mixes rankAndPermits with permitKey.
getNumberOfPermitsForRank(companyProgress : CompaniesGrowthState.CompanyData, metadata : ConstructionDescMetadata) : integer, boolean base/tealdef/game_mechanics/company/company_util.d.tl:11
Call as company_util.getNumberOfPermitsForRank
Notes
Returns the permits a construction gains at exactly the company's rank.
| Parameter | Type | Description |
|---|---|---|
companyProgress |
CompaniesGrowthState.CompanyData |
Progression (only level is read). |
metadata |
ConstructionDescMetadata |
Metadata of the construction resource. |
Returns integer, boolean: Number of permits, and the mixed-metadata warning flag.
getConstructionDisableCacheData(allDefs : {{ResName, ConstructionDescMetadata, string}}) : ConstructionDisableCacheData base/tealdef/game_mechanics/company/company_util.d.tl:36
Call as company_util.getConstructionDisableCacheData
Notes
Computes rank, permits, consumed permits, cooldowns and build counts of the player for a list of constructions.
| Parameter | Type | Description |
|---|---|---|
allDefs |
{{ResName, ConstructionDescMetadata, string}} |
List of {construction file, metadata, name}. |
Returns ConstructionDisableCacheData: Cache data.
getConstructionDisableReason(constructionRes : ResName, metadata : ConstructionDescMetadata, cache : ConstructionDisableCacheData) : ItemDisableReason base/tealdef/game_mechanics/company/company_util.d.tl:37
Call as company_util.getConstructionDisableReason
Notes
Tells why a construction cannot be built (rank, cooldown, no permits left).
| Parameter | Type | Description |
|---|---|---|
constructionRes |
ResName |
Construction file. |
metadata |
ConstructionDescMetadata |
Metadata of the construction resource. |
cache |
ConstructionDisableCacheData |
Result of getConstructionDisableCacheData. |
Returns ItemDisableReason: Reason with remaining permits, or nil if the construction has no company limits.
findStateIndex(CompaniesState, EntityUtil.EntityAndRevision) : integer base/tealdef/game_mechanics/company/company_util.d.tl:39
Call as company_util.findStateIndex
Notes
Finds the index of a company in the state.
| Parameter | Type | Description |
|---|---|---|
#1 |
CompaniesState |
Companies state. |
#2 |
EntityUtil.EntityAndRevision |
Company entity and revision. |
Returns integer: Index, or -1.
getCompanyState(CompaniesState, Engine.Entity) : CompanyState base/tealdef/game_mechanics/company/company_util.d.tl:40
Call as company_util.getCompanyState
Notes
Returns the state of a company, or a new empty one for a player without state.
| Parameter | Type | Description |
|---|---|---|
#1 |
CompaniesState |
Companies state. |
#2 |
Engine.Entity |
Player entity. |
Returns CompanyState: Company state, or nil if the entity is not a player.
setCompanyState(CompaniesState, Engine.Entity, CompanyState) : CompanyState base/tealdef/game_mechanics/company/company_util.d.tl:41
Call as company_util.setCompanyState
Notes
Stores the state of a company, adding it if missing.
| Parameter | Type | Description |
|---|---|---|
#1 |
CompaniesState |
Companies state. |
#2 |
Engine.Entity |
Player entity. |
#3 |
CompanyState |
Company state. |
Returns CompanyState
externalGetCompanyState(Engine.Entity) : CompanyState base/tealdef/game_mechanics/company/company_util.d.tl:42
Call as company_util.externalGetCompanyState
Notes
Reads the state of a company from the company game script.
| Parameter | Type | Description |
|---|---|---|
#1 |
Engine.Entity |
Player entity. |
Returns CompanyState: Company state.
Used in the base game: 3 times in 2 files
base/content/gui/gui/construction/construction_react_util.tl:1468
base/content/game_mechanics/game_mechanics/company/company_react_util.tl:211
externalGetCompaniesState() : CompaniesState base/tealdef/game_mechanics/company/company_util.d.tl:43
Call as company_util.externalGetCompaniesState
Notes
Reads the state of the company game script.
Returns CompaniesState: Companies state.
getNeededPermitsForProposal(Proposal, ProposalData) : {ResName : integer}, {ResName : ConstructionDescMetadata} base/tealdef/game_mechanics/company/company_util.d.tl:44
Call as company_util.getNeededPermitsForProposal
Notes
Counts the permits that the new constructions of a proposal need (replaced constructions excluded).
| Parameter | Type | Description |
|---|---|---|
#1 |
Proposal |
Proposal. |
#2 |
ProposalData |
Proposal data (unused). |
Returns {ResName : integer}, {ResName : ConstructionDescMetadata}: Permit key -> count, and permit key -> metadata.
countUsedConstructionPermits(permitKeys : {ResName : any}) : {ResName : integer} base/tealdef/game_mechanics/company/company_util.d.tl:45
Call as company_util.countUsedConstructionPermits
Notes
Counts the built constructions per permit key.
| Parameter | Type | Description |
|---|---|---|
permitKeys |
{ResName : any} |
Unused. |
Returns {ResName : integer}: Permit key -> number built.
getCompanyMetadataFromConstructionResource(constructionEntity : Engine.Entity) : CompanyMetadata.ConstructionDesc base/tealdef/game_mechanics/company/company_util.d.tl:47
Call as company_util.getCompanyMetadataFromConstructionResource
Notes
Returns the company metadata of a built construction's resource.
| Parameter | Type | Description |
|---|---|---|
constructionEntity |
Engine.Entity |
Construction entity. |
Returns CompanyMetadata.ConstructionDesc: Company metadata, or nil.
Used in the base game: 4 times in 3 files
base/content/landmarks/landmark_hud.script.tl:31
base/content/gui/gui/entity_window/entity_window_hud.tl:199
base/content/game_mechanics/game_mechanics/emission/pollution_cleanup_facility_hud.script.tl:39
getCurrentCompanyState() : CurrentCompanyState base/tealdef/game_mechanics/company/company_util.d.tl:54
Call as company_util.getCurrentCompanyState
Notes
Returns rank and experience of the player (zeros if unknown).
Returns CurrentCompanyState: Current company state.
getBasePopulation() : integer base/tealdef/game_mechanics/company/company_util.d.tl:55
Call as company_util.getBasePopulation
note: This will never change during play
Returns integer
Used in the base game: 4 times in 4 files
base/content/gui/gui/game_bar/game_bar.tl:392
base/content/game_mechanics/game_mechanics/company/company_react_util.tl:80
base/content/game_mechanics/game_mechanics/company/company_growth.script.tl:81
base/content/game_mechanics/game_mechanics/subventions/subventions.script.tl:247
computeWorldPopulation() : integer base/tealdef/game_mechanics/company/company_util.d.tl:56
Call as company_util.computeWorldPopulation
Notes
Sums the residential capacity of all towns.
Returns integer: World population.
isConstructionLandmark(constructionEntity : Engine.Entity) : boolean base/tealdef/game_mechanics/company/company_util.d.tl:58
Call as company_util.isConstructionLandmark
Notes
Tells whether a construction's company perk category is LANDMARK.
| Parameter | Type | Description |
|---|---|---|
constructionEntity |
Engine.Entity |
Construction entity. |
Returns boolean: true for landmarks.
CompanyUtil.ItemDisableReason¶
record base/tealdef/game_mechanics/company/company_util.d.tl:13
record ItemDisableReason
Notes
Why a construction cannot be built (or how many permits remain).
Used in the base game: 1 time in 1 file
base/content/game_mechanics/game_mechanics/company/company_util.tl:171
Fields
CompanyUtil.ConstructionDisableCacheData¶
record base/tealdef/game_mechanics/company/company_util.d.tl:19
record ConstructionDisableCacheData
Notes
Precomputed permit data for getConstructionDisableReason.
Used in the base game: 3 times in 1 file
base/content/game_mechanics/game_mechanics/company/company_util.tl:83
Fields
| Name | Type | Description |
|---|---|---|
companyRank |
integer |
Applied company rank. |
extraPermits |
{ResName : integer} |
Permit key -> extra permits by rank. |
maximumPermits |
{ResName : integer} |
contains extra permits |
consumedPermits |
{ResName : integer} |
Permit key -> permits consumed and still in cooldown. |
remainingPermitCooldown |
{ResName : CooldownState} |
Permit key -> cooldown of the oldest consumed permit. |
data |
{ResName : ItemDisableCacheData} |
Construction file or permit key -> build count. |
CompanyUtil.ConstructionDisableCacheData.CooldownState¶
record base/tealdef/game_mechanics/company/company_util.d.tl:20
record CooldownState
Notes
Cooldown of a permit key.
Fields
| Name | Type | Description |
|---|---|---|
remainingMs |
number |
Remaining cooldown in game time (ms). |
elapsedFraction |
number |
Elapsed part of the cooldown (0 to 1). |
CompanyUtil.ConstructionDisableCacheData.ItemDisableCacheData¶
record base/tealdef/game_mechanics/company/company_util.d.tl:31
record ItemDisableCacheData
Notes
Build count of a permit key.
Used in the base game: 1 time in 1 file
base/content/game_mechanics/game_mechanics/company/company_util.tl:144
Fields
| Name | Type | Description |
|---|---|---|
numBuilt |
integer |
Constructions built with this file or permit key. |
CompanyUtil.CurrentCompanyState¶
record base/tealdef/game_mechanics/company/company_util.d.tl:49
record CurrentCompanyState
Notes
Rank and experience of the player.
Used in the base game: 6 times in 2 files
base/content/game_mechanics/game_mechanics/company/company.tl:20
base/content/game_mechanics/game_mechanics/company/company_util.tl:373
Fields
| Name | Type | Description |
|---|---|---|
level |
integer |
Applied rank. |
potentialLevel |
integer |
Rank reached by experience. |
experience |
integer |
Experience points. |