Skip to content

Commit 113465d

Browse files
authored
Merge pull request CommunalHelper#260 from aonkeeper4/fix-connected-move-block-persistence
Add option to fix Move Block Redirects' effects sometimes persisting after block respawn
2 parents f35b8bf + d6f452e commit 113465d

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

Loenn/entities/connected_blocks/connected_move_block.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ for i, direction in ipairs(enums.move_block_directions) do
6161
regenTime = 3.0,
6262
shakeOnCollision = true,
6363
noDebris = false,
64+
redirectIsPersistent = false
6465
}
6566
}
6667
end
@@ -82,6 +83,7 @@ connectedMoveBlock.placements[5] = {
8283
regenTime = 3.0,
8384
shakeOnCollision = true,
8485
noDebris = false,
86+
redirectIsPersistent = false
8587
}
8688
}
8789
connectedMoveBlock.placements[6] = {
@@ -102,6 +104,7 @@ connectedMoveBlock.placements[6] = {
102104
regenTime = 3.0,
103105
shakeOnCollision = true,
104106
noDebris = false,
107+
redirectIsPersistent = false,
105108
activatorFlags = "_pressed",
106109
breakerFlags = "_obstructed",
107110
onActivateFlags = "",

Loenn/entities/connected_blocks/equation_move_block.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ for i, direction in ipairs(enums.move_block_directions) do
8282
regenTime = 3.0,
8383
shakeOnCollision = true,
8484
noDebris = false,
85+
redirectIsPersistent = false
8586
}
8687
}
8788
end
@@ -105,6 +106,7 @@ equationMoveBlock.placements[5] = {
105106
regenTime = 3.0,
106107
shakeOnCollision = true,
107108
noDebris = false,
109+
redirectIsPersistent = false
108110
}
109111
}
110112
equationMoveBlock.placements[6] = {
@@ -127,6 +129,7 @@ equationMoveBlock.placements[6] = {
127129
regenTime = 3.0,
128130
shakeOnCollision = true,
129131
noDebris = false,
132+
redirectIsPersistent = false,
130133
activatorFlags = "_pressed",
131134
breakerFlags = "_obstructed",
132135
onActivateFlags = "",

Loenn/lang/en_gb.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ entities.CommunalHelper/ConnectedMoveBlock.attributes.description.crashTime=The
457457
entities.CommunalHelper/ConnectedMoveBlock.attributes.description.regenTime=The time it takes for this Connected Move Block to respawn after breaking in seconds.
458458
entities.CommunalHelper/ConnectedMoveBlock.attributes.description.shakeOnCollision=Whether this Connected Move Block should start shaking if it collides with a solid for longer than the default break time.
459459
entities.CommunalHelper/ConnectedMoveBlock.attributes.description.noDebris=Whether this Connected Move Block should not spawn debris when it breaks.
460+
entities.CommunalHelper/ConnectedMoveBlock.attributes.description.redirectIsPersistent=Whether the effects of any Move Block Redirects on this block should persist after this block breaks and respawns.
460461

461462
# Connected Temple Cracked Block
462463
entities.CommunalHelper/ConnectedTempleCrackedBlock.placements.name.normal=Connected Temple Cracked Block
@@ -492,6 +493,7 @@ entities.CommunalHelper/EquationMoveBlock.attributes.description.crashTime=The t
492493
entities.CommunalHelper/EquationMoveBlock.attributes.description.regenTime=The time it takes for this Equation Move Block to respawn after breaking in seconds.
493494
entities.CommunalHelper/EquationMoveBlock.attributes.description.shakeOnCollision=Whether this Equation Move Block should start shaking if it collides with a solid for longer than the default break time.
494495
entities.CommunalHelper/EquationMoveBlock.attributes.description.noDebris=Whether this Equation Move Block should not spawn debris when it breaks.
496+
entities.CommunalHelper/EquationMoveBlock.attributes.description.redirectIsPersistent=Whether the effects of any Move Block Redirects on this block should persist after this block breaks and respawns.
495497

496498
# Bouncy Panel
497499
entities.CommunalHelper/BouncyPanel.placements.name.up=Bouncy Panel (Up)

src/Entities/ConnectedBlocks/ConnectedMoveBlock.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ public override void Render()
124124

125125
protected readonly bool noDebris;
126126

127+
// whether any MoveBlockRedirects' effects on this move block should persist after respawn
128+
protected readonly bool redirectIsPersistent;
129+
127130
public ConnectedMoveBlock(EntityData data, Vector2 offset)
128131
: this(data.Position + offset, data.Width, data.Height, data.Enum<MoveBlock.Directions>("direction"), data.Bool("fast") ? 75f : data.Float("moveSpeed", 60f))
129132
{
@@ -203,6 +206,8 @@ public ConnectedMoveBlock(EntityData data, Vector2 offset)
203206
shakeOnCollision = data.Bool("shakeOnCollision", true);
204207

205208
noDebris = data.Bool("noDebris");
209+
210+
redirectIsPersistent = data.Bool("redirectIsPersistent", true);
206211
}
207212

208213
public ConnectedMoveBlock(Vector2 position, int width, int height, MoveBlock.Directions direction, float moveSpeed)
@@ -368,6 +373,8 @@ protected virtual IEnumerator Controller()
368373
yield return 0.2f;
369374

370375
BreakParticles();
376+
if (!redirectIsPersistent)
377+
((MoveBlockRedirectable) Get<Redirectable>())?.ResetBlock();
371378

372379
List<MoveBlockDebris> debris = new();
373380
if (!noDebris)

src/Entities/ConnectedBlocks/EquationMoveBlock.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ MoveBlock.Directions.Up or
187187
yield return 0.2f;
188188

189189
BreakParticles();
190+
if (!redirectIsPersistent)
191+
((MoveBlockRedirectable) Get<Redirectable>())?.ResetBlock();
190192

191193
List<MoveBlockDebris> debris = new();
192194
if (!noDebris)

0 commit comments

Comments
 (0)