Prevent blocks from pushing sliding blocks, except frame blocks pushing dirt blocks

This commit is contained in:
Eevee (Evelyn Woods) 2020-12-29 08:30:55 -07:00
parent 63f09283ea
commit 41ab804f79

View File

@ -100,6 +100,14 @@ export class Tile {
return false; return false;
} }
// CC2 strikes again: blocks cannot push sliding blocks, except that frame blocks can push
// sliding dirt blocks!
if (this.type.is_block && tile.slide_mode && ! (
this.type.name === 'frame_block' && tile.type.name === 'dirt_block'))
{
return false;
}
// Obey railroad curvature // Obey railroad curvature
direction = tile.cell.redirect_exit(tile, direction); direction = tile.cell.redirect_exit(tile, direction);
// Need to explicitly check this here, otherwise you could /attempt/ to push a block, // Need to explicitly check this here, otherwise you could /attempt/ to push a block,
@ -285,9 +293,9 @@ export class Cell extends Array {
level._set_tile_prop(actor, 'is_pushing', true); level._set_tile_prop(actor, 'is_pushing', true);
} }
if (! level.attempt_out_of_turn_step(tile, direction)) { if (! level.attempt_out_of_turn_step(tile, direction)) {
// If the push failed and the obstacle is in the middle of a slide,
// remember this as the next move it'll make.
if (tile.slide_mode !== null && tile.movement_cooldown > 0) { if (tile.slide_mode !== null && tile.movement_cooldown > 0) {
// If the push failed and the obstacle is in the middle of a slide,
// remember this as the next move it'll make
level._set_tile_prop(tile, 'pending_push', direction); level._set_tile_prop(tile, 'pending_push', direction);
} }
return false; return false;
@ -1328,7 +1336,7 @@ export class Level extends LevelInterface {
// can pull other blocks even though they can't usually push them. given the // can pull other blocks even though they can't usually push them. given the
// existence of monster hooking, i suspect /anything/ can be hooked but on // existence of monster hooking, i suspect /anything/ can be hooked but on
// monsters it has a weird effect? figure this out? // monsters it has a weird effect? figure this out?
behind_actor.type.name.match(/_block$/) && behind_actor.type.is_block &&
(! behind_actor.type.allows_push || behind_actor.type.allows_push(behind_actor, direction))) (! behind_actor.type.allows_push || behind_actor.type.allows_push(behind_actor, direction)))
{ {
if (behind_actor.movement_cooldown) { if (behind_actor.movement_cooldown) {