Skip to content

Commit

Permalink
allow to control affected_by_reveal propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed Sep 1, 2023
1 parent 88fdabd commit 2e5c1cf
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 14 deletions.
1 change: 1 addition & 0 deletions assets/dbs/interactable_objects_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
},{
"type": "jump",
"active": false,
"dont_propagate_affected_by_reveal": true,
"x_shift": 0,
"y_shift": -2
}],
Expand Down
3 changes: 3 additions & 0 deletions base/debug/Debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ export class Debug {
activation_directions: Array.from(event.activation_directions).map(
dir => reverse_directions[dir]
),
initial_activation_directions: Array.from(event.initial_activation_directions).map(
dir => reverse_directions[dir]
),
activation_collision_layers: Array.from(event.activation_collision_layers),
...(event.origin_interactable_object && {
origin_interactable_object: `[${event.origin_interactable_object.key_name}${
Expand Down
2 changes: 1 addition & 1 deletion base/field_abilities/FrostFieldPsynergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class FrostFieldPsynergy extends FieldAbilities {
if (event.is_active_at_direction()) {
event.deactivate();
} else {
event.activate();
event.activate(this.target_object.affected_by_reveal);
event.activation_collision_layers.forEach(collision_layer => {
this.data.map.set_collision_in_tile(event.x, event.y, false, collision_layer);
});
Expand Down
67 changes: 55 additions & 12 deletions base/interactable_objects/InteractableObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -916,18 +916,51 @@ export class InteractableObjects {
const collision_layer_shift = this.tile_events_info[i]?.collision_layer_shift ?? 0;
const active_event = this.active ? event_info.active ?? true : false;
const target_layer = this.base_collision_layer + collision_layer_shift;
const dont_propagate_affected_by_reveal = event_info.dont_propagate_affected_by_reveal ?? false;
switch (event_info.type) {
case interactable_object_event_types.JUMP:
this.set_jump_type_event(i, x_pos, y_pos, active_event, target_layer, map);
this.set_jump_type_event(
i,
x_pos,
y_pos,
active_event,
target_layer,
map,
dont_propagate_affected_by_reveal
);
break;
case interactable_object_event_types.JUMP_AROUND:
this.set_jump_around_event(x_pos, y_pos, active_event, target_layer, map);
this.set_jump_around_event(
x_pos,
y_pos,
active_event,
target_layer,
map,
dont_propagate_affected_by_reveal
);
break;
case interactable_object_event_types.CLIMB:
this.set_stair_event(i, event_info, x_pos, y_pos, active_event, target_layer, map);
this.set_stair_event(
i,
event_info,
x_pos,
y_pos,
active_event,
target_layer,
map,
dont_propagate_affected_by_reveal
);
break;
case interactable_object_event_types.ROPE:
this.set_rope_event(event_info, x_pos, y_pos, active_event, target_layer, map);
this.set_rope_event(
event_info,
x_pos,
y_pos,
active_event,
target_layer,
map,
dont_propagate_affected_by_reveal
);
break;
}
}
Expand Down Expand Up @@ -973,7 +1006,8 @@ export class InteractableObjects {
y_pos: number,
active_event: boolean,
target_layer: number,
map: Map
map: Map,
dont_propagate_affected_by_reveal: boolean
) {
if (this.not_allowed_tile_test(x_pos, y_pos)) return;
const activation_directions = [
Expand All @@ -992,7 +1026,7 @@ export class InteractableObjects {
[target_layer],
undefined,
this,
this.affected_by_reveal,
dont_propagate_affected_by_reveal ? false : this.affected_by_reveal,
undefined,
undefined
);
Expand Down Expand Up @@ -1023,7 +1057,8 @@ export class InteractableObjects {
y_pos: number,
active_event: boolean,
target_layer: number,
map: Map
map: Map,
dont_propagate_affected_by_reveal: boolean
) {
const activation_directions =
event_info.activation_directions ?? get_directions(false).map(dir => reverse_directions[dir]);
Expand Down Expand Up @@ -1065,7 +1100,7 @@ export class InteractableObjects {
active_event ? undefined : activation_direction,
activation_collision_layer,
undefined,
this.affected_by_reveal,
dont_propagate_affected_by_reveal ? false : this.affected_by_reveal,
event_info.key_name,
this,
event_info.walk_over_rope,
Expand All @@ -1081,7 +1116,14 @@ export class InteractableObjects {
});
}

private set_jump_around_event(x_pos: number, y_pos: number, active_event: boolean, target_layer: number, map: Map) {
private set_jump_around_event(
x_pos: number,
y_pos: number,
active_event: boolean,
target_layer: number,
map: Map,
dont_propagate_affected_by_reveal: boolean
) {
get_surroundings(x_pos, y_pos).forEach((pos, index) => {
if (this.not_allowed_tile_test(pos.x, pos.y)) return;
const activation_direction = [
Expand All @@ -1100,7 +1142,7 @@ export class InteractableObjects {
[target_layer],
undefined,
this,
this.affected_by_reveal,
dont_propagate_affected_by_reveal ? false : this.affected_by_reveal,
undefined,
undefined
) as JumpEvent;
Expand All @@ -1123,7 +1165,8 @@ export class InteractableObjects {
y_pos: number,
active_event: boolean,
target_layer: number,
map: Map
map: Map,
dont_propagate_affected_by_reveal: boolean
) {
const collision_layer_shift = this.tile_events_info[event_index]?.collision_layer_shift ?? 0;
const intermediate_collision_layer_shift =
Expand Down Expand Up @@ -1200,7 +1243,7 @@ export class InteractableObjects {
active_event ? undefined : event_data.activation_directions,
event_data.activation_collision_layers,
undefined,
this.affected_by_reveal,
dont_propagate_affected_by_reveal ? false : this.affected_by_reveal,
undefined,
event_data.change_to_collision_layer,
this,
Expand Down
10 changes: 9 additions & 1 deletion base/tile_events/TileEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export abstract class TileEvent {
get activation_collision_layers() {
return this._activation_collision_layers;
}
/** The set of directions that this event can be fired when it was created. */
get initial_activation_directions() {
return this._initial_activation_directions;
}
/** The interactable object that created this event (in the case of it has been created from it). */
get origin_interactable_object() {
return this._origin_interactable_object;
Expand Down Expand Up @@ -244,9 +248,13 @@ export abstract class TileEvent {

/**
* Activates this event in all initial directions.
* @param include_affected_by_reveal if true, it will also make this event sensible to reveal.
*/
activate() {
activate(include_affected_by_reveal: boolean = false) {
this._activation_directions = new Set(this._initial_activation_directions);
if (include_affected_by_reveal) {
this._affected_by_reveal = new Set(this._initial_activation_directions);
}
}

/**
Expand Down

0 comments on commit 2e5c1cf

Please sign in to comment.