Skip to content

Commit

Permalink
fixing bug with check_collision_structures logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed Sep 7, 2023
1 parent 681c608 commit 28b5e40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions base/Map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ export class Map {
let sensor_active = false;
if (collision_object.properties) {
sensor_active =
collision_object.properties.affected_by_reveal && collision_object.properties.collide_on_reveal;
Boolean(collision_object.properties.affected_by_reveal) &&
Boolean(collision_object.properties.collide_on_reveal);
if (collision_object.properties.controller_variable) {
const is_sensor_by_controller = !(this.data.storage.get(
collision_object.properties.controller_variable
Expand Down Expand Up @@ -629,7 +630,8 @@ export class Map {
let split_polygon = false;
if (collision_object.properties) {
sensor_active =
collision_object.properties.affected_by_reveal && collision_object.properties.collide_on_reveal;
Boolean(collision_object.properties.affected_by_reveal) &&
Boolean(collision_object.properties.collide_on_reveal);
if (collision_object.properties.controller_variable) {
const is_sensor_by_controller = !(this.data.storage.get(
collision_object.properties.controller_variable
Expand Down
14 changes: 12 additions & 2 deletions base/game_events/SetValueEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,25 @@ export class SetValueEvent extends GameEvent {
npc_index: this.npc_index,
npc_label: this.npc_label,
}) ?? this.origin_npc;
(char as NPC).check_storage_keys();
if (char) {
(char as NPC).check_storage_keys();
} else {
this.data.logger.log_message(
`NPC label not passed to "set_value" event when "check_npc_storage_values" was set true.`
);
}
}
if (this.check_collision_structures) {
this.data.map.collision_sprite.body.data.shapes.forEach(shape => {
if (shape.properties?.controller_variable) {
const is_sensor_by_controller = !(this.data.storage.get(
shape.properties.controller_variable
) as boolean);
shape.sensor = is_sensor_by_controller ? true : shape.sensor;
if (is_sensor_by_controller) {
shape.sensor = true;
} else if (!shape.properties.affected_by_reveal) {
shape.sensor = false;
}
}
});
}
Expand Down

0 comments on commit 28b5e40

Please sign in to comment.