Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/UnitAI.js
Show First 20 Lines • Show All 4,051 Lines • ▼ Show 20 Lines | for (let order of this.orderQueue) | |||||||||||||||||||
if (order.data) | if (order.data) | |||||||||||||||||||
orders.push(clone(order.data)); | orders.push(clone(order.data)); | |||||||||||||||||||
return orders; | return orders; | |||||||||||||||||||
}; | }; | |||||||||||||||||||
UnitAI.prototype.UpdateWorkOrders = function(type) | UnitAI.prototype.UpdateWorkOrders = function(type) | |||||||||||||||||||
{ | { | |||||||||||||||||||
var isWorkType = type => type == "Gather" || type == "Trade" || type == "Repair" || type == "ReturnResource"; | const isWorkType = t => t == "Gather" || t == "Trade" || t == "Repair" || t == "ReturnResource"; | |||||||||||||||||||
Freagarach: Do notice this is a small change in behaviour. Entities tasked to return resources no longer… | ||||||||||||||||||||
Done Inline ActionsI didn't say it was bad, especially since now one can't order your units back to work after such an attack. Perhaps more people are opinionated about this. Freagarach: I didn't say it was bad, especially since now one can't order your units back to work after… | ||||||||||||||||||||
if (isWorkType(type)) | if (isWorkType(type)) | |||||||||||||||||||
{ | { | |||||||||||||||||||
this.workOrders = []; | this.workOrders = []; | |||||||||||||||||||
return; | return; | |||||||||||||||||||
} | } | |||||||||||||||||||
if (this.workOrders.length) | if (this.workOrders.length) | |||||||||||||||||||
return; | return; | |||||||||||||||||||
▲ Show 20 Lines • Show All 1,297 Lines • ▼ Show 20 Lines | ||||||||||||||||||||
* Adds stop order to queue, forced by the player. | * Adds stop order to queue, forced by the player. | |||||||||||||||||||
*/ | */ | |||||||||||||||||||
UnitAI.prototype.Stop = function(queued, pushFront) | UnitAI.prototype.Stop = function(queued, pushFront) | |||||||||||||||||||
{ | { | |||||||||||||||||||
this.AddOrder("Stop", { "force": true }, queued, pushFront); | this.AddOrder("Stop", { "force": true }, queued, pushFront); | |||||||||||||||||||
}; | }; | |||||||||||||||||||
/** | /** | |||||||||||||||||||
* The unit will drop all resources at the closest dropsite. If this unit is no gatherer or | ||||||||||||||||||||
Done Inline Actions
Freagarach: | ||||||||||||||||||||
* no dropsite is available, it will do nothing. | ||||||||||||||||||||
* | ||||||||||||||||||||
* @return {boolean} Whether this unit could drop resources. | ||||||||||||||||||||
*/ | ||||||||||||||||||||
UnitAI.prototype.DropAtNearestDropSite = function(queued, pushFront) | ||||||||||||||||||||
Done Inline Actions
Freagarach: | ||||||||||||||||||||
{ | ||||||||||||||||||||
const cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer); | ||||||||||||||||||||
if (!cmpResourceGatherer) | ||||||||||||||||||||
Done Inline Actions
Freagarach: | ||||||||||||||||||||
return false; | ||||||||||||||||||||
const nearby = this.FindNearestDropsite(cmpResourceGatherer.GetMainCarryingType()); | ||||||||||||||||||||
Done Inline Actions
You can early return when no resource gatherer. Freagarach: You can early return when no resource gatherer. | ||||||||||||||||||||
if (!nearby) | ||||||||||||||||||||
return false; | ||||||||||||||||||||
this.ReturnResource(nearby, queued, pushFront); | ||||||||||||||||||||
return true; | ||||||||||||||||||||
Done Inline Actions
Freagarach: | ||||||||||||||||||||
}; | ||||||||||||||||||||
Done Inline Actions
(Same about early return.) Freagarach: (Same about early return.) | ||||||||||||||||||||
/** | ||||||||||||||||||||
* Adds walk-to-target order to queue, this only occurs in response | * Adds walk-to-target order to queue, this only occurs in response | |||||||||||||||||||
* to a player order, and so is forced. | * to a player order, and so is forced. | |||||||||||||||||||
*/ | */ | |||||||||||||||||||
UnitAI.prototype.WalkToTarget = function(target, queued, pushFront) | UnitAI.prototype.WalkToTarget = function(target, queued, pushFront) | |||||||||||||||||||
{ | { | |||||||||||||||||||
this.AddOrder("WalkToTarget", { "target": target, "force": true }, queued, pushFront); | this.AddOrder("WalkToTarget", { "target": target, "force": true }, queued, pushFront); | |||||||||||||||||||
}; | }; | |||||||||||||||||||
▲ Show 20 Lines • Show All 1,064 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Do notice this is a small change in behaviour. Entities tasked to return resources no longer clear the workOrders. I think that means one cannot get rid of that pesky command button easily anymore?