diff --git a/base/game_events/GameEventManager.ts b/base/game_events/GameEventManager.ts index 9db2d4b22..271129e78 100644 --- a/base/game_events/GameEventManager.ts +++ b/base/game_events/GameEventManager.ts @@ -1307,7 +1307,8 @@ export class GameEventManager { info.shadow_follow_io, info.keep_io_collision_disable, info.dest_collision_layer, - info.change_collision_layer_on_init + info.change_collision_layer_on_init, + info.enable_collision_on_previous_pos ); case event_types.EXIT_SAND_MODE: return new ExitSandModeEvent( diff --git a/base/game_events/IOTweenPositionEvent.ts b/base/game_events/IOTweenPositionEvent.ts index 6220736d6..bc0d44698 100644 --- a/base/game_events/IOTweenPositionEvent.ts +++ b/base/game_events/IOTweenPositionEvent.ts @@ -18,8 +18,10 @@ export class IOTweenPositionEvent extends GameEvent { private shadow_follow_io: boolean; private keep_io_collision_disable: boolean; private prev_collision_status: boolean; + private prev_collision_layer: number; private dest_collision_layer: number; private change_collision_layer_on_init: boolean; + private enable_collision_on_previous_pos: boolean; constructor( game, @@ -42,7 +44,8 @@ export class IOTweenPositionEvent extends GameEvent { shadow_follow_io, keep_io_collision_disable, dest_collision_layer, - change_collision_layer_on_init + change_collision_layer_on_init, + enable_collision_on_previous_pos ) { super(game, data, event_types.IO_TWEEN_POSITION, active, key_name, keep_reveal, keep_custom_psynergy); this.io_label = io_label; @@ -59,6 +62,7 @@ export class IOTweenPositionEvent extends GameEvent { this.keep_io_collision_disable = keep_io_collision_disable ?? false; this.dest_collision_layer = dest_collision_layer; this.change_collision_layer_on_init = change_collision_layer_on_init ?? false; + this.enable_collision_on_previous_pos = enable_collision_on_previous_pos ?? false; this.finish_events = []; if (finish_events !== undefined) { finish_events.forEach(event_info => { @@ -89,6 +93,7 @@ export class IOTweenPositionEvent extends GameEvent { tween_pos.y = this.incremental ? interactable_object.y + tween_pos.y : tween_pos.y; } this.prev_collision_status = interactable_object.shapes_collision_active; + this.prev_collision_layer = interactable_object.base_collision_layer; const target = interactable_object.body ?? interactable_object.sprite; if (this.change_collision_layer_on_init && this.dest_collision_layer !== undefined) { interactable_object.change_collision_layer(this.dest_collision_layer); @@ -131,7 +136,12 @@ export class IOTweenPositionEvent extends GameEvent { }; interactable_object.shift_events( dest_tile_pos.x - interactable_object.tile_x_pos, - dest_tile_pos.y - interactable_object.tile_y_pos + dest_tile_pos.y - interactable_object.tile_y_pos, + this.enable_collision_on_previous_pos + ? { + prev_collision_layer: this.prev_collision_layer, + } + : undefined ); interactable_object.set_tile_position({ x: dest_tile_pos.x, diff --git a/base/interactable_objects/InteractableObjects.ts b/base/interactable_objects/InteractableObjects.ts index a249c79cd..300ca12ec 100644 --- a/base/interactable_objects/InteractableObjects.ts +++ b/base/interactable_objects/InteractableObjects.ts @@ -1513,7 +1513,13 @@ export class InteractableObjects { * @param event_shift_x the x shift amount. * @param event_shift_y the y shift amount. */ - shift_events(event_shift_x: number, event_shift_y: number) { + shift_events( + event_shift_x: number, + event_shift_y: number, + manipulate_collision?: { + prev_collision_layer: number; + } + ) { if (event_shift_x === 0 && event_shift_y === 0) { return; } @@ -1532,6 +1538,16 @@ export class InteractableObjects { let new_x = old_x + event_shift_x; let new_y = old_y + event_shift_y; event.set_position(new_x, new_y, true); + if (manipulate_collision && event.type === event_types.JUMP) { + if (this.rollable || this.pushable) { + this.data.map.set_collision_in_tile( + old_x, + old_y, + true, + manipulate_collision.prev_collision_layer + ); + } + } } } }