Skip to content

Commit

Permalink
robust event destroy check
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed May 28, 2023
1 parent 75f64f2 commit 0799c4a
Show file tree
Hide file tree
Showing 28 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion base/Map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@ export class Map {
if (this.show_footsteps) {
this.data.hero.footsteps.clean_all();
}
this.game_events.forEach(event => event.destroy());
this.game_events.forEach(event => event?.destroy());

this.data.collision.clear_custom_bodies();

Expand Down
2 changes: 1 addition & 1 deletion base/NPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ export class NPC extends ControllableChar {
this.footsteps.destroy();
}
this.unset_push_timer();
this._events.forEach(event => event.destroy());
this._events.forEach(event => event?.destroy());
this.look_target = null;
this.clear_snapshot();
}
Expand Down
2 changes: 1 addition & 1 deletion base/game_events/AudioPlayEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ export class AudioPlayEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
}
}
8 changes: 4 additions & 4 deletions base/game_events/BattleEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ export class BattleEvent extends GameEvent {

_destroy() {
this.battle = null;
this.victory_events.forEach(event => event.destroy());
this.defeat_events.forEach(event => event.destroy());
this.before_fade_defeat_events.forEach(event => event.destroy());
this.before_fade_victory_events.forEach(event => event.destroy());
this.victory_events.forEach(event => event?.destroy());
this.defeat_events.forEach(event => event?.destroy());
this.before_fade_defeat_events.forEach(event => event?.destroy());
this.before_fade_victory_events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/game_events/BranchEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ export class BranchEvent extends GameEvent {
}

_destroy() {
this.events.forEach(event => event.destroy());
this.events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/game_events/CameraFadeEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ export class CameraFadeEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/game_events/CameraFollowEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ export class CameraFollowEvent extends GameEvent {
}

_destroy() {
this.transition_end_events.forEach(event => event.destroy());
this.transition_end_events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/game_events/CameraMoveEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ export class CameraMoveEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/game_events/CharAnimPlayEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ export class CharAnimPlayEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
}
}
4 changes: 2 additions & 2 deletions base/game_events/ChestEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ export class ChestEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.inventory_full_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
this.inventory_full_events.forEach(event => event?.destroy());
this.dialog_manager?.destroy();
if (this.control_key !== null) {
this.data.control_manager.detach_bindings(this.control_key);
Expand Down
2 changes: 1 addition & 1 deletion base/game_events/ColorizeMapEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ export class ColorizeMapEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
}
}
6 changes: 3 additions & 3 deletions base/game_events/DialogEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ export class DialogEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.yes_no_events.yes.forEach(event => event.destroy());
this.yes_no_events.no.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
this.yes_no_events.yes.forEach(event => event?.destroy());
this.yes_no_events.no.forEach(event => event?.destroy());
this.dialog_index = 0;
this.yes_no_menu?.destroy();
this.yes_no_menu = null;
Expand Down
4 changes: 2 additions & 2 deletions base/game_events/DjinnGetEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,8 @@ export class DjinnGetEvent extends GameEvent {

_destroy() {
this.djinn = null;
this.finish_events.forEach(event => event.destroy());
this.on_battle_defeat_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
this.on_battle_defeat_events.forEach(event => event?.destroy());
this.dialog_manager?.destroy();
this.dialog_manager = null;
this.data.control_manager.detach_bindings(this.control_key);
Expand Down
2 changes: 1 addition & 1 deletion base/game_events/EmoticonEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class EmoticonEvent extends GameEvent {
* Unsets this event.
*/
_destroy() {
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
this.char = null;
}
}
2 changes: 1 addition & 1 deletion base/game_events/EventsHolderEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export class EventsHolderEvent extends GameEvent {
}

_destroy() {
this.events.forEach(event => event.destroy());
this.events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/game_events/EventsLoopEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ export class EventsLoopEvent extends GameEvent {
_destroy() {
this.loop_timer.stop();
this.loop_timer.destroy();
this.events.forEach(event => event.destroy());
this.events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/game_events/FaceDirectionEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ export class FaceDirectionEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/game_events/IOAnimPlayEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ export class IOAnimPlayEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
}
}
4 changes: 2 additions & 2 deletions base/game_events/ItemChecksEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class ItemChecksEvent extends GameEvent {
}

_destroy() {
this.check_ok_events.forEach(event => event.destroy());
this.check_fail_events.forEach(event => event.destroy());
this.check_ok_events.forEach(event => event?.destroy());
this.check_fail_events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/game_events/JumpEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ export class JumpEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/game_events/MapOpacityEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ export class MapOpacityEvent extends GameEvent {

_destroy() {
this.map_layer = null;
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/game_events/MoveEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,6 @@ export class MoveEvent extends GameEvent {

_destroy() {
this.previous_camera_target = null;
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/game_events/PartyJoinEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class PartyJoinEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
this.dialog_manager?.destroy();
if (this.control_key !== null) {
this.data.control_manager.detach_bindings(this.control_key);
Expand Down
2 changes: 1 addition & 1 deletion base/game_events/PsynergyStoneEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class PsynergyStoneEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
this.dialog_manager?.destroy();
this.dialog_manager = null;
if (this.control_key !== null) {
Expand Down
2 changes: 1 addition & 1 deletion base/game_events/StorageChangeEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ export class StorageChangeEvent extends GameEvent {
ids.forEach(id => this.data.storage.remove_callback(state_key, id));
}
this.callback_ids = null;
this.change_events.forEach(event => event.destroy());
this.change_events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/game_events/SummonEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export class SummonEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
this.dialog?.destroy();
this.emitter?.destroy();
this.letters = null;
Expand Down
2 changes: 1 addition & 1 deletion base/game_events/TimerEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export class TimerEvent extends GameEvent {
}

_destroy() {
this.finish_events.forEach(event => event.destroy());
this.finish_events.forEach(event => event?.destroy());
}
}
2 changes: 1 addition & 1 deletion base/tile_events/EventTriggerEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ export class EventTriggerEvent extends TileEvent {
destroy() {
this.deactivate();
this._origin_interactable_object = null;
this.events.forEach(event => event.destroy());
this.events.forEach(event => event?.destroy());
}
}

0 comments on commit 0799c4a

Please sign in to comment.