@wayward/types 2.12.0-beta.dev.20220927.1 → 2.12.0-beta.dev.20220929.2

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.
@@ -138,7 +138,7 @@ export declare class Game extends EventEmitter.Host<IGameEvents> {
138
138
  * Marks that the human had a turn
139
139
  * In manual turn mode, it will tick the humans stat timers & the game
140
140
  */
141
- passTurn(human: Human, turnType?: TurnTypeFlag): void;
141
+ passTurn(human: Human, turnType?: TurnTypeFlag, dueToAction?: boolean): void;
142
142
  tickRealtime(): void;
143
143
  updateTablesAndWeight(): void;
144
144
  /**
@@ -157,11 +157,11 @@ export declare class Game extends EventEmitter.Host<IGameEvents> {
157
157
  /**
158
158
  * Collection of things to perform on each tick
159
159
  */
160
- tick(ticks?: number, playingHumans?: Human[], tickFlag?: TickFlag): void;
160
+ tick(ticks?: number, playingHumans?: Human[], tickFlag?: TickFlag, dueToAction?: boolean): void;
161
161
  /**
162
162
  * Collection of things to perform on each tick
163
163
  */
164
- tickAsync(island: Island, ticks: number, playingHumans: Human[] | undefined, tickFlag: TickFlag | undefined, onProgress: (progess: number) => Promise<void>): Promise<void>;
164
+ tickAsync(island: Island, ticks: number, playingHumans: Human[] | undefined, tickFlag: TickFlag | undefined, onProgress: (progess: number) => Promise<void>, dueToAction?: boolean): Promise<void>;
165
165
  createRenderer(entity: Entity): void;
166
166
  /**
167
167
  * Resets the game state. This should be called when returning to the main menu from a game and/or right before starting/joining a game.
@@ -68,8 +68,8 @@ export interface IGameEvents {
68
68
  getBiomeType(positon: IVector2, biomeType: BiomeTypes): BiomeTypes | undefined;
69
69
  pause(): any;
70
70
  resume(): any;
71
- tickStart(tickFlag: TickFlag, ticks: number): any;
72
- tickEnd(tickFlag: TickFlag, ticks: number): any;
71
+ tickStart(tickFlag: TickFlag, ticks: number, dueToAction: boolean): any;
72
+ tickEnd(tickFlag: TickFlag, ticks: number, dueToAction: boolean): any;
73
73
  /**
74
74
  * Called when the playing entity count changes
75
75
  */
@@ -44,7 +44,7 @@ export declare const actionDescriptionsSlow: {
44
44
  63: import("./Action").Action<[import("game/entity/action/IAction").ActionArgument.ItemNearby, import("game/entity/action/IAction").ActionArgument.EquipType], import("../Human").default, boolean, import("game/entity/action/IAction").IActionUsable, [import("../../item/Item").default, import("../IHuman").EquipType]>;
45
45
  38: import("./Action").Action<[import("game/entity/action/IAction").ActionArgument.ItemInventory], import("../Human").default, void, import("game/entity/action/IAction").IActionUsable, [import("../../item/Item").default]>;
46
46
  110: import("./Action").Action<[import("game/entity/action/IAction").ActionArgument.ItemInventory, [import("game/entity/action/IAction").ActionArgument.ItemInventory, import("game/entity/action/IAction").ActionArgument.Undefined]], import("../Human").default, void, import("game/entity/action/actions/Exude").IExudeCanUse, [import("../../item/Item").default, (import("../../item/Item").default | undefined)?]>;
47
- 36: import("./Action").Action<[import("game/entity/action/IAction").ActionArgument.ItemInventory], import("../Human").default, void, import("game/entity/action/IAction").IActionUsable, [import("../../item/Item").default]>;
47
+ 36: import("./Action").Action<[import("game/entity/action/IAction").ActionArgument.ItemInventory], import("../Human").default, void, import("game/entity/action/actions/Attack").IAttackCloseUpCanUse | import("game/entity/action/actions/Attack").IAttackThrowItemCanUse | import("game/entity/action/actions/Attack").IAttackRangedWeaponCanUse, [import("../../item/Item").default]>;
48
48
  22: import("./Action").Action<[[import("game/entity/action/IAction").ActionArgument.ItemInventory, import("game/entity/action/IAction").ActionArgument.Undefined]], import("../Human").default, void, import("game/entity/action/actions/Gather").IGatherCanUse, [(import("../../item/Item").default | undefined)?]>;
49
49
  15: import("./Action").Action<[import("game/entity/action/IAction").ActionArgument.ItemNearby], import("../Human").default, void, import("game/entity/action/actions/GatherLiquid").IGatherLiquidCanUse, [import("../../item/Item").default]>;
50
50
  86: import("./Action").Action<[[import("game/entity/action/IAction").ActionArgument.ItemNearbyIncludingTradeContainer, import("game/entity/action/IAction").ActionArgument.Undefined], [import("game/entity/action/IAction").ActionArgument.Container, import("game/entity/action/IAction").ActionArgument.Undefined], [import("game/entity/action/IAction").ActionArgument.ItemType, import("game/entity/action/IAction").ActionArgument.Undefined], [import("game/entity/action/IAction").ActionArgument.Quality, import("game/entity/action/IAction").ActionArgument.Undefined], [import("game/entity/action/IAction").ActionArgument.String, import("game/entity/action/IAction").ActionArgument.Undefined]], import("../Human").default, void, import("game/entity/action/actions/MoveItem").MoveItemCanUse, [(import("../../item/Item").default | undefined)?, (import("../../item/IItem").IContainer | undefined)?, (import("../../item/IItem").ItemType | undefined)?, (import("../../IObject").Quality | undefined)?, (string | undefined)?]>;
@@ -13,5 +13,5 @@ import { ActionArgument } from "game/entity/action/IAction";
13
13
  /**
14
14
  * Firing a weapon (like a bow)
15
15
  */
16
- declare const _default: Action<[ActionArgument.ItemInventory], import("../../Human").default, void, import("game/entity/action/IAction").IActionUsable, [import("../../../item/Item").default]>;
16
+ declare const _default: Action<[ActionArgument.ItemInventory], import("../../Human").default, void, import("game/entity/action/actions/Attack").IAttackCloseUpCanUse | import("game/entity/action/actions/Attack").IAttackThrowItemCanUse | import("game/entity/action/actions/Attack").IAttackRangedWeaponCanUse, [import("../../../item/Item").default]>;
17
17
  export default _default;
@@ -23,6 +23,7 @@ import type Inspection from "game/inspection/Inspection";
23
23
  import type { Quality } from "game/IObject";
24
24
  import type { ItemType } from "game/item/IItem";
25
25
  import type Item from "game/item/Item";
26
+ import type ItemFinder from "game/item/ItemFinder";
26
27
  import type Message from "language/dictionary/Message";
27
28
  import Translation from "language/Translation";
28
29
  import type Bindable from "ui/input/Bindable";
@@ -36,8 +37,9 @@ export interface IUsableActionRequirement<TYPE> {
36
37
  find?(player: Player): TYPE | undefined;
37
38
  getMissingName?(): Translation;
38
39
  }
39
- export interface IUsableActionItemRequirement extends IUsableActionRequirement<Item> {
40
+ export interface IUsableActionItemRequirement extends Omit<IUsableActionRequirement<Item>, "find"> {
40
41
  allowOnlyItemType?(player: Player, type: ItemType): boolean;
42
+ finder?(player: Player): ItemFinder | undefined;
41
43
  }
42
44
  export declare namespace IUsableActionRequirement {
43
45
  interface Maybe<TYPE> {
@@ -66,7 +68,7 @@ export interface IUsableActionUsing<REQUIREMENTS extends IUsableActionRequiremen
66
68
  } ? undefined : never) | (REQUIREMENTS["item"] extends {
67
69
  validate(player: Player, value: Item): boolean;
68
70
  } ? Item : never) | (REQUIREMENTS["item"] extends {
69
- find(player: Player): Item;
71
+ finder: ItemFinder;
70
72
  } ? Item : never) | (REQUIREMENTS["item"] extends {
71
73
  allowOnlyItemType(player: Player, type: ItemType): boolean;
72
74
  } ? undefined : never));
@@ -75,7 +77,7 @@ export interface IUsableActionUsing<REQUIREMENTS extends IUsableActionRequiremen
75
77
  } ? undefined : never) | (REQUIREMENTS["item"] extends {
76
78
  validate(player: Player, value: Item): boolean;
77
79
  } ? ItemType | undefined : never) | (REQUIREMENTS["item"] extends {
78
- find(player: Player): Item;
80
+ finder: ItemFinder;
79
81
  } ? ItemType : never) | (REQUIREMENTS["item"] extends {
80
82
  allowOnlyItemType(player: Player, type: ItemType): boolean;
81
83
  } ? ItemType : never));
