Small-Loan-Studio / TGO

0 stars 0 forks source link

Over engineer a quest system #96

Closed this-is-envy closed 2 weeks ago

this-is-envy commented 3 weeks ago

In addition to this writeup see also the merged docs -- https://github.com/Small-Loan-Studio/TGO/blob/envy-quest-systems/docs/tgo-quests.md

Adds an initial cut of a Quest definition / tracking system. Includes a...

Quest Resource

The class has reasonable documentation but a short version is that it is a combination of:

A quest with "Phases" is basically a parent quest that has multiple steps which need to be completed. It's possible to mark some quest phases as failable

A quest with a "next" element is one that will trigger some next step once the current is completed.

Each quest evaluates itself and conditions to determine if it should finish itself.

QuestManager

This handles reactions to state transitions between quests and tracks the active quests. It's where the logic for progression from one quest to the other that I describe above is implemented, c.f., _process_completed_quest.

It also attaches to change signals from relevant external systems to understand when it should reevaluate the state of the active quests. At this point it is only linked to inventory state and dialogic var state. This happens in _connect_post_ready

Conditions

New Effect

SetQuestStateEffect is a way to move a quest from Dormant to any other state. Can be used to start / complete quests in conversations / interactable / switches / etc.

Debugging UI

I thought this was going to be a simple "just do a thing" but turns out walking the phase/next bullshit is hard and by the end I think we should reevaluate even using that on a long enough timeline. On the plus side after building this I'm pretty sure I know how I'm going to write up the interface guidelines.

QuestLine displays a single quest title and a checkmark or X if the quest has completed or failed.

QuestTracker has a reference to the quest manager and handles walking the active set of quests and turning that into a set of quest lines. It links to QuestManager via quest_updated signal to determine when it should recalculate the display. This is all "slow" in that it does a full walk and doesn't do anything clever but quest state changes should be infrequent enough it doesn't matter.

Also this is a debugging UI that we can trash. The _process_quest impl will probably be useful if we want to generally reuse the graph walk (or maybe we can convert this to a visitor pattern)