public sealed class ObjectiveTrackerA set of objectives, their progress, and the subscriptions that move it. What a quest stage and a dynamic event are both made of.
Remarks
One tracker, two owners, and that is doc 28's "the same machine with the scope moved". A quest stage tracks with an owner set, so only that player's kills count; a dynamic event tracks with no owner, so everybody's do. Nothing else about them differs, and writing it twice would be two implementations of "no objective completes twice".
⚠ Completion is latched. Progress is a number that can move either way — a Collect objective is a level, and a rescaled event can want more than it did a minute ago — but finished is a one-way door. Without the latch, selling an ore un-finishes a stage that has already advanced, and doc 28's property that no objective completes twice becomes a property that it completes as often as a player likes.
⚠ It unsubscribes on Dispose and a caller must. A tracker holds one subscription per objective plus one per failure verb, and a stage that advanced without dropping its old tracker would go on counting kills for an objective nobody can see.
Fields and properties (6)
public int CountHow many objectives there are.
public int RequiredCountHow many of them have to be finished.
public bool IsCompleteWhether every non-optional objective is finished.
public bool IsFailedWhether something failed it.
public int FailedByWhich objective failed it, or −1.
public ReadOnlySpan<ObjectiveTemplate> ObjectivesWhat it is tracking.
Events (2)
public Action<ObjectiveAdvance>? AdvancedRaised when an objective moves.
public Action<int>? FailedRaised the first time something fails it.
Methods (11)
public ObjectiveTracker(GameplayEventBus bus, ReadOnlySpan<ObjectiveTemplate> objectives, PlayerId owner = default(PlayerId), float scale = 1)Starts tracking, subscribing immediately.
public int ProgressOf(int index)How far along an objective is.
public float Exact(int index)How far along an objective is, unrounded.
public int RequiredOf(int index)How much an objective needs.
public bool Seat(int index, float progress, bool completed)Puts an objective's progress back with no checks and no events.
public void SeatFailure(bool failed, int objective = -1)Puts a failure back with no checks and no events.
public bool IsCompleteAt(int index)Whether an objective is finished.
public int Tick(float delta)Advances the timed objectives.
public int Rescale(float scale)Raises what the objectives need, for an event that grew.
public bool Fail(int objective = -1)Fails it, as a stage's clock running out does.
public void Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Used by (7)
- ActiveQuestVixen.Gameplay.Quests
- DynamicEventInstanceVixen.Gameplay.Quests
- DynamicEventTestsVixen.Gameplay.Quests.Tests
- QuestJournalVixen.Gameplay.Quests
- QuestJournalTestsVixen.Gameplay.Quests.Tests
- QuestSectionVixen.Live.Gameplay
- QuestSectionTestsVixen.Live.Gameplay.Tests