Skip to content

Commit

Permalink
game teleport event
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed Sep 18, 2023
1 parent d73391e commit cdf1bec
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/game_events/GameEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 14 additions & 0 deletions base/game_events/GameEventManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
65 changes: 65 additions & 0 deletions base/game_events/TeleportEvent.ts
Original file line number Diff line number Diff line change
@@ -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() {}
}

0 comments on commit cdf1bec

Please sign in to comment.