forked from profectus/Profectus
Add manual complete function for milestones
This commit is contained in:
parent
1fac1edb46
commit
d8edac1c9a
1 changed files with 5 additions and 0 deletions
|
@ -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>;
|
||||||
|
|
Loading…
Reference in a new issue