Skip to content

Commit 1b1bc67

Browse files
committed
Add noDebris option to all move block entities
1 parent 7305921 commit 1b1bc67

File tree

10 files changed

+95
-60
lines changed

10 files changed

+95
-60
lines changed

Loenn/entities/cassette_blocks/cassette_move_block.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ for i = 1, 4 do
5252
crashTime = 0.15,
5353
regenTime = 3.0,
5454
shakeOnCollision = true,
55+
noDebris = false,
5556
}
5657
}
5758
end

Loenn/entities/connected_blocks/connected_move_block.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ for i, direction in ipairs(enums.move_block_directions) do
6060
crashTime = 0.15,
6161
regenTime = 3.0,
6262
shakeOnCollision = true,
63+
noDebris = false,
6364
}
6465
}
6566
end
@@ -80,6 +81,7 @@ connectedMoveBlock.placements[5] = {
8081
crashTime = 0.15,
8182
regenTime = 3.0,
8283
shakeOnCollision = true,
84+
noDebris = false,
8385
}
8486
}
8587
connectedMoveBlock.placements[6] = {
@@ -99,6 +101,7 @@ connectedMoveBlock.placements[6] = {
99101
crashTime = 0.15,
100102
regenTime = 3.0,
101103
shakeOnCollision = true,
104+
noDebris = false,
102105
activatorFlags = "_pressed",
103106
breakerFlags = "_obstructed",
104107
onActivateFlags = "",

Loenn/entities/connected_blocks/equation_move_block.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ for i, direction in ipairs(enums.move_block_directions) do
8181
crashTime = 0.15,
8282
regenTime = 3.0,
8383
shakeOnCollision = true,
84+
noDebris = false,
8485
}
8586
}
8687
end
@@ -103,6 +104,7 @@ equationMoveBlock.placements[5] = {
103104
crashTime = 0.15,
104105
regenTime = 3.0,
105106
shakeOnCollision = true,
107+
noDebris = false,
106108
}
107109
}
108110
equationMoveBlock.placements[6] = {
@@ -124,6 +126,7 @@ equationMoveBlock.placements[6] = {
124126
crashTime = 0.15,
125127
regenTime = 3.0,
126128
shakeOnCollision = true,
129+
noDebris = false,
127130
activatorFlags = "_pressed",
128131
breakerFlags = "_obstructed",
129132
onActivateFlags = "",

Loenn/entities/dream_blocks/dream_move_block.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ dreamMoveBlock.placements = {
7373
crashTime = 0.15,
7474
regenTime = 3.0,
7575
shakeOnCollision = true,
76+
noDebris = false,
7677
idleButtonsColor = "FFFFFF",
7778
movingButtonsColor = "FFFFFF",
7879
idleArrowColor = "FFFFFF",

Loenn/entities/misc/move_swap_block.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ moveSwapBlock.placements = {
4646
crashTime = 0.15,
4747
regenTime = 3.0,
4848
shakeOnCollision = true,
49+
noDebris = false,
4950
}
5051
}
5152
}

src/Entities/CassetteBlocks/CassetteMoveBlock.cs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ public class CassetteMoveBlock : CustomCassetteBlock
5959
private readonly ParticleType P_Break;
6060
private readonly ParticleType P_BreakPressed;
6161

62-
public CassetteMoveBlock(Vector2 position, EntityID id, int width, int height, Directions direction, float moveSpeed, int index, float tempo, bool oldConnectionBehavior, Color? overrideColor, float crashTime, float regenTime, bool shakeOnCollision)
62+
private readonly bool noDebris;
63+
64+
public CassetteMoveBlock(Vector2 position, EntityID id, int width, int height, Directions direction, float moveSpeed, int index, float tempo, bool oldConnectionBehavior, Color? overrideColor, float crashTime, float regenTime, bool shakeOnCollision, bool noDebris)
6365
: base(position, id, width, height, index, tempo, true, oldConnectionBehavior, dynamicHitbox: true, overrideColor)
6466
{
6567
startPosition = position;
@@ -82,6 +84,8 @@ public CassetteMoveBlock(Vector2 position, EntityID id, int width, int height, D
8284
P_Break = new ParticleType(MoveBlock.P_Break) { Color = color };
8385
P_BreakPressed = new ParticleType(MoveBlock.P_Break) { Color = pressedColor };
8486

87+
this.noDebris = noDebris;
88+
8589
DynamicData dynamicData = new(this);
8690
Add(new MoveBlockRedirectable(
8791
dynamicData,
@@ -116,7 +120,7 @@ public CassetteMoveBlock(Vector2 position, EntityID id, int width, int height, D
116120
}
117121

118122
public CassetteMoveBlock(EntityData data, Vector2 offset, EntityID id)
119-
: this(data.Position + offset, id, data.Width, data.Height, data.Enum("direction", Directions.Left), data.Bool("fast") ? FastMoveSpeed : data.Float("moveSpeed", MoveSpeed), data.Int("index"), data.Float("tempo", 1f), data.Bool("oldConnectionBehavior", true), data.HexColorNullable("customColor"), data.Float("crashTime", 0.15f), data.Float("regenTime", 3f), data.Bool("shakeOnCollision", true))
123+
: this(data.Position + offset, id, data.Width, data.Height, data.Enum("direction", Directions.Left), data.Bool("fast") ? FastMoveSpeed : data.Float("moveSpeed", MoveSpeed), data.Int("index"), data.Float("tempo", 1f), data.Bool("oldConnectionBehavior", true), data.HexColorNullable("customColor"), data.Float("crashTime", 0.15f), data.Float("regenTime", 3f), data.Bool("shakeOnCollision", true), data.Bool("noDebris"))
120124
{
121125
}
122126

@@ -260,19 +264,21 @@ private IEnumerator Controller()
260264
BreakParticles();
261265
((MoveBlockRedirectable) Get<Redirectable>())?.ResetBlock();
262266
List<MoveBlockDebris> debris = new();
263-
for (int x = 0; x < Width; x += 8)
264-
{
265-
for (int y = 0; y < Height; y += 8)
267+
if (!noDebris) {
268+
for (int x = 0; x < Width; x += 8)
266269
{
267-
Vector2 offset = new(x + 4f, y + 4f);
268-
269-
MoveBlockDebris d = Engine.Pooler.Create<MoveBlockDebris>().Init(Position + offset, Center, startPosition + offset, spr =>
270+
for (int y = 0; y < Height; y += 8)
270271
{
271-
spr.Color = Activated ? color : pressedColor;
272-
});
273-
d.Sprite.Texture = Calc.Random.Choose(GFX.Game.GetAtlasSubtextures("objects/CommunalHelper/cassetteMoveBlock/debris"));
274-
debris.Add(d);
275-
Scene.Add(d);
272+
Vector2 offset = new(x + 4f, y + 4f);
273+
274+
MoveBlockDebris d = Engine.Pooler.Create<MoveBlockDebris>().Init(Position + offset, Center, startPosition + offset, spr =>
275+
{
276+
spr.Color = Activated ? color : pressedColor;
277+
});
278+
d.Sprite.Texture = Calc.Random.Choose(GFX.Game.GetAtlasSubtextures("objects/CommunalHelper/cassetteMoveBlock/debris"));
279+
debris.Add(d);
280+
Scene.Add(d);
281+
}
276282
}
277283
}
278284
Vector2 newPosition = startPosition + blockOffset;
@@ -336,7 +342,7 @@ private IEnumerator Controller()
336342

337343
private IEnumerator SoundFollowsDebrisCenter(EventInstance instance, List<MoveBlockDebris> debris)
338344
{
339-
while (true)
345+
while (true && debris.Count > 0)
340346
{
341347
instance.getPlaybackState(out PLAYBACK_STATE state);
342348
if (state == PLAYBACK_STATE.STOPPED)

src/Entities/ConnectedBlocks/ConnectedMoveBlock.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ public override void Render()
126126

127127
private readonly bool outline;
128128

129+
protected readonly bool noDebris;
130+
129131
public ConnectedMoveBlock(EntityData data, Vector2 offset)
130132
: this(data.Position + offset, data.Width, data.Height, data.Enum<MoveBlock.Directions>("direction"), data.Bool("fast") ? 75f : data.Float("moveSpeed", 60f))
131133
{
@@ -203,6 +205,8 @@ public ConnectedMoveBlock(EntityData data, Vector2 offset)
203205
crashTime = data.Float("crashTime", 0.15f);
204206
regenTime = data.Float("regenTime", 3f);
205207
shakeOnCollision = data.Bool("shakeOnCollision", true);
208+
209+
noDebris = data.Bool("noDebris");
206210
}
207211

208212
public ConnectedMoveBlock(Vector2 position, int width, int height, MoveBlock.Directions direction, float moveSpeed)
@@ -370,20 +374,22 @@ protected virtual IEnumerator Controller()
370374
BreakParticles();
371375

372376
List<MoveBlockDebris> debris = new();
373-
int tWidth = (int) ((GroupBoundsMax.X - GroupBoundsMin.X) / 8);
374-
int tHeight = (int) ((GroupBoundsMax.Y - GroupBoundsMin.Y) / 8);
377+
if (!noDebris) {
378+
int tWidth = (int) ((GroupBoundsMax.X - GroupBoundsMin.X) / 8);
379+
int tHeight = (int) ((GroupBoundsMax.Y - GroupBoundsMin.Y) / 8);
375380

376-
for (int i = 0; i < tWidth; i++)
377-
{
378-
for (int j = 0; j < tHeight; j++)
381+
for (int i = 0; i < tWidth; i++)
379382
{
380-
if (AllGroupTiles[i, j])
383+
for (int j = 0; j < tHeight; j++)
381384
{
382-
Vector2 value = new((i * 8) + 4, (j * 8) + 4);
383-
Vector2 pos = value + Position + GroupOffset;
384-
MoveBlockDebris debris2 = Engine.Pooler.Create<MoveBlockDebris>().Init(pos, GroupCenter, startPosition + GroupOffset + value);
385-
debris.Add(debris2);
386-
Scene.Add(debris2);
385+
if (AllGroupTiles[i, j])
386+
{
387+
Vector2 value = new((i * 8) + 4, (j * 8) + 4);
388+
Vector2 pos = value + Position + GroupOffset;
389+
MoveBlockDebris debris2 = Engine.Pooler.Create<MoveBlockDebris>().Init(pos, GroupCenter, startPosition + GroupOffset + value);
390+
debris.Add(debris2);
391+
Scene.Add(debris2);
392+
}
387393
}
388394
}
389395
}
@@ -483,7 +489,7 @@ protected virtual IEnumerator Controller()
483489

484490
protected IEnumerator SoundFollowsDebrisCenter(EventInstance instance, List<MoveBlockDebris> debris)
485491
{
486-
while (true)
492+
while (true && debris.Count > 0)
487493
{
488494
instance.getPlaybackState(out PLAYBACK_STATE pLAYBACK_STATE);
489495
if (pLAYBACK_STATE == PLAYBACK_STATE.STOPPED)

src/Entities/ConnectedBlocks/EquationMoveBlock.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,22 @@ MoveBlock.Directions.Up or
188188
BreakParticles();
189189

190190
List<MoveBlockDebris> debris = new();
191-
int tWidth = (int) ((GroupBoundsMax.X - GroupBoundsMin.X) / 8);
192-
int tHeight = (int) ((GroupBoundsMax.Y - GroupBoundsMin.Y) / 8);
191+
if (!noDebris) {
192+
int tWidth = (int) ((GroupBoundsMax.X - GroupBoundsMin.X) / 8);
193+
int tHeight = (int) ((GroupBoundsMax.Y - GroupBoundsMin.Y) / 8);
193194

194-
for (int i = 0; i < tWidth; i++)
195-
{
196-
for (int j = 0; j < tHeight; j++)
195+
for (int i = 0; i < tWidth; i++)
197196
{
198-
if (AllGroupTiles[i, j])
197+
for (int j = 0; j < tHeight; j++)
199198
{
200-
Vector2 value = new((i * 8) + 4, (j * 8) + 4);
201-
Vector2 pos = value + Position + GroupOffset;
202-
MoveBlockDebris debris2 = Engine.Pooler.Create<MoveBlockDebris>().Init(pos, GroupCenter, startPosition + GroupOffset + value);
203-
debris.Add(debris2);
204-
Scene.Add(debris2);
199+
if (AllGroupTiles[i, j])
200+
{
201+
Vector2 value = new((i * 8) + 4, (j * 8) + 4);
202+
Vector2 pos = value + Position + GroupOffset;
203+
MoveBlockDebris debris2 = Engine.Pooler.Create<MoveBlockDebris>().Init(pos, GroupCenter, startPosition + GroupOffset + value);
204+
debris.Add(debris2);
205+
Scene.Add(debris2);
206+
}
205207
}
206208
}
207209
}

src/Entities/DreamBlocks/DreamMoveBlock.cs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ public class DreamMoveBlock : CustomDreamBlock
9393

9494
private bool oneUseBroken;
9595

96+
private readonly bool noDebris;
97+
9698
internal static void InitializeParticles()
9799
{
98100
P_Activate = new ParticleType(MoveBlock.P_Activate)
@@ -148,6 +150,8 @@ public DreamMoveBlock(EntityData data, Vector2 offset)
148150
regenTime = data.Float("regenTime", 3f);
149151
shakeOnCollision = data.Bool("shakeOnCollision", true);
150152

153+
noDebris = data.Bool("noDebris");
154+
151155
if (data.Attr("idleButtonsColor", "FFFFFF") != "FFFFFF")
152156
{
153157
this.idleButtonsColor = Calc.HexToColor(data.Attr("idleButtonsColor"));
@@ -407,20 +411,22 @@ private IEnumerator Controller()
407411
BreakParticles();
408412
((MoveBlockRedirectable) Get<Redirectable>())?.ResetBlock();
409413
List<MoveBlockDebris> debris = new();
410-
for (int x = 0; x < Width; x += 8)
411-
{
412-
for (int y = 0; y < Height; y += 8)
414+
if (!noDebris) {
415+
for (int x = 0; x < Width; x += 8)
413416
{
414-
Vector2 offset = new(x + 4f, y + 4f);
415-
MTexture texture = Calc.Random.Choose(GFX.Game.GetAtlasSubtextures("objects/CommunalHelper/dreamMoveBlock/debris"));
416-
MTexture altTexture = GFX.Game[texture.AtlasPath.Replace("debris", "disabledDebris")];
417-
MoveBlockDebris d = Engine.Pooler.Create<MoveBlockDebris>()
418-
.Init(Position + offset, Center, startPosition + offset, spr =>
419-
{
420-
spr.Texture = PlayerHasDreamDash ? texture : altTexture;
421-
});
422-
debris.Add(d);
423-
Scene.Add(d);
417+
for (int y = 0; y < Height; y += 8)
418+
{
419+
Vector2 offset = new(x + 4f, y + 4f);
420+
MTexture texture = Calc.Random.Choose(GFX.Game.GetAtlasSubtextures("objects/CommunalHelper/dreamMoveBlock/debris"));
421+
MTexture altTexture = GFX.Game[texture.AtlasPath.Replace("debris", "disabledDebris")];
422+
MoveBlockDebris d = Engine.Pooler.Create<MoveBlockDebris>()
423+
.Init(Position + offset, Center, startPosition + offset, spr =>
424+
{
425+
spr.Texture = PlayerHasDreamDash ? texture : altTexture;
426+
});
427+
debris.Add(d);
428+
Scene.Add(d);
429+
}
424430
}
425431
}
426432
MoveStaticMovers(startPosition - Position);
@@ -533,7 +539,7 @@ public override void SetupCustomParticles(float canvasWidth, float canvasHeight)
533539

534540
private IEnumerator SoundFollowsDebrisCenter(EventInstance instance, List<MoveBlockDebris> debris)
535541
{
536-
while (true)
542+
while (true && debris.Count > 0)
537543
{
538544
instance.getPlaybackState(out PLAYBACK_STATE state);
539545
if (state == PLAYBACK_STATE.STOPPED)

src/Entities/Misc/MoveSwapBlock.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public class MoveSwapBlock : SwapBlock
9292

9393
private float particleRemainder;
9494

95+
private readonly bool noDebris;
96+
9597
#endregion
9698

9799
private bool swapUpdate;
@@ -177,6 +179,8 @@ public MoveSwapBlock(EntityData data, Vector2 offset)
177179
regenTime = data.Float("regenTime", 3f);
178180
shakeOnCollision = data.Bool("shakeOnCollision", true);
179181

182+
noDebris = data.Bool("noDebris");
183+
180184
int tilesX = (int) Width / 8;
181185
int tilesY = (int) Height / 8;
182186
MTexture buttonTexture = GFX.Game["objects/moveBlock/button"];
@@ -501,15 +505,17 @@ private IEnumerator Controller()
501505
BreakParticles();
502506
((MoveBlockRedirectable) Get<Redirectable>())?.ResetBlock();
503507
List<MoveBlockDebris> debrisList = new();
504-
for (int i = 0; i < Width; i += 8)
505-
{
506-
for (int j = 0; j < Height; j += 8)
508+
if (!noDebris) {
509+
for (int i = 0; i < Width; i += 8)
507510
{
508-
Vector2 value = new(i + 4f, j + 4f);
509-
MoveBlockDebris debris = Engine.Pooler.Create<MoveBlockDebris>().Init(Position + value, Center, startPosition + value);
510-
debris.Sprite.Texture = debrisTextures.Choose();
511-
debrisList.Add(debris);
512-
Scene.Add(debris);
511+
for (int j = 0; j < Height; j += 8)
512+
{
513+
Vector2 value = new(i + 4f, j + 4f);
514+
MoveBlockDebris debris = Engine.Pooler.Create<MoveBlockDebris>().Init(Position + value, Center, startPosition + value);
515+
debris.Sprite.Texture = debrisTextures.Choose();
516+
debrisList.Add(debris);
517+
Scene.Add(debris);
518+
}
513519
}
514520
}
515521

@@ -586,7 +592,7 @@ private IEnumerator Controller()
586592

587593
private IEnumerator SoundFollowsDebrisCenter(EventInstance instance, List<MoveBlockDebris> debrisList)
588594
{
589-
while (true)
595+
while (true && debrisList.Count > 0)
590596
{
591597
instance.getPlaybackState(out PLAYBACK_STATE pLAYBACK_STATE);
592598
if (pLAYBACK_STATE != PLAYBACK_STATE.STOPPED)

0 commit comments

Comments
 (0)