|
| 1 | +import { ActionHook, ActionType } from '@engine/action'; |
| 2 | +import { Quest } from '@engine/world/actor/player/quest'; |
| 3 | + |
| 4 | +// Base hook type that all hook types must extend |
| 5 | +export interface BaseHook { |
| 6 | + type: ActionType; |
| 7 | + handler: (...args: any[]) => any; |
| 8 | +} |
| 9 | + |
| 10 | +// Object interaction hook type |
| 11 | +export interface ObjectInteractionHook extends BaseHook { |
| 12 | + type: 'object_interaction'; |
| 13 | + objectIds: number[]; |
| 14 | + options?: string[]; |
| 15 | + walkTo?: boolean; |
| 16 | +} |
| 17 | + |
| 18 | +// Button interaction hook type |
| 19 | +export interface ButtonHook extends BaseHook { |
| 20 | + type: 'button'; |
| 21 | + widgetId: number; |
| 22 | + buttonIds: number[]; |
| 23 | +} |
| 24 | + |
| 25 | +// Widget interaction hook type |
| 26 | +export interface WidgetInteractionHook extends BaseHook { |
| 27 | + type: 'widget_interaction'; |
| 28 | + widgetIds: number | number[]; |
| 29 | + childIds?: number | number[]; |
| 30 | + optionId?: number; |
| 31 | +} |
| 32 | + |
| 33 | +// NPC interaction hook type |
| 34 | +export interface NpcInteractionHook extends BaseHook { |
| 35 | + type: 'npc_interaction'; |
| 36 | + npcs?: string | string[]; |
| 37 | + options?: string | string[]; |
| 38 | + walkTo: boolean; |
| 39 | +} |
| 40 | + |
| 41 | +// Item interaction hook type |
| 42 | +export interface ItemInteractionHook extends BaseHook { |
| 43 | + type: 'item_interaction'; |
| 44 | + itemIds?: number | number[]; |
| 45 | + widgets?: { widgetId: number, containerId: number } | { widgetId: number, containerId: number }[]; |
| 46 | + options?: string | string[]; |
| 47 | +} |
| 48 | + |
| 49 | +// Item-on-object hook type |
| 50 | +export interface ItemOnObjectHook extends BaseHook { |
| 51 | + type: 'item_on_object'; |
| 52 | + objectIds: number | number[]; |
| 53 | + itemIds: number | number[]; |
| 54 | + walkTo: boolean; |
| 55 | +} |
| 56 | + |
| 57 | +// Item-on-NPC hook type |
| 58 | +export interface ItemOnNpcHook extends BaseHook { |
| 59 | + type: 'item_on_npc'; |
| 60 | + npcs: string | string[]; |
| 61 | + itemIds: number | number[]; |
| 62 | + walkTo: boolean; |
| 63 | +} |
| 64 | + |
| 65 | +// Item-on-player hook type |
| 66 | +export interface ItemOnPlayerHook extends BaseHook { |
| 67 | + type: 'item_on_player'; |
| 68 | + itemIds: number | number[]; |
| 69 | + walkTo: boolean; |
| 70 | +} |
| 71 | + |
| 72 | +// Item-on-item hook type |
| 73 | +export interface ItemOnItemHook extends BaseHook { |
| 74 | + type: 'item_on_item'; |
| 75 | + items: { item1: number, item2?: number }[]; |
| 76 | +} |
| 77 | + |
| 78 | +// Player/NPC init hook type |
| 79 | +export interface InitHook extends BaseHook { |
| 80 | + type: 'player_init' | 'npc_init'; |
| 81 | +} |
| 82 | + |
| 83 | +// Player command hook type |
| 84 | +export interface PlayerCommandHook extends BaseHook { |
| 85 | + type: 'player_command'; |
| 86 | + commands: string | string[]; |
| 87 | + args?: { |
| 88 | + name: string; |
| 89 | + type: 'number' | 'string' | 'either'; |
| 90 | + defaultValue?: number | string; |
| 91 | + }[]; |
| 92 | +} |
| 93 | + |
| 94 | +// Player interaction hook type |
| 95 | +export interface PlayerInteractionHook extends BaseHook { |
| 96 | + type: 'player_interaction'; |
| 97 | + options: string | string[]; |
| 98 | + walkTo: boolean; |
| 99 | +} |
| 100 | + |
| 101 | +// Region change hook type |
| 102 | +export interface RegionChangeHook extends BaseHook { |
| 103 | + type: 'region_change'; |
| 104 | + regionType?: string; |
| 105 | + regionTypes?: string[]; |
| 106 | + teleporting?: boolean; |
| 107 | +} |
| 108 | + |
| 109 | +// Equipment change hook type |
| 110 | +export interface EquipmentChangeHook extends BaseHook { |
| 111 | + type: 'equipment_change'; |
| 112 | + itemIds?: number | number[]; |
| 113 | + eventType?: 'equip' | 'unequip'; |
| 114 | +} |
| 115 | + |
| 116 | +// Item swap hook type |
| 117 | +export interface ItemSwapHook extends BaseHook { |
| 118 | + type: 'item_swap'; |
| 119 | + widgetId?: number; |
| 120 | + widgetIds?: number[]; |
| 121 | +} |
| 122 | + |
| 123 | +// Move item hook type |
| 124 | +export interface MoveItemHook extends BaseHook { |
| 125 | + type: 'move_item'; |
| 126 | + widgetId?: number; |
| 127 | + widgetIds?: number[]; |
| 128 | +} |
| 129 | + |
| 130 | +// Item on world item hook type |
| 131 | +export interface ItemOnWorldItemHook extends BaseHook { |
| 132 | + type: 'item_on_world_item'; |
| 133 | + items: { item?: number, worldItem?: number }[]; |
| 134 | +} |
| 135 | + |
| 136 | +// Spawned item interaction hook type |
| 137 | +export interface SpawnedItemInteractionHook extends BaseHook { |
| 138 | + type: 'spawned_item_interaction'; |
| 139 | + itemIds?: number | number[]; |
| 140 | + options: string | string[]; |
| 141 | + walkTo: boolean; |
| 142 | +} |
| 143 | + |
| 144 | +// Magic on item hook type |
| 145 | +export interface MagicOnItemHook extends BaseHook { |
| 146 | + type: 'magic_on_item'; |
| 147 | + itemIds?: number | number[]; |
| 148 | + spellIds?: number | number[]; |
| 149 | +} |
| 150 | + |
| 151 | +// Magic on player hook type |
| 152 | +export interface MagicOnPlayerHook extends BaseHook { |
| 153 | + type: 'magic_on_player'; |
| 154 | + spellIds?: number | number[]; |
| 155 | +} |
| 156 | + |
| 157 | +// Magic on NPC hook type |
| 158 | +export interface MagicOnNpcHook extends BaseHook { |
| 159 | + type: 'magic_on_npc'; |
| 160 | + npcs?: string | string[]; |
| 161 | + spellIds?: number | number[]; |
| 162 | +} |
| 163 | + |
| 164 | +// Prayer hook type |
| 165 | +export interface PrayerHook extends BaseHook { |
| 166 | + type: 'prayer'; |
| 167 | + prayers?: number | number[]; |
| 168 | +} |
| 169 | + |
| 170 | + |
| 171 | +// Union of all possible hook types |
| 172 | +export type PluginHook = |
| 173 | + | ObjectInteractionHook |
| 174 | + | ButtonHook |
| 175 | + | WidgetInteractionHook |
| 176 | + | NpcInteractionHook |
| 177 | + | ItemInteractionHook |
| 178 | + | ItemOnObjectHook |
| 179 | + | ItemOnNpcHook |
| 180 | + | ItemOnPlayerHook |
| 181 | + | ItemOnItemHook |
| 182 | + | ItemOnWorldItemHook |
| 183 | + | ItemSwapHook |
| 184 | + | MoveItemHook |
| 185 | + | SpawnedItemInteractionHook |
| 186 | + | MagicOnItemHook |
| 187 | + | MagicOnPlayerHook |
| 188 | + | MagicOnNpcHook |
| 189 | + | InitHook |
| 190 | + | PlayerCommandHook |
| 191 | + | PlayerInteractionHook |
| 192 | + | RegionChangeHook |
| 193 | + | EquipmentChangeHook |
| 194 | + | PrayerHook; |
| 195 | + |
| 196 | +// Main plugin type |
| 197 | +export interface ContentPlugin { |
| 198 | + // Unique identifier for the plugin |
| 199 | + pluginId: string; |
| 200 | + |
| 201 | + // Array of hooks this plugin provides |
| 202 | + hooks?: PluginHook[]; |
| 203 | + |
| 204 | + // Optional quests defined by this plugin |
| 205 | + quests?: Quest[]; |
| 206 | + |
| 207 | + // Optional plugin configuration |
| 208 | + config?: { |
| 209 | + // Whether the plugin can be hot-reloaded |
| 210 | + reloadable?: boolean; |
| 211 | + |
| 212 | + // Plugin dependencies |
| 213 | + dependencies?: string[]; |
| 214 | + |
| 215 | + // Plugin load priority (higher numbers load first) |
| 216 | + priority?: number; |
| 217 | + }; |
| 218 | +} |
0 commit comments