hm
This commit is contained in:
parent
7455d630fc
commit
4d3fc2cd47
84 changed files with 3429 additions and 3480 deletions
|
|
@ -11,23 +11,14 @@
|
|||
"TarinaiItemGrowthLifecycleStep",
|
||||
]);
|
||||
|
||||
let cachedSteps = null;
|
||||
function concreteSteps() {
|
||||
if (!cachedSteps) cachedSteps = CONCRETE_STEP_NAMES.map(name => global[name]);
|
||||
return cachedSteps;
|
||||
}
|
||||
|
||||
const runner = global.TarinaiUpdateStepPipelineRunner.create(
|
||||
CONCRETE_STEP_NAMES,
|
||||
(step, item, dt, worldRef, context) => step.update(item, dt, worldRef, context)
|
||||
);
|
||||
|
||||
function updateOne(item, dt, worldRef, options = {}) {
|
||||
if (!item || item.dead) return false;
|
||||
const steps = concreteSteps();
|
||||
if (steps.length !== CONCRETE_STEP_NAMES.length) return false;
|
||||
const context = options.context || {};
|
||||
for (const step of steps) {
|
||||
const result = step.update(item, dt, worldRef, context) || {};
|
||||
if (result.done) return result.ok !== false;
|
||||
}
|
||||
return true;
|
||||
return runner.run(item, dt, worldRef, options.context || {});
|
||||
}
|
||||
|
||||
global.TarinaiItemLifecyclePipeline = Object.freeze({ updateOne });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue