diff --git a/base/game_events/GameEvent.ts b/base/game_events/GameEvent.ts index 37e14c6ff2..f3861043de 100644 --- a/base/game_events/GameEvent.ts +++ b/base/game_events/GameEvent.ts @@ -104,6 +104,7 @@ export enum event_types { MAIN_CHARS_JOIN_SPLIT = "main_chars_join_split", SET_IO_VISIBILITY = "set_io_visibility", SET_IO_ACTIVATION = "set_io_activation", + TELEPORT = "teleport", } export enum game_event_misc_origin { diff --git a/base/game_events/GameEventManager.ts b/base/game_events/GameEventManager.ts index 1e4acb0914..4e805c3ddd 100644 --- a/base/game_events/GameEventManager.ts +++ b/base/game_events/GameEventManager.ts @@ -78,6 +78,7 @@ import {LayerVisibilityEvent} from "./LayerVisibilityEvent"; import {MainCharsJoinSplitEvent} from "./MainCharsJoinSplitEvent"; import {SetIoVisibilityEvent} from "./SetIoVisibilityEvent"; import {SetIoActivationEvent} from "./SetIoActivationEvent"; +import {TeleportEvent} from "./TeleportEvent"; export enum interaction_patterns { NO_INTERACTION = "no_interaction", @@ -1113,6 +1114,19 @@ export class GameEventManager { info.io_label, info.io_active ); + case event_types.TELEPORT: + return new TeleportEvent( + this.game, + this.data, + info.active, + info.key_name, + info.keep_reveal, + info.target_map_key, + info.target_tile_position, + info.target_collision_layer, + info.target_direction, + info.keep_encounter_cumulator + ); default: const origin = `Event origin: ${event_origin}. ${ entity_origin?.label diff --git a/base/game_events/TeleportEvent.ts b/base/game_events/TeleportEvent.ts new file mode 100644 index 0000000000..c4610cb6b5 --- /dev/null +++ b/base/game_events/TeleportEvent.ts @@ -0,0 +1,65 @@ +import {TeleportEvent as TileTeleportEvent} from "../tile_events/TeleportEvent"; +import {GameEvent, event_types} from "./GameEvent"; + +export class TeleportEvent extends GameEvent { + private target_map_key: string; + private target_tile_position: {x: number; y: number}; + private target_collision_layer: number; + private target_direction: string; + private keep_encounter_cumulator: boolean; + + constructor( + game, + data, + active, + key_name, + keep_reveal, + target_map_key, + target_tile_position, + target_collision_layer, + target_direction, + keep_encounter_cumulator + ) { + super(game, data, event_types.TELEPORT, active, key_name, keep_reveal); + this.target_map_key = target_map_key; + this.target_tile_position = target_tile_position; + this.target_collision_layer = target_collision_layer; + this.target_direction = target_direction; + this.keep_encounter_cumulator = keep_encounter_cumulator ?? true; + } + + _fire() { + const event = new TileTeleportEvent( + this.game, + this.data, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + false, + undefined, + this.target_map_key, + this.target_tile_position.x, + this.target_tile_position.y, + false, + false, + false, + this.target_collision_layer, + this.target_direction, + this.keep_encounter_cumulator, + true, + true, + false, + false, + undefined, + undefined, + undefined, + undefined + ); + event.fire(); + } + + _destroy() {} +}