diff --git a/base/interactable_objects/InteractableObjects.ts b/base/interactable_objects/InteractableObjects.ts index 6d917e89b4..a249c79cdb 100644 --- a/base/interactable_objects/InteractableObjects.ts +++ b/base/interactable_objects/InteractableObjects.ts @@ -1,5 +1,5 @@ import {SpriteBase} from "../SpriteBase"; -import {IntegerPairKey, TileEvent} from "../tile_events/TileEvent"; +import {IntegerPairKey, TileEvent, event_types} from "../tile_events/TileEvent"; import * as numbers from "../magic_numbers"; import * as _ from "lodash"; import { @@ -947,6 +947,16 @@ export class InteractableObjects { if (this.sprite?.body) { this.sprite.body.data.shapes.forEach(shape => (shape.sensor = !enable)); this._shapes_collision_active = enable; + if (this.allow_jumping_over_it) { + this.get_events().forEach(event => { + if ( + event.type === event_types.JUMP && + event.is_active_at_collision_layer(this.base_collision_layer) + ) { + this.data.map.set_collision_in_tile(event.x, event.y, enable, this.base_collision_layer); + } + }); + } } } diff --git a/base/tile_events/TileEvent.ts b/base/tile_events/TileEvent.ts index 62d2e46968..71ecba403f 100644 --- a/base/tile_events/TileEvent.ts +++ b/base/tile_events/TileEvent.ts @@ -320,6 +320,14 @@ export abstract class TileEvent { collision_layers_indexes.forEach(this.activation_collision_layers.add, this.activation_collision_layers); } + /** + * Checks if this event is active in a given collision layer. + * @param collision_layer the collision layer index to be checked. + */ + is_active_at_collision_layer(collision_layer: number) { + return this.activation_collision_layers.has(collision_layer); + } + /** * This method will be called on map update. If necessary, overrides it. */