-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlowerPlugin.ts
72 lines (62 loc) · 1.82 KB
/
FlowerPlugin.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { FlowerAPI } from "./FlowerAPI"
import { LogSource } from "./logSource"
export type FlowerMeta =
{
/**
* Fill this out and make it unique.
* Try to follow a reverse COM format or team.product schema here
*/
GUID: string
/**
* You can put whatever you want here but keep in mind other plugins may want
* to figure out if they know what features you offer based on your version so
* keep it simple to understand. SemVer x.x.x major.minor.release is easy to
* understand and parse
*/
VERSION: string
/**
* This can be whatever you want.
*/
NAME: string
/**
* Flower will respect this value and refuse to load plugins that are disabled
*/
ENABLED: boolean
}
export interface IFlowerPluginFactory<T>
{
/**
* Flower will pass you a flowerAPI and LogSource as your plugin is created
* This is the earliest your plugin exists and because JS is async
* there is no way to access other plugins metadata/etc here.
* Flower and the logger are loaded. Other plugins may still be loading
*/
new(flower: FlowerAPI<T>, logger: LogSource): IFlowerPlugin
}
export interface IFlowerPlugin
{
/**
* Flower will call this as a post-load event when it has finished loading
* or disposing of all plugins. All plugin states are ready here and you
* can depend on all other plugins being fully loaded at this point
*/
Awake: () => void
}
export type FlowerModule =
{
META: FlowerMeta;
default: IFlowerPluginFactory<any>
}
export abstract class BasePlugin<T> implements IFlowerPlugin
{
flower: FlowerAPI<T>;
logger: LogSource;
gameData: T;
constructor(flower: FlowerAPI<T>, logger: LogSource)
{
this.flower = flower;
this.logger = logger;
this.gameData = flower.GetGameMain();
}
abstract Awake(): void;
}