@@ -12,7 +12,6 @@ import type { ActionId, IUsableActionDefinition, IUsableActionDefinitionExecutab
12
12
  import { IUsableActionNotUsable } from "game/entity/action/usable/IUsableAction";
13
13
  import type Player from "game/entity/player/Player";
14
14
  import type { IIcon } from "game/inspection/InfoProvider";
15
- import type { IGetBestItemsOptions } from "game/item/IItemManager";
16
15
  import type Item from "game/item/Item";
17
16
  import { ActionTranslation } from "language/dictionary/Misc";
18
17
  import type Translation from "language/Translation";
@@ -47,6 +46,10 @@ declare class UsableAction<REQUIREMENTS extends IUsableActionRequirements = IUsa
47
46
  private readonly findItemCannotUse;
48
47
  getFindItemCannotUse(): IUsableActionNotUsable[];
49
48
  getItem(player: Player, provided?: IUsableActionPossibleUsing, fullUsabilityCheck?: boolean): Item | false | undefined;
49
+ private requirementsItemFinders?;
50
+ private getItemFinder;
51
+ private itemFinderFullCheck?;
52
+ private itemFinderSimpleCheck?;
50
53
  private getItemByType;
51
54
  getDoodad(player: Player, provided?: IUsableActionPossibleUsing): false | import("../../../doodad/Doodad").default | undefined;
52
55
  getCreature(player: Player, provided?: IUsableActionPossibleUsing): false | import("../../creature/Creature").default | undefined;
@@ -63,6 +66,5 @@ export interface IUsableActionFactory<REQUIREMENTS extends IUsableActionRequirem
63
66
  declare namespace UsableAction {
64
67
  function requiring<REQUIREMENTS1 extends IUsableActionRequirements>(requirements: REQUIREMENTS1): IUsableActionFactory<REQUIREMENTS1>;
65
68
  function create<DEFINITION extends IUsableActionDefinition<{}>>(action: DEFINITION): UsableAction<{}, DEFINITION>;
66
- function getBestSafeItemInInventory(player: Player, options?: Partial<IGetBestItemsOptions>): Item | undefined;
67
69
  }
68
70
  export default UsableAction;
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * Copyright 2011-2021 Unlok
3
+ * https://www.unlok.ca
4
+ *
5
+ * Credits & Thanks:
6
+ * https://www.unlok.ca/credits-thanks/
7
+ *
8
+ * Wayward is a copyrighted and licensed work. Modification and/or distribution of any source files is prohibited. If you wish to modify the game in any way, please refer to the modding guide:
9
+ * https://github.com/WaywardGame/types/wiki
10
+ */
11
+ import type Player from "game/entity/player/Player";
12
+ import type { IItemFinderOptions } from "game/item/ItemFinder";
13
+ import ItemFinder from "game/item/ItemFinder";
14
+ export default class UsableActionItemFinder extends ItemFinder {
15
+ constructor(player: Player, options?: IItemFinderOptions);
16
+ }
@@ -11,7 +11,7 @@
11
11
  import { ActionType } from "game/entity/action/IAction";
12
12
  import type { IUsableActionDynamicDefinition } from "game/entity/action/usable/actions/UsableActionsDynamic";
13
13
  import UsableActionsDynamic from "game/entity/action/usable/actions/UsableActionsDynamic";
14
- import type { IUsableActionRequirement, IUsableActionRequirements } from "game/entity/action/usable/IUsableAction";
14
+ import type { IUsableActionItemRequirement, IUsableActionRequirements } from "game/entity/action/usable/IUsableAction";
15
15
  import type { IGetBestItemsOptions } from "game/item/IItemManager";
16
16
  import type Item from "game/item/Item";
17
17
  export interface IUseItemAction extends IUsableActionDynamicDefinition {
@@ -24,7 +24,7 @@ export interface IUseItemAction extends IUsableActionDynamicDefinition {
24
24
  }
25
25
  export declare namespace IUseItemAction {
26
26
  function getGetItemOptions(actionType: ActionType, useItemAction?: Omit<IUseItemAction, keyof IUsableActionDynamicDefinition>): Partial<IGetBestItemsOptions>;
27
- function getItemRequirement(actionType: ActionType, useItemAction?: Omit<IUseItemAction, keyof IUsableActionDynamicDefinition>, getItemOptions?: Partial<IGetBestItemsOptions>): IUsableActionRequirement<Item>;
27
+ function getItemRequirement(actionType: ActionType, useItemAction?: Omit<IUseItemAction, keyof IUsableActionDynamicDefinition>, getItemOptions?: Partial<IGetBestItemsOptions>): IUsableActionItemRequirement;
28
28
  }
29
29
  declare const _default: UsableActionsDynamic<IUseItemAction, IUsableActionRequirements>;
30
30
  export default _default;
@@ -48,7 +48,7 @@ export interface IGetItemsOptions extends IGetItemOptions {
48
48
  }
49
49
  export interface IGetBestItemsOptions extends IGetItemsOptions {
50
50
  action: ActionType;
51
- actionWith: Item;
51
+ actionWith: Item | (() => Item | undefined);
52
52
  filterType: ItemType;
53
53
  filterQuality: Quality;
54
54
  filterGroup: ItemTypeGroup;
@@ -13,6 +13,10 @@ import type { IContainer } from "game/item/IItem";
13
13
  import type { IGetBestItemsOptions } from "game/item/IItemManager";
14
14
  import type Item from "game/item/Item";
15
15
  import type ItemManager from "game/item/ItemManager";
16
+ export interface IItemFinderOptions extends Partial<IGetBestItemsOptions> {
17
+ replace?(): Item[] | undefined;
18
+ fallback?: ItemFinder;
19
+ }
16
20
  export default class ItemFinder {
17
21
  private readonly options;
18
22
  private readonly human;
@@ -20,10 +24,11 @@ export default class ItemFinder {
20
24
  private trackedContainers?;
21
25
  private trackedItems?;
22
26
  private foundItemIds?;
23
- constructor(human: Human, container: IContainer, options?: Partial<IGetBestItemsOptions>);
24
- get(): Item[];
25
- track(): void;
26
- dispose(): void;
27
+ constructor(human: Human, container: IContainer, options?: IItemFinderOptions);
28
+ best(): Item | undefined;
29
+ all(): Item[];
30
+ track(): this;
31
+ dispose(): this;
27
32
  markDirty(): void;
28
33
  private compute;
29
34
  protected onItemStateChange(item: Item): void;
@@ -330,7 +330,7 @@ export default class Component<E extends HTMLElement = HTMLElement> extends Even
330
330
  protected onContextMenu(api: IBindHandlerApi): boolean;
331
331
  protected onEnter(reason: "mouse" | "focus"): void;
332
332
  private menuCancelHideTooltip;
333
- protected onLeave(reason: "mouse" | "focus"): void;
333
+ protected onLeave(reason: "mouse" | "focus" | "remove"): void;
334
334
  /**
335
335
  * @returns a promise that resolves when either the given time has passed, or this component has been removed.
336
336
  * Returns `true` if this component exists, `false` if it has been removed.
@@ -30,7 +30,7 @@ export interface IComponentEvents {
30
30
  willRemove(): boolean | void;
31
31
  regenerateBox(box: IBox): any;
32
32
  enter(reason: "mouse" | "focus"): any;
33
- leave(reason: "mouse" | "focus"): any;
33
+ leave(reason: "mouse" | "focus" | "remove"): any;
34
34
  focus(): any;
35
35
  blur(): any;
36
36
  removeContextMenu(): any;
@@ -121,8 +121,11 @@ export default class InGameScreen extends BaseScreen {
121
121
  clampDialogs(): void;
122
122
  getItemClass(item?: Item, itemType?: ItemType): string;
123
123
  createItemString(itemType: ItemType, item?: Item, extraClass?: string): string;
124
+ private readonly itemElementsCollections;
124
125
  getItemElements(item: Item | number): HTMLCollectionOf<HTMLElement>;
125
126
  syncItemElements(itemIds: number | number[], forceSyncDecay?: boolean): void;
127
+ private readonly SYMBOL_LAST_NEARLY_DESTROYED;
128
+ private readonly SYMBOL_LAST_NEARLY_DECAYED;
126
129
  private readonly SYMBOL_LAST_DECAY;
127
130
  syncDecayBar(item: Item, force?: boolean, elements?: HTMLCollectionOf<HTMLElement>): void;
128
131
  addItemToContainer(item: Item, container: IContainer, _internal?: boolean, isAddingMultipleItems?: boolean, updateTables?: boolean): void;
@@ -123,4 +123,6 @@ export default class ItemComponent extends Component {
123
123
  private refreshDecayBar;
124
124
  private lastDurability;
125
125
  private refreshDurabilityBar;
126
+ private lastActionIcon?;
127
+ private refreshActionIcon;
126
128
  }
@@ -12,6 +12,8 @@ import type { Events, IEventEmitter } from "event/EventEmitter";
12
12
  import type { IActionApi } from "game/entity/action/IAction";
13
13
  import type { IUsableActionPossibleUsing, IUsableActionRequirements, ReturnableUsableActionUsability } from "game/entity/action/usable/IUsableAction";
14
14
  import type Player from "game/entity/player/Player";
15
+ import type { Game } from "game/Game";
16
+ import type { TickFlag } from "game/IGame";
15
17
  import type Item from "game/item/Item";
16
18
  import Button from "ui/component/Button";
17
19
  import Component from "ui/component/Component";
@@ -111,6 +113,7 @@ export declare class ActionSlot extends Button implements IRefreshable {
111
113
  configure(emitToActionBar?: boolean): void;
112
114
  protected onAppend(): void;
113
115
  protected onItemMaybeInaccessible(): void;
116
+ protected onTickEnd(game: Game, tickFlag: TickFlag, ticks: number, dueToAction: boolean): void;
114
117
  postExecuteAction(action: IActionApi): void;
115
118
  protected playSound(): void;
116
119
  private lastClickUseWhenMoving;
@@ -121,7 +124,7 @@ export declare class ActionSlot extends Button implements IRefreshable {
121
124
  onActivate(nonClick?: IBindHandlerApi | true, silent?: true): boolean;
122
125
  protected onGetOrRemoveItemInInventory(player: Player, item: Item): void;
123
126
  onToggle(api: IBindHandlerApi): boolean;
124
- protected onLeave(reason: "mouse" | "focus"): void;
127
+ protected onLeave(reason: "mouse" | "focus" | "remove"): void;
125
128
  private getTooltipLocation;
126
129
  getAction(): import("../../../../../game/entity/action/usable/UsableAction").default<IUsableActionRequirements, import("game/entity/action/usable/IUsableAction").IUsableActionDefinition<IUsableActionRequirements>> | undefined;
127
130
  getUsing(): IUsableActionPossibleUsing;
@@ -35,6 +35,7 @@ export default class ImagePath<PATHTYPE extends PathType = PathType> {
35
35
  private readonly applications;
36
36
  private args?;
37
37
  private constructor();
38
+ static equals(imagePath?: ImagePath | ISerializedImagePath | string, imagePath2?: ImagePath | ISerializedImagePath | string): boolean;
38
39
  serialize(): ISerializedImagePath;
39
40
  setExtension(extension?: string): this;
40
41
  setArgs(args?: ResourceOptionsMap[PATHTYPE]): this;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wayward/types",
3
3
  "description": "TypeScript declarations for Wayward, used for modding.",
4
- "version": "2.12.0-beta.dev.20220927.1",
4
+ "version": "2.12.0-beta.dev.20220929.2",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",