Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/ai/petra/queue.js
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | |||||
PETRA.Queue.prototype.Deserialize = function(gameState, data) | PETRA.Queue.prototype.Deserialize = function(gameState, data) | ||||
{ | { | ||||
this.paused = data.paused; | this.paused = data.paused; | ||||
this.switched = data.switched; | this.switched = data.switched; | ||||
this.plans = []; | this.plans = []; | ||||
for (let dataPlan of data.plans) | for (let dataPlan of data.plans) | ||||
{ | { | ||||
let plan; | let plan; | ||||
if (dataPlan.category == "unit") | if (dataPlan.category == "unit") | ||||
plan = new PETRA.TrainingPlan(gameState, dataPlan.type); | plan = new PETRA.TrainingPlan(gameState, dataPlan.type); | ||||
else if (dataPlan.category == "building") | else if (dataPlan.category == "building") | ||||
plan = new PETRA.ConstructionPlan(gameState, dataPlan.type); | plan = new PETRA.ConstructionPlan(gameState, dataPlan.type); | ||||
else if (dataPlan.category == "technology") | else if (dataPlan.category == "technology") | ||||
plan = new PETRA.ResearchPlan(gameState, dataPlan.type); | plan = new PETRA.ResearchPlan(gameState, dataPlan.type); | ||||
else if (dataPlan.category == "upgrading") | |||||
plan = new PETRA.UpgradePlan(gameState, dataPlan.entityID, dataPlan.upgradeData); | |||||
else | else | ||||
Stan: Would be nice to have enums for those at some point. I suppose for everything but the last one… | |||||
Done Inline ActionsCould have some reflection attribute as well. Also I just noticed that this is somewhat inconsistent with all other plans now :) lyv: Could have some reflection attribute as well.
Also I just noticed that this is somewhat… | |||||
{ | { | ||||
API3.warn("Petra deserialization error: plan unknown " + uneval(dataPlan)); | API3.warn("Petra deserialization error: plan unknown " + uneval(dataPlan)); | ||||
continue; | continue; | ||||
} | } | ||||
plan.Deserialize(gameState, dataPlan); | plan.Deserialize(gameState, dataPlan); | ||||
this.plans.push(plan); | this.plans.push(plan); | ||||
} | } | ||||
}; | }; |
Wildfire Games · Phabricator
Would be nice to have enums for those at some point. I suppose for everything but the last one it could be