Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] - Activities #49

Open
LambdaSix opened this issue Jun 6, 2019 · 1 comment
Open

[Core] - Activities #49

LambdaSix opened this issue Jun 6, 2019 · 1 comment

Comments

@LambdaSix
Copy link
Owner

LambdaSix commented Jun 6, 2019

Any action that is not instantaneous/uninterruptable* should be queued as an Activity that can be interrupted, paused, and resumed later.

Most activities will be 'active' and be at the front of the queue, so the creature will be processing that specific activity, however there should be support for 'passive' activities like eating while crafting, refuelling a fire, or being aware of other creatures in the vicinity.
All activities should process a single turns worth of actions, then yield back to the manager which will either invoke a passive handler and possibly consuming a turn, or call the activity again for another turns worth of actions.

Passive actions can possibly not require a full turn to process, an example would be passively checking for monsters, this would be treated as a 'free' action; Eating/drinking on the other hand would be considered a multiple-turn action of it's own and interrupt the current activity satisfy the players needs.

To allow for that, activities should support a Priority system, so that checking for monsters is highest priority, eating/drinking is below it, refuelling fire is next, then finally the current activity. This allows multi-turn passive activities to 'block' the current activity until they are finished.

Activities should be pushed into a queue that belongs to each creature with at least the following:

  • Add an ActivityInfo to the queue, yielding a unique key for that activity
  • Investigate the contents of the queue
  • Process a Current activity, calling the given activity for progress & time left info.
  • Remove an activity either by reference to the ActivityInfo or the unique key

The Activity queue for a creature should be serialised alongside it's other data to allow resuming tasks across sessions. With pre-checks this would allow storing work bench activities on the player with situation requirements for resuming later.

Activity handlers should:

  • Be able to give an estimate for the task be taken (where possible).
  • Register their requirements as they change.
  • Process the activity on a per-turn basis.
    That is, the activity should yield back to the calling function per turns worth of activity.
  • Be interruptable.
  • Be resumable/restartable.
  • Basic implementation should be a simple subclass and method overriding.
  • Probably very few actions take <1 turn?
@LambdaSix
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant