Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/TerritoryDecay.js
function TerritoryDecay() {} | function TerritoryDecay() {} | ||||
TerritoryDecay.prototype.Schema = | TerritoryDecay.prototype.Schema = | ||||
"<element name='DecayRate' a:help='Decay rate in capture points per second'>" + | "<element name='DecayRate' a:help='Decay rate in capture points per second'>" + | ||||
"<choice><ref name='positiveDecimal'/><value>Infinity</value></choice>" + | "<choice><ref name='positiveDecimal'/><value>Infinity</value></choice>" + | ||||
"</element>"; | "</element>"; | ||||
TerritoryDecay.prototype.Init = function() | TerritoryDecay.prototype.Init = function() | ||||
{ | { | ||||
this.decaying = false; | this.decaying = false; | ||||
this.connectedNeighbours = new Array(Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetNumPlayers()).fill(0); | this.connectedNeighbours = new Uint32Array(Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetNumPlayers()); | ||||
lyv: CCmpTerritoryManager keeps it as u32 | |||||
lyvAuthorUnsubmitted Done Inline ActionsI wonder why I did this in the first place. lyv: I wonder why I did this in the first place. | |||||
this.territoryOwnership = !isFinite(+this.template.DecayRate); | this.territoryOwnership = !isFinite(+this.template.DecayRate); | ||||
}; | }; | ||||
TerritoryDecay.prototype.IsConnected = function() | TerritoryDecay.prototype.IsConnected = function() | ||||
{ | { | ||||
this.connectedNeighbours.fill(0); | this.connectedNeighbours.fill(0); | ||||
var cmpPosition = Engine.QueryInterface(this.entity, IID_Position); | var cmpPosition = Engine.QueryInterface(this.entity, IID_Position); | ||||
Show All 24 Lines | if (tileConnected) | ||||
return true; | return true; | ||||
if (cmpPlayer.GetPlayerID() != tileOwner) | if (cmpPlayer.GetPlayerID() != tileOwner) | ||||
{ | { | ||||
this.connectedNeighbours[0] = 1; | this.connectedNeighbours[0] = 1; | ||||
return false; | return false; | ||||
} | } | ||||
this.connectedNeighbours = cmpTerritoryManager.GetNeighbours(pos.x, pos.y, true); | this.connectedNeighbours = cmpTerritoryManager.GetNeighbours(pos.x, pos.y, true); | ||||
lyvAuthorUnsubmitted Not Done Inline ActionsNot sure how this returns the data, probably as an untyped array. lyv: Not sure how this returns the data, probably as an untyped array. | |||||
let numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetNumPlayers(); | let numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetNumPlayers(); | ||||
for (var i = 1; i < numPlayers; ++i) | for (var i = 1; i < numPlayers; ++i) | ||||
if (this.connectedNeighbours[i] > 0 && cmpPlayer.IsMutualAlly(i)) | if (this.connectedNeighbours[i] > 0 && cmpPlayer.IsMutualAlly(i)) | ||||
{ | { | ||||
// don't decay if connected to a connected ally; disable blinking | // don't decay if connected to a connected ally; disable blinking | ||||
cmpTerritoryManager.SetTerritoryBlinking(pos.x, pos.y, false); | cmpTerritoryManager.SetTerritoryBlinking(pos.x, pos.y, false); | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
CCmpTerritoryManager keeps it as u32