narraleaf-react 0.0.1-beta.11 → 0.0.1-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import { RenderableNode } from "../action/tree/actionTree";
2
2
  import { LogicAction } from "../action/logicAction";
3
3
  import { Actionable } from "../action/actionable";
4
4
  import { GameState } from "../../player/gameState";
5
+ import { Chained, ChainedActions, Proxied } from "../action/chain";
5
6
  export type ConditionConfig = {};
6
7
  interface LambdaCtx {
7
8
  gameState: GameState;
@@ -34,18 +35,18 @@ export type ConditionData = {
34
35
  };
35
36
  export declare class Condition extends Actionable {
36
37
  static defaultConfig: ConditionConfig;
38
+ static getInitialState(): ConditionData;
37
39
  readonly config: ConditionConfig;
38
40
  conditions: ConditionData;
39
41
  constructor(config?: ConditionConfig);
40
- static getInitialState(): ConditionData;
41
- If(condition: Lambda | LambdaHandler<boolean>, action: LogicAction.Actions | LogicAction.Actions[]): this;
42
- ElseIf(condition: Lambda | LambdaHandler<boolean>, action: (LogicAction.Actions | LogicAction.Actions[])): this;
43
- Else(action: (LogicAction.Actions | LogicAction.Actions[])): this;
42
+ If(condition: Lambda | LambdaHandler<boolean>, action: ChainedActions): Proxied<Condition, Chained<LogicAction.Actions>>;
43
+ ElseIf(condition: Lambda | LambdaHandler<boolean>, action: ChainedActions): Proxied<Condition, Chained<LogicAction.Actions>>;
44
+ Else(action: ChainedActions): Proxied<Condition, Chained<LogicAction.Actions>>;
44
45
  evaluate(conditions: ConditionData, { gameState }: {
45
46
  gameState: GameState;
46
47
  }): LogicAction.Actions[] | null;
47
- toActions(): LogicAction.Actions[];
48
- construct(actions: LogicAction.Actions[], lastChild?: RenderableNode, parentChild?: RenderableNode): LogicAction.Actions[];
48
+ fromChained(chained: Proxied<Condition, Chained<LogicAction.Actions>>): LogicAction.Actions[];
49
+ construct(chainedActions: ChainedActions, lastChild?: RenderableNode, parentChild?: RenderableNode): LogicAction.Actions[];
49
50
  _getFutureActions(): LogicAction.Actions[];
50
51
  }
51
52
  export {};
@@ -1,38 +1,41 @@
1
1
  import { Actionable } from "../action/actionable";
2
2
  import { LogicAction } from "../action/logicAction";
3
+ import { Chained, ChainedActions, Proxied } from "../action/chain";
3
4
  import Actions = LogicAction.Actions;
5
+ type ChainedControl = Proxied<Control, Chained<LogicAction.Actions>>;
4
6
  export declare class Control extends Actionable {
5
7
  /**
6
8
  * Execute actions in order, waiting for each action to complete
7
9
  */
8
- static do(actions: (Actions | Actions[])[]): Control;
10
+ static do(actions: ChainedActions): never;
9
11
  /**
10
12
  * Execute actions in order, do not wait for this action to complete
11
13
  */
12
- static doAsync(actions: (Actions | Actions[])[]): Control;
14
+ static doAsync(actions: ChainedActions): never;
13
15
  /**
14
16
  * Execute all actions at the same time, waiting for any one action to complete
15
17
  */
16
- static any(actions: (Actions | Actions[])[]): Control;
18
+ static any(actions: ChainedActions): never;
17
19
  /**
18
20
  * Execute all actions at the same time, waiting for all actions to complete
19
21
  */
20
- static all(actions: (Actions | Actions[])[]): Control;
22
+ static all(actions: ChainedActions): never;
21
23
  /**
22
24
  * Execute all actions at the same time, do not wait for all actions to complete
23
25
  */
24
- static allAsync(actions: (Actions | Actions[])[]): Control;
26
+ static allAsync(actions: ChainedActions): never;
25
27
  /**
26
28
  * Execute actions multiple times
27
29
  */
28
- static repeat(times: number, actions: (Actions | Actions[])[]): Control;
30
+ static repeat(times: number, actions: ChainedActions): never;
29
31
  constructor();
30
- do(actions: (Actions | Actions[])[]): this;
31
- doAsync(actions: (Actions | Actions[])[]): this;
32
- any(actions: (Actions | Actions[])[]): this;
33
- all(actions: (Actions | Actions[])[]): this;
34
- allAsync(actions: (Actions | Actions[])[]): this;
35
- repeat(times: number, actions: (Actions | Actions[])[]): this;
32
+ do(actions: ChainedActions): ChainedControl;
33
+ doAsync(actions: ChainedActions): ChainedControl;
34
+ any(actions: ChainedActions): ChainedControl;
35
+ all(actions: ChainedActions): ChainedControl;
36
+ allAsync(actions: ChainedActions): ChainedControl;
37
+ repeat(times: number, actions: ChainedActions): ChainedControl;
36
38
  construct(actions: Actions[]): Actions[];
37
39
  private push;
38
40
  }
41
+ export {};
@@ -2,10 +2,13 @@ import React from "react";
2
2
  import type { TransformDefinitions } from "../elements/transform/type";
3
3
  import { ImageAction } from "../action/actions";
4
4
  import { Actionable } from "../action/actionable";
5
+ import { Scene } from "../elements/scene";
5
6
  import { Transform } from "./transform/transform";
6
7
  import { CommonImage, StaticImageData } from "../types";
8
+ import { LogicAction } from "../game";
7
9
  import { ITransition } from "../elements/transition/type";
8
10
  import { DeepPartial, EventDispatcher } from "../../../util/data";
11
+ import { Chained, Proxied } from "../action/chain";
9
12
  export type ImageConfig = {
10
13
  src: string | StaticImageData;
11
14
  display: boolean;
@@ -25,7 +28,7 @@ export type ImageEventTypes = {
25
28
  "event:image.elementLoaded": [];
26
29
  "event:image.setTransition": [ITransition | null];
27
30
  };
28
- export declare class Image extends Actionable<ImageDataRaw> {
31
+ export declare class Image extends Actionable<ImageDataRaw, Image> {
29
32
  static EventTypes: {
30
33
  [K in keyof ImageEventTypes]: K;
31
34
  };
@@ -35,18 +38,17 @@ export declare class Image extends Actionable<ImageDataRaw> {
35
38
  left: "left";
36
39
  right: "right";
37
40
  };
41
+ static serializeImageState(state: Record<string, any>): Record<string, any>;
42
+ static deserializeImageState(state: Record<string, any>): ImageConfig;
38
43
  readonly name: string;
39
44
  readonly config: ImageConfig;
40
45
  state: ImageConfig;
41
- actions: ImageAction<any>[];
42
- events: EventDispatcher<ImageEventTypes>;
46
+ readonly events: EventDispatcher<ImageEventTypes>;
43
47
  ref: React.RefObject<HTMLImageElement> | undefined;
44
48
  constructor(name: string, config: DeepPartial<ImageConfig>);
45
49
  constructor(config: DeepPartial<ImageConfig>);
46
- static serializeImageState(state: Record<string, any>): Record<string, any>;
47
- static deserializeImageState(state: Record<string, any>): ImageConfig;
48
- dispose(): this;
49
- init(): this;
50
+ dispose(): Proxied<Image, Chained<LogicAction.Actions, any>>;
51
+ init(): Proxied<Image, Chained<LogicAction.Actions>>;
50
52
  checkConfig(): this;
51
53
  /**
52
54
  * Set the source of the image
@@ -62,7 +64,7 @@ export declare class Image extends Actionable<ImageDataRaw> {
62
64
  * image.setSrc(yourImage, new Fade(1000));
63
65
  * ```
64
66
  */
65
- setSrc(src: string | StaticImageData, transition?: ITransition): this;
67
+ setSrc(src: string | StaticImageData, transition?: ITransition): Proxied<Image, Chained<LogicAction.Actions>>;
66
68
  /**
67
69
  * Apply a transform to the image
68
70
  * @example
@@ -95,7 +97,7 @@ export declare class Image extends Actionable<ImageDataRaw> {
95
97
  * );
96
98
  * ```
97
99
  */
98
- applyTransform(transform: Transform): this;
100
+ applyTransform(transform: Transform): Proxied<Image, Chained<LogicAction.Actions>>;
99
101
  /**
100
102
  * Show the image
101
103
  *
@@ -107,15 +109,15 @@ export declare class Image extends Actionable<ImageDataRaw> {
107
109
  * });
108
110
  * ```
109
111
  */
110
- show(): this;
111
- show(options: Transform): this;
112
- show(options: Partial<TransformDefinitions.CommonTransformProps>): this;
112
+ show(): Proxied<Image, Chained<LogicAction.Actions>>;
113
+ show(options: Transform): Proxied<Image, Chained<LogicAction.Actions>>;
114
+ show(options: Partial<TransformDefinitions.CommonTransformProps>): Proxied<Image, Chained<LogicAction.Actions>>;
113
115
  /**
114
116
  * Hide the image
115
117
  */
116
- hide(): this;
117
- hide(transform: Transform): this;
118
- hide(transform: Partial<TransformDefinitions.CommonTransformProps>): this;
118
+ hide(): Proxied<Image, Chained<LogicAction.Actions>>;
119
+ hide(transform: Transform): Proxied<Image, Chained<LogicAction.Actions>>;
120
+ hide(transform: Partial<TransformDefinitions.CommonTransformProps>): Proxied<Image, Chained<LogicAction.Actions>>;
119
121
  toTransform(): Transform;
120
122
  setScope(scope: React.RefObject<HTMLImageElement>): this;
121
123
  getScope(): React.RefObject<HTMLImageElement> | undefined;
@@ -123,9 +125,9 @@ export declare class Image extends Actionable<ImageDataRaw> {
123
125
  toData(): ImageDataRaw | null;
124
126
  fromData(data: ImageDataRaw): this;
125
127
  _$setDispose(): this;
126
- _setTransition(transition: ITransition | null): this;
127
- _applyTransition(transition: ITransition): this;
128
+ _setTransition(transition: ITransition | null): Proxied<Image, Chained<LogicAction.Actions>>;
129
+ _applyTransition(transition: ITransition): Proxied<Image, Chained<LogicAction.Actions>>;
128
130
  private _transitionSrc;
129
131
  private _dispose;
130
- private _init;
132
+ _init(scene?: Scene): ImageAction<typeof ImageAction.ActionTypes.init>;
131
133
  }
@@ -1,14 +1,17 @@
1
1
  import { Sentence, Word } from "./text";
2
- import { RenderableNode } from "../action/tree/actionTree";
3
2
  import { LogicAction } from "../action/logicAction";
4
3
  import { MenuAction } from "../action/actions";
5
4
  import { Actionable } from "../action/actionable";
6
5
  import Actions = LogicAction.Actions;
6
+ import { Chained, Proxied } from "../action/chain";
7
+ import GameElement = LogicAction.GameElement;
7
8
  export type MenuConfig = {};
8
9
  export type MenuChoice = {
9
- action: Actions[];
10
+ action: ChainedActions;
10
11
  prompt: UnSentencePrompt | Sentence;
11
12
  };
13
+ type ChainedAction = Proxied<GameElement, Chained<LogicAction.Actions>>;
14
+ type ChainedActions = (ChainedAction | ChainedAction[] | Actions | Actions[])[];
12
15
  type UnSentencePrompt = (string | Word)[] | (string | Word);
13
16
  export type Choice = {
14
17
  action: Actions[];
@@ -18,7 +21,7 @@ export type MenuData = {
18
21
  prompt: Sentence;
19
22
  choices: Choice[];
20
23
  };
21
- export declare class Menu extends Actionable {
24
+ export declare class Menu extends Actionable<any, Menu> {
22
25
  static defaultConfig: MenuConfig;
23
26
  static targetAction: typeof MenuAction;
24
27
  prompt: Sentence;
@@ -33,11 +36,11 @@ export declare class Menu extends Actionable {
33
36
  * character.say("I went left").toActions()
34
37
  * ]);
35
38
  */
36
- choose(choice: MenuChoice): this;
37
- choose(prompt: Sentence, action: (Actions | Actions[])[]): this;
38
- choose(prompt: UnSentencePrompt, action: (Actions | Actions[])[]): this;
39
- construct(actions: Actions[], lastChild?: RenderableNode, parentChild?: RenderableNode): Actions[];
40
- toActions(): MenuAction<"menu:action">[];
39
+ choose(choice: MenuChoice): Proxied<Menu, Chained<LogicAction.Actions>>;
40
+ choose(prompt: Sentence, action: ChainedActions): Proxied<Menu, Chained<LogicAction.Actions>>;
41
+ choose(prompt: UnSentencePrompt, action: ChainedActions): Proxied<Menu, Chained<LogicAction.Actions>>;
42
+ fromChained(chained: Proxied<Menu, Chained<LogicAction.Actions>>): LogicAction.Actions[];
43
+ private construct;
41
44
  _getFutureActions(choices: Choice[]): LogicAction.Actions[];
42
45
  private constructChoices;
43
46
  }
@@ -8,8 +8,10 @@ import { ITransition } from "../elements/transition/type";
8
8
  import { SrcManager } from "../elements/srcManager";
9
9
  import { Sound, SoundDataRaw } from "../elements/sound";
10
10
  import { TransformDefinitions } from "../elements/transform/type";
11
+ import { Chained, Proxied } from "../action/chain";
11
12
  import Actions = LogicAction.Actions;
12
13
  import ImageTransformProps = TransformDefinitions.ImageTransformProps;
14
+ import GameElement = LogicAction.GameElement;
13
15
  export type SceneConfig = {
14
16
  invertY: boolean;
15
17
  invertX: boolean;
@@ -22,15 +24,17 @@ export type SceneState = {
22
24
  export type JumpConfig = {
23
25
  transition: ITransition;
24
26
  };
27
+ type ChainableAction = Proxied<GameElement, Chained<LogicAction.Actions>> | Actions;
28
+ type ChainedScene = Proxied<Scene, Chained<LogicAction.Actions>>;
25
29
  export type SceneDataRaw = {
26
30
  state: {
27
31
  backgroundMusic?: SoundDataRaw | null;
28
32
  background?: Background["background"];
29
- backgroundImageState?: Partial<CommonImage>;
30
33
  };
34
+ backgroundImageState?: Partial<CommonImage>;
31
35
  };
32
36
  export type SceneEventTypes = {
33
- "event:scene.setTransition": [ITransition | null];
37
+ "event:scene.applyTransition": [ITransition | null];
34
38
  "event:scene.remove": [];
35
39
  "event:scene.load": [];
36
40
  "event:scene.unload": [];
@@ -42,72 +46,92 @@ export type SceneEventTypes = {
42
46
  "event:scene.setBackgroundMusic": [Sound | null, number];
43
47
  "event:scene.applyTransform": [Transform<ImageTransformProps>];
44
48
  };
45
- export declare class Scene extends Constructable<any, Actions, SceneAction<"scene:action">> {
49
+ export declare class Scene extends Constructable<Actions, Scene> {
46
50
  static EventTypes: {
47
51
  [K in keyof SceneEventTypes]: K;
48
52
  };
49
53
  static defaultConfig: SceneConfig;
50
54
  static defaultState: SceneState;
51
- static targetAction: typeof SceneAction;
52
55
  readonly id: string;
53
56
  readonly name: string;
54
57
  readonly config: SceneConfig;
55
58
  state: SceneConfig & SceneState;
56
- srcManager: SrcManager;
57
- events: EventDispatcher<SceneEventTypes>;
59
+ readonly srcManager: SrcManager;
60
+ readonly events: EventDispatcher<SceneEventTypes>;
58
61
  backgroundImageState: Partial<CommonImage>;
59
62
  _liveState: {
60
63
  active: boolean;
61
64
  };
62
- _sceneRoot?: SceneAction<"scene:action">;
63
- private _actions;
65
+ sceneRoot?: SceneAction<"scene:action">;
64
66
  constructor(name: string, config?: DeepPartial<SceneConfig>);
65
- activate(): this;
66
- deactivate(): this;
67
+ /**
68
+ * Activate the scene
69
+ *
70
+ * This is only used when auto activation is not working
71
+ * @chainable
72
+ */
73
+ activate(): ChainedScene;
74
+ /**
75
+ * Deactivate the scene
76
+ *
77
+ * This is only used when auto deactivation is not working
78
+ * @chainable
79
+ */
80
+ deactivate(): ChainedScene;
67
81
  /**
68
82
  * Set background, if {@link transition} is provided, it will be applied
83
+ * @chainable
69
84
  */
70
- setBackground(background: Background["background"], transition?: ITransition): this;
85
+ setBackground(background: Background["background"], transition?: ITransition): ChainedScene;
71
86
  /**
72
87
  * Apply a transform to the scene
73
88
  *
74
89
  * for example, you can shake the scene by applying a transform with a shake effect
90
+ * @chainable
75
91
  */
76
- applyTransform(transform: Transform<ImageTransformProps>): this;
92
+ applyTransform(transform: Transform<ImageTransformProps>): ChainedScene;
77
93
  /**
78
94
  * Jump to the specified scene
79
95
  *
80
96
  * After calling the method, you **will not be able to return to the context of the scene** that called the jump, so the scene will be unloaded
81
97
  *
82
98
  * Any operations after the jump operation will not be executed
99
+ * @chainable
83
100
  */
84
- jumpTo(arg0: Scene, config?: Partial<JumpConfig>): this;
85
- transitionSceneBackground(scene?: Scene, transition?: ITransition): this;
101
+ jumpTo(arg0: Scene, config?: Partial<JumpConfig>): ChainedScene;
86
102
  /**
87
103
  * Wait for a period of time, the parameter can be the number of milliseconds, a Promise, or an unresolved {@link Awaitable}
104
+ * @chainable
88
105
  */
89
- sleep(ms: number): this;
90
- sleep(promise: Promise<any>): this;
91
- sleep(awaitable: Awaitable<any, any>): this;
106
+ sleep(ms: number): ChainedScene;
107
+ sleep(promise: Promise<any>): ChainedScene;
108
+ sleep(awaitable: Awaitable<any, any>): ChainedScene;
92
109
  /**
93
110
  * Set background music
94
111
  * @param sound Target music
95
112
  * @param fade If set, the fade-out effect will be applied to the previous music, and the fade-in effect will be applied to the current music, with a duration of {@link fade} milliseconds
113
+ * @chainable
96
114
  */
97
- setBackgroundMusic(sound: Sound, fade?: number): this;
98
- toActions(): SceneAction<any>[];
99
- _$getBackgroundMusic(): Sound | null;
115
+ setBackgroundMusic(sound: Sound, fade?: number): ChainedScene;
100
116
  toData(): SceneDataRaw | null;
101
117
  fromData(data: SceneDataRaw): this;
102
- _setTransition(transition: ITransition): this;
103
- _applyTransition(transition: ITransition): this;
104
- _toTransform(): Transform<ImageTransformProps>;
118
+ getInitTransform(): Transform<ImageTransformProps>;
119
+ action(actions: (ChainableAction | ChainableAction[])[]): this;
120
+ action(actions: ((scene: Scene) => ChainableAction[])): this;
105
121
  registerSrc(seen?: Set<Scene>): void;
106
- action(actions: (Actions | Actions[])[]): this;
107
- action(actions: ((scene: Scene) => Actions[])): this;
108
- protected getSceneActions(): SceneAction<any>[];
122
+ /**
123
+ * @internal STILL IN DEVELOPMENT
124
+ */
125
+ assignActionId(): void;
126
+ /**
127
+ * @internal STILL IN DEVELOPMENT
128
+ */
129
+ assignElementId(): void;
130
+ private _applyTransition;
131
+ private _transitionSceneBackground;
109
132
  private _jumpTo;
110
133
  private _exit;
111
134
  private _transitionToScene;
112
135
  private _init;
113
136
  }
137
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { LogicAction } from "../action/logicAction";
2
2
  import { Actionable } from "../action/actionable";
3
3
  import { GameState } from "../../player/gameState";
4
- import Actions = LogicAction.Actions;
4
+ import { Chained, Proxied } from "../action/chain";
5
5
  export interface ScriptCtx {
6
6
  script: Script;
7
7
  gameState: GameState;
@@ -18,6 +18,6 @@ export declare class Script extends Actionable<object> {
18
18
  getCtx({ gameState }: {
19
19
  gameState: GameState;
20
20
  }): ScriptCtx;
21
- toActions(): Actions[];
21
+ fromChained(chained: Proxied<Script, Chained<LogicAction.Actions>>): LogicAction.Actions[];
22
22
  }
23
23
  export {};
@@ -1,7 +1,10 @@
1
1
  import { Actionable } from "../action/actionable";
2
2
  import { DeepPartial } from "../../../util/data";
3
+ import { LogicAction } from "../game";
3
4
  import * as Howler from "howler";
4
5
  import { HowlOptions } from "howler";
6
+ import { Chained, Proxied } from "../action/chain";
7
+ type ChainedSound = Proxied<Sound, Chained<LogicAction.Actions>>;
5
8
  export declare enum SoundType {
6
9
  soundEffect = "soundEffect",
7
10
  music = "music",
@@ -40,13 +43,13 @@ export declare class Sound extends Actionable<SoundDataRaw> {
40
43
  token: any;
41
44
  };
42
45
  constructor(config?: DeepPartial<SoundConfig>);
43
- play(): this;
44
- stop(): this;
45
- fade(start: number | undefined, end: number, duration: number): this;
46
- setVolume(volume: number): this;
47
- setRate(rate: number): this;
48
- pause(fade?: number): this;
49
- resume(fade?: number): this;
46
+ play(): ChainedSound;
47
+ stop(): ChainedSound;
48
+ fade(start: number | undefined, end: number, duration: number): ChainedSound;
49
+ setVolume(volume: number): ChainedSound;
50
+ setRate(rate: number): ChainedSound;
51
+ pause(fade?: number): ChainedSound;
52
+ resume(fade?: number): ChainedSound;
50
53
  getHowlOptions(): HowlOptions;
51
54
  getSrc(): string;
52
55
  $setToken(token: any): void;
@@ -58,3 +61,4 @@ export declare class Sound extends Actionable<SoundDataRaw> {
58
61
  fromData(data: SoundDataRaw): this;
59
62
  private pushAction;
60
63
  }
64
+ export {};
@@ -1,40 +1,17 @@
1
1
  import { Constructable } from "../action/constructable";
2
- import { LogicAction } from "../game";
3
- import { SceneAction, StoryAction } from "../action/actions";
4
- import { RawData, RenderableNode } from "../action/tree/actionTree";
2
+ import { SceneAction } from "../action/actions";
5
3
  import { Scene } from "../elements/scene";
4
+ import { RawData } from "../action/tree/actionTree";
6
5
  export type StoryConfig = {};
7
6
  export type ElementStateRaw = Record<string, any>;
8
7
  export type NodeChildIdMap = Map<string, string>;
9
- export declare class Story extends Constructable<any, SceneAction<"scene:action">, StoryAction<"story:action">> {
8
+ export declare class Story extends Constructable<SceneAction<"scene:action">, Story> {
10
9
  static defaultConfig: StoryConfig;
11
- static targetAction: typeof StoryAction;
12
10
  readonly id: string;
13
11
  readonly name: string;
14
12
  readonly config: StoryConfig;
13
+ entryScene: Scene | null;
15
14
  constructor(name: string, config?: StoryConfig);
16
- /**@internal */
17
- _setAllElementState(data: RawData<ElementStateRaw>[], actions?: LogicAction.Actions[]): void;
18
- /**@internal */
19
- _getAllElementState(actions?: LogicAction.Actions[]): RawData<ElementStateRaw>[];
20
- /**
21
- * @internal
22
- * Generate node descendant ID mapping
23
- * The key is the node ID, and the value is the child node ID
24
- */
25
- _getNodeChildIdMap(actions?: LogicAction.Actions[]): NodeChildIdMap;
26
- /**
27
- * @internal
28
- * Use the specified mapping table to restore the node descendants
29
- */
30
- _setNodeChildByMap(map: NodeChildIdMap | Record<string, string>, actions?: LogicAction.Actions[]): void;
31
- /**
32
- * @internal
33
- * Generate node ID mapping
34
- */
35
- _getMappedNodes(nodes: RenderableNode[]): Map<string, RenderableNode>;
36
- toData(): null;
37
- fromData(_: any): this;
38
15
  /**
39
16
  * Set the entry scene of the story
40
17
  * @example
@@ -45,4 +22,7 @@ export declare class Story extends Constructable<any, SceneAction<"scene:action"
45
22
  * ```
46
23
  */
47
24
  entry(scene: Scene): this;
25
+ constructStory(): this;
26
+ getAllElementStates(): RawData<ElementStateRaw>[];
27
+ private runStaticCheck;
48
28
  }
@@ -1,7 +1,9 @@
1
+ import { LogicAction } from "../game";
1
2
  import { color, Color } from "../types";
2
3
  import { DeepPartial } from "../../../util/data";
3
4
  import { Actionable } from "../action/actionable";
4
5
  import type { Sound } from "../elements/sound";
6
+ import { Chained, Proxied } from "../action/chain";
5
7
  export type SentenceConfig = {
6
8
  pause?: boolean | number;
7
9
  voice: Sound | string | null | undefined;
@@ -17,14 +19,14 @@ type UnSentencePrompt = (string | Word)[] | (string | Word);
17
19
  export declare class Sentence {
18
20
  static defaultConfig: SentenceConfig;
19
21
  static defaultState: SentenceState;
22
+ static isSentence(obj: any): obj is Sentence;
23
+ static toSentence(prompt: UnSentencePrompt | Sentence): Sentence;
20
24
  id: string;
21
25
  character: Character | null;
22
26
  text: Word[];
23
27
  config: SentenceConfig;
24
28
  state: SentenceState;
25
29
  constructor(character: Character | null, text: (string | Word)[] | (string | Word), config?: Partial<SentenceConfig>);
26
- static isSentence(obj: any): obj is Sentence;
27
- static toSentence(prompt: UnSentencePrompt | Sentence): Sentence;
28
30
  format(text: (string | Word)[] | (string | Word)): Word[];
29
31
  toData(): SentenceDataRaw | null;
30
32
  fromData(data: SentenceDataRaw): this;
@@ -33,10 +35,10 @@ export declare class Sentence {
33
35
  export declare class Word {
34
36
  static defaultConfig: Partial<WordConfig>;
35
37
  static defaultColor: color;
38
+ static isWord(obj: any): obj is Word;
36
39
  text: string;
37
40
  config: Partial<WordConfig>;
38
41
  constructor(text: string, config?: Partial<WordConfig>);
39
- static isWord(obj: any): obj is Word;
40
42
  }
41
43
  export declare enum CharacterMode {
42
44
  "adv" = "adv",
@@ -46,34 +48,33 @@ export type CharacterConfig = {
46
48
  mode: CharacterMode;
47
49
  };
48
50
  export type CharacterStateData = {};
49
- export declare class Character extends Actionable<CharacterStateData> {
51
+ export declare class Character extends Actionable<CharacterStateData, Character> {
50
52
  static Modes: typeof CharacterMode;
51
53
  static defaultConfig: CharacterConfig;
52
- name: string | null;
53
- config: CharacterConfig;
54
+ readonly name: string | null;
55
+ readonly config: CharacterConfig;
54
56
  constructor(name: string | null, config?: DeepPartial<CharacterConfig>);
55
57
  /**
56
58
  * Say something
57
59
  * @example
58
60
  * ```typescript
59
- * character.say("Hello, world!").toActions();
61
+ * character.say("Hello, world!");
60
62
  * ```
61
63
  * @example
62
64
  * ```typescript
63
65
  * character
64
66
  * .say("Hello, world!")
65
- * .say("Hello, world!")
66
- * .toActions();
67
+ * .say("Hello, world!");
67
68
  * ```
68
69
  * @example
69
70
  * ```typescript
70
71
  * character.say(new Sentence(character, [
71
72
  * "Hello, ",
72
73
  * new Word("world", {color: "#f00"}), // Some words can be colored
73
- * ])).toActions();
74
+ * ]));
74
75
  */
75
- say(content: string): Character;
76
- say(content: Sentence): Character;
77
- say(content: (string | Word)[]): Character;
76
+ say(content: string): Proxied<Character, Chained<LogicAction.Actions>>;
77
+ say(content: Sentence): Proxied<Character, Chained<LogicAction.Actions>>;
78
+ say(content: (string | Word)[]): Proxied<Character, Chained<LogicAction.Actions>>;
78
79
  }
79
80
  export {};
@@ -16,12 +16,6 @@ declare class IdManager extends IdManager_base {
16
16
  getStringId(): string;
17
17
  prefix(prefix: string, value: string, separator?: string): string;
18
18
  }
19
- declare class GameIdManager {
20
- private id;
21
- getId(): number;
22
- getStringId(): string;
23
- prefix(prefix: string, value: string, separator?: string): string;
24
- }
25
19
  declare enum GameSettingsNamespace {
26
20
  game = "game"
27
21
  }
@@ -32,6 +26,7 @@ export declare class Game {
32
26
  };
33
27
  static DefaultConfig: GameConfig;
34
28
  static GameSettingsNamespace: typeof GameSettingsNamespace;
29
+ static getIdManager(): IdManager;
35
30
  readonly config: Readonly<GameConfig>;
36
31
  liveGame: LiveGame | null;
37
32
  /**
@@ -39,7 +34,6 @@ export declare class Game {
39
34
  * @param config - Game configuration
40
35
  */
41
36
  constructor(config: DeepPartial<GameConfig>);
42
- static getIdManager(): IdManager;
43
37
  useComponent<T extends keyof ComponentsTypes>(key: T, components: ComponentsTypes[T]): this;
44
38
  getLiveGame(): LiveGame;
45
39
  private createLiveGame;
@@ -53,15 +47,12 @@ export declare class LiveGame {
53
47
  };
54
48
  game: Game;
55
49
  storable: Storable;
56
- currentSceneNumber: number | null;
57
50
  currentSavedGame: SavedGame | null;
58
51
  story: Story | null;
59
52
  lockedAwaiting: Awaitable<CalledActionResult, any> | null;
60
- idManager: GameIdManager;
61
53
  _lockedCount: number;
62
54
  private currentAction;
63
55
  constructor(game: Game);
64
- getDefaultSavedGame(): SavedGame;
65
56
  initNamespaces(): this;
66
57
  getStorable(): Storable;
67
58
  loadStory(story: Story): this;
@@ -72,17 +63,22 @@ export declare class LiveGame {
72
63
  /**
73
64
  * Load a saved game
74
65
  *
75
- * Note: Different versions of the game won't be able to load each other's saved games
66
+ * Note: Even if you change just a single line of code, the saved game might not be compatible with the new version
67
+ *
68
+ * After calling this method, the current game state will be lost, can the stage will trigger force reset
76
69
  */
77
70
  deserialize(savedGame: SavedGame, { gameState }: {
78
71
  gameState: GameState;
79
72
  }): void;
73
+ reset({ gameState }: {
74
+ gameState: GameState;
75
+ }): void;
80
76
  /**
81
77
  * Serialize the current game state
82
78
  *
83
79
  * You can use this to save the game state to a file or a database
84
80
  *
85
- * Note: Different versions of the game won't be able to load each other's saved games
81
+ * Note: Even if you change just a single line of code, the saved game might not be compatible with the new version
86
82
  */
87
83
  serialize({ gameState }: {
88
84
  gameState: GameState;
@@ -92,6 +88,7 @@ export declare class LiveGame {
92
88
  next(state: GameState): CalledActionResult | Awaitable<CalledActionResult, CalledActionResult> | null;
93
89
  abortAwaiting(): void;
94
90
  executeAction(state: GameState, action: LogicAction.Actions): LogicAction.Actions | Awaitable<CalledActionResult, CalledActionResult> | null;
91
+ private getNewSavedGame;
95
92
  }
96
93
  declare const _default: {
97
94
  Game: typeof Game;