-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
190 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import {ControllableChar} from "../ControllableChar"; | ||
import {GameEvent, event_types} from "./GameEvent"; | ||
|
||
export class CharFallEvent extends GameEvent { | ||
private is_npc: boolean; | ||
private npc_label: string; | ||
private options: Parameters<ControllableChar["fall"]>[0]; | ||
private finish_events: GameEvent[]; | ||
|
||
constructor( | ||
game, | ||
data, | ||
active, | ||
key_name, | ||
keep_reveal, | ||
is_npc, | ||
npc_label, | ||
y_destination_position, | ||
dest_collision_layer, | ||
show_exclamation_emoticon, | ||
splash_sweat_drops, | ||
walking_in_the_air, | ||
ground_hit_animation, | ||
teleport, | ||
finish_events | ||
) { | ||
super(game, data, event_types.CHAR_FALL, active, key_name, keep_reveal); | ||
this.is_npc = is_npc; | ||
this.npc_label = npc_label; | ||
this.options = { | ||
y_destination_position: y_destination_position, | ||
dest_collision_layer: dest_collision_layer, | ||
show_exclamation_emoticon: show_exclamation_emoticon, | ||
splash_sweat_drops: splash_sweat_drops, | ||
walking_in_the_air: walking_in_the_air, | ||
ground_hit_animation: ground_hit_animation, | ||
teleport: teleport, | ||
}; | ||
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) { | ||
++this.data.game_event_manager.events_running_count; | ||
const target_obj = Object.assign({}, this.options, { | ||
on_fall_finish_callback: () => { | ||
if (!this.options.teleport) { | ||
--this.data.game_event_manager.events_running_count; | ||
this.finish_events.forEach(event => event.fire(this.origin_npc)); | ||
} | ||
}, | ||
}); | ||
if (target_obj.teleport) { | ||
target_obj.teleport.on_before_teleport = () => { | ||
this.data.game_event_manager.events_running_count = 0; | ||
}; | ||
} | ||
target_char.fall(target_obj); | ||
} | ||
} | ||
|
||
_destroy() { | ||
this.finish_events.forEach(event => event?.destroy()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import {ControllableChar} from "../ControllableChar"; | ||
import {event_types, TileEvent} from "./TileEvent"; | ||
|
||
export class FallEvent extends TileEvent { | ||
private options: Parameters<ControllableChar["fall"]>[0]; | ||
|
||
constructor( | ||
game, | ||
data, | ||
x, | ||
y, | ||
activation_directions, | ||
initial_disabled_directions, | ||
activation_collision_layers, | ||
active_storage_key, | ||
affected_by_reveal, | ||
key_name: string, | ||
y_destination_position, | ||
dest_collision_layer, | ||
show_exclamation_emoticon, | ||
splash_sweat_drops, | ||
walking_in_the_air, | ||
ground_hit_animation, | ||
teleport | ||
) { | ||
super( | ||
game, | ||
data, | ||
event_types.FALL, | ||
x, | ||
y, | ||
activation_directions, | ||
initial_disabled_directions, | ||
activation_collision_layers, | ||
active_storage_key, | ||
null, | ||
affected_by_reveal, | ||
key_name | ||
); | ||
this.options = { | ||
y_destination_position: y_destination_position, | ||
dest_collision_layer: dest_collision_layer, | ||
show_exclamation_emoticon: show_exclamation_emoticon, | ||
splash_sweat_drops: splash_sweat_drops, | ||
walking_in_the_air: walking_in_the_air, | ||
ground_hit_animation: ground_hit_animation, | ||
teleport: teleport, | ||
}; | ||
} | ||
|
||
fire() { | ||
if (!this.check_position() || !this.data.hero_movement_allowed()) { | ||
return; | ||
} | ||
this.data.hero.fall(this.options); | ||
} | ||
|
||
destroy() { | ||
this.deactivate(); | ||
this._origin_interactable_object = null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters