Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/AIProxy.js
Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | AIProxy.prototype.OnGarrisonedUnitsChanged = function(msg) | ||||
// Send a message telling a unit garrisoned or ungarrisoned. | // Send a message telling a unit garrisoned or ungarrisoned. | ||||
// I won't check if the unit is still alive so it'll be up to the AI. | // I won't check if the unit is still alive so it'll be up to the AI. | ||||
for (let ent of msg.added) | for (let ent of msg.added) | ||||
this.cmpAIInterface.PushEvent("Garrison", { "entity": ent, "holder": this.entity }); | this.cmpAIInterface.PushEvent("Garrison", { "entity": ent, "holder": this.entity }); | ||||
for (let ent of msg.removed) | for (let ent of msg.removed) | ||||
this.cmpAIInterface.PushEvent("UnGarrison", { "entity": ent, "holder": this.entity }); | this.cmpAIInterface.PushEvent("UnGarrison", { "entity": ent, "holder": this.entity }); | ||||
}; | }; | ||||
AIProxy.prototype.OnResourceSupplyChanged = function(msg) | |||||
{ | |||||
if (!this.NotifyChange()) | |||||
return; | |||||
this.changes.resourceSupplyAmount = msg.to; | |||||
}; | |||||
AIProxy.prototype.OnResourceSupplyNumGatherersChanged = function(msg) | |||||
{ | |||||
if (!this.NotifyChange()) | |||||
return; | |||||
this.changes.resourceSupplyNumGatherers = msg.to; | |||||
}; | |||||
AIProxy.prototype.OnResourceCarryingChanged = function(msg) | |||||
{ | |||||
if (!this.NotifyChange()) | |||||
return; | |||||
this.changes.resourceCarrying = msg.to; | |||||
}; | |||||
AIProxy.prototype.OnFoundationProgressChanged = function(msg) | AIProxy.prototype.OnFoundationProgressChanged = function(msg) | ||||
{ | { | ||||
if (!this.NotifyChange()) | if (!this.NotifyChange()) | ||||
return; | return; | ||||
this.changes.foundationProgress = msg.to; | this.changes.foundationProgress = msg.to; | ||||
}; | }; | ||||
AIProxy.prototype.OnFoundationBuildersChanged = function(msg) | AIProxy.prototype.OnFoundationBuildersChanged = function(msg) | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | AIProxy.prototype.GetFullRepresentation = function() | ||||
let cmpFoundation = Engine.QueryInterface(this.entity, IID_Foundation); | let cmpFoundation = Engine.QueryInterface(this.entity, IID_Foundation); | ||||
if (cmpFoundation) | if (cmpFoundation) | ||||
{ | { | ||||
// Updated by OnFoundationProgressChanged | // Updated by OnFoundationProgressChanged | ||||
ret.foundationProgress = cmpFoundation.GetBuildPercentage(); | ret.foundationProgress = cmpFoundation.GetBuildPercentage(); | ||||
} | } | ||||
let cmpResourceSupply = Engine.QueryInterface(this.entity, IID_ResourceSupply); | |||||
if (cmpResourceSupply) | |||||
{ | |||||
// Updated by OnResourceSupplyChanged | |||||
ret.resourceSupplyAmount = cmpResourceSupply.GetCurrentAmount(); | |||||
ret.resourceSupplyNumGatherers = cmpResourceSupply.GetNumGatherers(); | |||||
} | |||||
let cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer); | |||||
if (cmpResourceGatherer) | |||||
{ | |||||
// Updated by OnResourceCarryingChanged | |||||
ret.resourceCarrying = cmpResourceGatherer.GetCarryingStatus(); | |||||
} | |||||
let cmpResourceDropsite = Engine.QueryInterface(this.entity, IID_ResourceDropsite); | let cmpResourceDropsite = Engine.QueryInterface(this.entity, IID_ResourceDropsite); | ||||
if (cmpResourceDropsite) | if (cmpResourceDropsite) | ||||
{ | { | ||||
// Updated by OnDropsiteSharingChanged | // Updated by OnDropsiteSharingChanged | ||||
ret.sharedDropsite = cmpResourceDropsite.IsShared(); | ret.sharedDropsite = cmpResourceDropsite.IsShared(); | ||||
} | } | ||||
let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); | let cmpGarrisonHolder = Engine.QueryInterface(this.entity, IID_GarrisonHolder); | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator