Add manual complete function for milestones

This commit is contained in:
thepaperpilot 2022-03-11 08:54:36 -06:00
parent 1fac1edb46
commit d8edac1c9a

View file

@ -59,6 +59,7 @@ export interface MilestoneOptions {
export interface BaseMilestone extends Persistent<boolean> { export interface BaseMilestone extends Persistent<boolean> {
id: string; id: string;
earned: Ref<boolean>; earned: Ref<boolean>;
complete: VoidFunction;
type: typeof MilestoneType; type: typeof MilestoneType;
[Component]: typeof MilestoneComponent; [Component]: typeof MilestoneComponent;
[GatherProps]: () => Record<string, unknown>; [GatherProps]: () => Record<string, unknown>;
@ -92,6 +93,10 @@ export function createMilestone<T extends MilestoneOptions>(
milestone[Component] = MilestoneComponent; milestone[Component] = MilestoneComponent;
milestone.earned = milestone[PersistentState]; milestone.earned = milestone[PersistentState];
milestone.complete = function () {
milestone[PersistentState].value = true;
};
processComputable(milestone as T, "visibility"); processComputable(milestone as T, "visibility");
setDefault(milestone, "visibility", Visibility.Visible); setDefault(milestone, "visibility", Visibility.Visible);
const visibility = milestone.visibility as ProcessedComputable<Visibility>; const visibility = milestone.visibility as ProcessedComputable<Visibility>;