creep-tasks
creep-tasks copied to clipboard
Question: Why is creep._task not set when originally setting the task?
https://github.com/bencbartlett/creep-tasks/blob/master/src/creep-tasks/prototypes.ts#L39
It looks like when you assign creep.task, the only thing that gets set is the creep's memory, which then needs to get read again and instantiate a new Task object. What's the reason for this?
Seems odd that the steps are essentially:
// Instantiate new Task object to assign
creep.task = new TaskHarvest();
// Under the hood, this sets
creep.memory.task = task.proto;
// Then when creep,task is read
creep._task = new TaskHarvest() // via the prototask
Why not just set creep._task = task
in the initial setter?