Skip to content

Commit

Permalink
new splash_sweat_drops event
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed Mar 14, 2024
1 parent 1237e85 commit b1a0960
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
49 changes: 49 additions & 0 deletions base/game_events/CharSplashSweatDropsEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import {GameEvent, event_types} from "./GameEvent";

export class CharSplashSweatDropsEvent extends GameEvent {
private is_npc: boolean;
private npc_label: string;
private times: number;
private finish_events: GameEvent[];

constructor(
game,
data,
active,
key_name,
keep_reveal,
keep_custom_psynergy,
is_npc,
npc_label,
times,
finish_events
) {
super(game, data, event_types.SPLASH_SWEAT_DROPS, active, key_name, keep_reveal, keep_custom_psynergy);
this.times = times;
this.is_npc = is_npc;
this.npc_label = npc_label;
this.finish_events = [];
if (finish_events !== undefined) {
finish_events.forEach(event_info => {
const event = this.data.game_event_manager.get_event_instance(event_info, this.type, this.origin_npc);
this.finish_events.push(event);
});
}
}

async _fire() {
const target_char =
GameEvent.get_char(this.data, {
is_npc: this.is_npc,
npc_label: this.npc_label,
}) ?? this.origin_npc;
if (target_char) {
await target_char.splash_sweat_drops(this.times);
this.finish_events.forEach(event => event.fire(this.origin_npc));
}
}

_destroy() {
this.finish_events.forEach(event => event?.destroy());
}
}
1 change: 1 addition & 0 deletions base/game_events/GameEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export enum event_types {
CHAR_FALL = "char_fall",
SET_CHAR_HP_PP = "set_char_hp_pp",
AUDIO_STOP = "audio_stop",
SPLASH_SWEAT_DROPS = "splash_sweat_drops",
}

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 @@ -88,6 +88,7 @@ import {ExitSandModeEvent} from "./ExitSandModeEvent";
import {CharFallEvent} from "./CharFallEvent";
import {SetCharHPPPEvent} from "./SetCharHPPPEvent";
import {AudioStopEvent} from "./AudioStopEvent";
import {CharSplashSweatDropsEvent} from "./CharSplashSweatDropsEvent";

export enum interaction_patterns {
NO_INTERACTION = "no_interaction",
Expand Down Expand Up @@ -1363,6 +1364,19 @@ export class GameEventManager {
info.fade_out,
info.bgm_identifier
);
case event_types.SPLASH_SWEAT_DROPS:
return new CharSplashSweatDropsEvent(
this.game,
this.data,
info.active,
info.key_name,
info.keep_reveal,
info.keep_custom_psynergy,
info.is_npc,
info.npc_label,
info.times,
info.finish_events
);
default:
const origin = `Event origin: ${event_origin}. ${
entity_origin?.label
Expand Down

0 comments on commit b1a0960

Please sign in to comment.