Not logged inOpenClonk Forum
Up Topic Question: Goal updates

This board is threaded (i.e. has a tree structure). Please use the Reply button of the specific post you are referring to, not just any random button. If you want to reply to the topic in general, use the Post button near the top and bottom of the page.

Post Reply
In Response to Sven2
A function like IsFulfilled is needed e.g. if someone clicks the goal menu and wants to see all goals and their fulfilled status. Whether the goal upodates its state via a timer, via events or keeps a cached result is up to the goal. IsFulfilled is pretty much the simplest interface you can have. It makes no assumption about how the goal achieves that and the goal does not have to know how often an update is needed.

For example, if a goal menu is open, you want an immediate update. So you call IsFulfilled more often - possibly every frame while the goal is open. If it's a league game, you may want to ask the goal more often as well (that was done e.g. in CR in the settlement league). If a sequence trigger is bound to a goal fulfilled status, it may also check the goal more often and also check inactive goals.

If the periodic call to the expensive check operation were done in the goal (i.e.: each goal that cannot work with events keeps its timer), then the goal would have to decide how often to update itself, even though it doesn't know that. If the goal were to do a timer and then inform everyone else of its change, you have a much more complex interface:
1. The refresh rate would be fixed and a goal user (such as the HUD) had no way to speed it up. If you wanted that, then each goal would have to implement something like SetCheckTimerInterval
2. Each goal would have to keep a list of potential users to callback to. You'd need to write a callback list (or hardcode all potential goal status users in the goal object - that's bad design because it would increase inter-dependencies)
3. Each goal that cannot work based on an event would have to implement its own timer.

Of course that extra logic could be hidden in Library_Goal and goals just keep either implementing IsFulfilled or have a property telling the controller "I work via events", and call SetFulfilled () (in that case, the default implementation of IsFulfilled would just check a variable defined in Library_Goal). It's a more complex interface. The upside would be that it saves having a timer for some goals (the ones that can be decided by an event).

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill