Sebaestschjin / gloomhaven-campaign-manager

Simplify the management of your Gloomhaven campaign progress in Tabletop Simulator.
MIT License
7 stars 5 forks source link

Make waiting for other tasks to finish easier and more consistent #14

Closed Sebaestschjin closed 3 years ago

Sebaestschjin commented 4 years ago

Throughout the code for loading there are different waits to ensure that other components are already on the table before starting (e.g. the box for locked characters has to be there before pulling a character of that box). Some of those waits are currently with time, which is quite fragile if a lot of stuff happens at the same time or your PC is slow. It would be better to ensure a specific ordering of events through wait events with conditions. What I'm imagening is a seperate tasks moduke, which would encapsulate that:

task = {}
tasks.UNLOCK_CHARACTERS = "UNLOCK_CHARACTERS"
tasks.PLACE_CHARACTER = "PLACE_CHARACTER"
-- ...

function tasks.waitFor(taskName) end
function tasks.isFinished(taskName) end
function tasks.finish(taskName) end

Also I diagram of which tasks have to wait for which other tasks would be cool.