Skip to content

Commit

Permalink
tile event manager: add remove_from_field
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed Jan 8, 2024
1 parent f3bfd94 commit ee2aa3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion base/game_events/GameEventManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ export class GameEventManager {
info.io_label,
info.activate_at,
info.pos,
info.collision_layers
info.collision_layers,
info.remove_from_field
);
case event_types.DESTROYER:
return new DestroyerEvent(
Expand Down
11 changes: 9 additions & 2 deletions base/game_events/TileEventManageEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class TileEventManageEvent extends GameEvent {
private activate_at: {[direction: string]: boolean};
private pos: {x: number; y: number};
private collision_layers: number[];
private remove_from_field: boolean;

constructor(
game,
Expand All @@ -19,20 +20,22 @@ export class TileEventManageEvent extends GameEvent {
io_label,
activate_at,
pos,
collision_layers
collision_layers,
remove_from_field
) {
super(game, data, event_types.TILE_EVENT_MANAGE, active, key_name, keep_reveal);
this.tile_event_key = tile_event_key;
this.io_label = io_label;
this.activate_at = activate_at;
this.remove_from_field = remove_from_field;
this.pos = pos;
if (collision_layers !== undefined) {
this.collision_layers = Array.isArray(collision_layers) ? collision_layers : [collision_layers];
}
}

_fire() {
let events = [];
let events: TileEvent[] = [];
if (this.tile_event_key) {
const event = TileEvent.get_labeled_event(this.tile_event_key);
if (event) {
Expand Down Expand Up @@ -87,6 +90,10 @@ export class TileEventManageEvent extends GameEvent {
if (this.pos) {
event.set_position(this.pos.x, this.pos.y, true);
}

if (this.remove_from_field) {
this.data.map.remove_event(event.location_key, event.id);
}
}
}

Expand Down

0 comments on commit ee2aa3d

Please sign in to comment.