Skip to content

Commit 626de8b

Browse files
authored
Merge pull request CommunalHelper#227 from aonkeeper4/debrisless-entities
Add option to remove debris to all move block types
2 parents 7305921 + 74ffa3e commit 626de8b

File tree

11 files changed

+108
-65
lines changed

11 files changed

+108
-65
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
}

Loenn/lang/en_gb.lang

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ entities.CommunalHelper/CassetteMoveBlock.attributes.name.regenTime=Respawn Time
189189
entities.CommunalHelper/CassetteMoveBlock.attributes.description.crashTime=The time it takes for this Cassette Move Block to break when hitting a solid in seconds.
190190
entities.CommunalHelper/CassetteMoveBlock.attributes.description.regenTime=The time it takes for this Cassette Move Block to respawn after breaking in seconds.
191191
entities.CommunalHelper/CassetteMoveBlock.attributes.description.shakeOnCollision=Whether this Cassette Move Block should start shaking if it collides with a solid for longer than the default break time.
192+
entities.CommunalHelper/CassetteMoveBlock.attributes.description.noDebris=Whether this Cassette Move Block should not spawn debris when it breaks.
192193

193194
# Cassette Swap Block
194195
entities.CommunalHelper/CassetteSwapBlock.placements.name.cassette_block_0=Cassette Swap Block (0 - Blue)
@@ -318,6 +319,7 @@ entities.CommunalHelper/DreamMoveBlock.attributes.name.regenTime=Respawn Time
318319
entities.CommunalHelper/DreamMoveBlock.attributes.description.crashTime=The time it takes for this Dream Move Block to break when hitting a solid in seconds.
319320
entities.CommunalHelper/DreamMoveBlock.attributes.description.regenTime=The time it takes for this Dream Move Block to respawn after breaking in seconds.
320321
entities.CommunalHelper/DreamMoveBlock.attributes.description.shakeOnCollision=Whether this Dream Move Block should start shaking if it collides with a solid for longer than the default break time.
322+
entities.CommunalHelper/DreamMoveBlock.attributes.description.noDebris=Whether this Dream Move Block should not spawn debris when it breaks.
321323
entities.CommunalHelper/DreamMoveBlock.Attributes.description.idleButtonsColor=Body and buttons's color when the block is idle.
322324
entities.CommunalHelper/DreamMoveBlock.Attributes.description.idleArrowColor=Arrow's color when the block is idle.
323325
entities.CommunalHelper/DreamMoveBlock.Attributes.description.idleWobbleLinesColor=Wobble lines's color when the block is idle.
@@ -430,6 +432,7 @@ entities.CommunalHelper/ConnectedMoveBlock.attributes.name.regenTime=Respawn Tim
430432
entities.CommunalHelper/ConnectedMoveBlock.attributes.description.crashTime=The time it takes for this Connected Move Block to break when hitting a solid in seconds.
431433
entities.CommunalHelper/ConnectedMoveBlock.attributes.description.regenTime=The time it takes for this Connected Move Block to respawn after breaking in seconds.
432434
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.
435+
entities.CommunalHelper/ConnectedMoveBlock.attributes.description.noDebris=Whether this Connected Move Block should not spawn debris when it breaks.
433436

434437
# Connected Temple Cracked Block
435438
entities.CommunalHelper/ConnectedTempleCrackedBlock.placements.name.normal=Connected Temple Cracked Block
@@ -464,6 +467,7 @@ entities.CommunalHelper/EquationMoveBlock.attributes.name.regenTime=Respawn Time
464467
entities.CommunalHelper/EquationMoveBlock.attributes.description.crashTime=The time it takes for this Equation Move Block to break when hitting a solid in seconds.
465468
entities.CommunalHelper/EquationMoveBlock.attributes.description.regenTime=The time it takes for this Equation Move Block to respawn after breaking in seconds.
466469
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.
470+
entities.CommunalHelper/EquationMoveBlock.attributes.description.noDebris=Whether this Equation Move Block should not spawn debris when it breaks.
467471

468472
# Bouncy Panel
469473
entities.CommunalHelper/BouncyPanel.placements.name.up=Bouncy Panel (Up)
@@ -608,6 +612,7 @@ entities.CommunalHelper/MoveSwapBlock.attributes.name.regenTime=Respawn Time
608612
entities.CommunalHelper/MoveSwapBlock.attributes.description.crashTime=The time it takes for this Move Swap Block to break when hitting a solid in seconds.
609613
entities.CommunalHelper/MoveSwapBlock.attributes.description.regenTime=The time it takes for this Move Swap Block to respawn after breaking in seconds.
610614
entities.CommunalHelper/MoveSwapBlock.attributes.description.shakeOnCollision=Whether this Move Swap Block should start shaking if it collides with a solid for longer than the default break time.
615+
entities.CommunalHelper/MoveSwapBlock.attributes.description.noDebris=Whether this Move Swap Block should not spawn debris when it breaks.
611616

612617
# Player Bubble Region
613618
entities.CommunalHelper/PlayerBubbleRegion.placements.name.player_bubble_region=Player Bubble Region

src/Entities/CassetteBlocks/CassetteMoveBlock.cs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using MonoMod.Utils;
44
using System.Collections;
55
using System.Collections.Generic;
6+
using System.Linq;
67
using Directions = Celeste.MoveBlock.Directions;
78

89
// TODO
@@ -59,7 +60,9 @@ public class CassetteMoveBlock : CustomCassetteBlock
5960
private readonly ParticleType P_Break;
6061
private readonly ParticleType P_BreakPressed;
6162

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)
63+
private readonly bool noDebris;
64+
65+
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)
6366
: base(position, id, width, height, index, tempo, true, oldConnectionBehavior, dynamicHitbox: true, overrideColor)
6467
{
6568
startPosition = position;
@@ -82,6 +85,8 @@ public CassetteMoveBlock(Vector2 position, EntityID id, int width, int height, D
8285
P_Break = new ParticleType(MoveBlock.P_Break) { Color = color };
8386
P_BreakPressed = new ParticleType(MoveBlock.P_Break) { Color = pressedColor };
8487

88+
this.noDebris = noDebris;
89+
8590
DynamicData dynamicData = new(this);
8691
Add(new MoveBlockRedirectable(
8792
dynamicData,
@@ -116,7 +121,7 @@ public CassetteMoveBlock(Vector2 position, EntityID id, int width, int height, D
116121
}
117122

118123
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))
124+
: 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"))
120125
{
121126
}
122127

@@ -260,19 +265,21 @@ private IEnumerator Controller()
260265
BreakParticles();
261266
((MoveBlockRedirectable) Get<Redirectable>())?.ResetBlock();
262267
List<MoveBlockDebris> debris = new();
263-
for (int x = 0; x < Width; x += 8)
264-
{
265-
for (int y = 0; y < Height; y += 8)
268+
if (!noDebris) {
269+
for (int x = 0; x < Width; x += 8)
266270
{
267-
Vector2 offset = new(x + 4f, y + 4f);
268-
269-
MoveBlockDebris d = Engine.Pooler.Create<MoveBlockDebris>().Init(Position + offset, Center, startPosition + offset, spr =>
271+
for (int y = 0; y < Height; y += 8)
270272
{
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);
273+
Vector2 offset = new(x + 4f, y + 4f);
274+
275+
MoveBlockDebris d = Engine.Pooler.Create<MoveBlockDebris>().Init(Position + offset, Center, startPosition + offset, spr =>
276+
{
277+
spr.Color = Activated ? color : pressedColor;
278+
});
279+
d.Sprite.Texture = Calc.Random.Choose(GFX.Game.GetAtlasSubtextures("objects/CommunalHelper/cassetteMoveBlock/debris"));
280+
debris.Add(d);
281+
Scene.Add(d);
282+
}
276283
}
277284
}
278285
Vector2 newPosition = startPosition + blockOffset;
@@ -297,7 +304,7 @@ private IEnumerator Controller()
297304
yield return null;
298305

299306
Present = true;
300-
EventInstance sound = Audio.Play(SFX.game_04_arrowblock_reform_begin, debris[0].Position);
307+
EventInstance sound = Audio.Play(SFX.game_04_arrowblock_reform_begin, debris.FirstOrDefault()?.Position ?? Center);
301308
Coroutine component;
302309
Coroutine routine = component = new Coroutine(SoundFollowsDebrisCenter(sound, debris));
303310
Add(component);
@@ -336,7 +343,7 @@ private IEnumerator Controller()
336343

337344
private IEnumerator SoundFollowsDebrisCenter(EventInstance instance, List<MoveBlockDebris> debris)
338345
{
339-
while (true)
346+
while (true && debris.Count > 0)
340347
{
341348
instance.getPlaybackState(out PLAYBACK_STATE state);
342349
if (state == PLAYBACK_STATE.STOPPED)

src/Entities/ConnectedBlocks/ConnectedMoveBlock.cs

Lines changed: 19 additions & 13 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
}
@@ -443,7 +449,7 @@ protected virtual IEnumerator Controller()
443449
}
444450

445451
Collidable = true;
446-
EventInstance instance = Audio.Play(ReformBeginSoundEffect, debris[0].Position);
452+
EventInstance instance = Audio.Play(ReformBeginSoundEffect, debris.FirstOrDefault()?.Position ?? Center);
447453
Coroutine component;
448454
Coroutine routine = component = new Coroutine(SoundFollowsDebrisCenter(instance, debris));
449455
Add(component);
@@ -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: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using FMOD.Studio;
33
using System.Collections;
44
using System.Collections.Generic;
5+
using System.Linq;
56

67
namespace Celeste.Mod.CommunalHelper.Entities.ConnectedStuff;
78

@@ -188,20 +189,22 @@ MoveBlock.Directions.Up or
188189
BreakParticles();
189190

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

194-
for (int i = 0; i < tWidth; i++)
195-
{
196-
for (int j = 0; j < tHeight; j++)
196+
for (int i = 0; i < tWidth; i++)
197197
{
198-
if (AllGroupTiles[i, j])
198+
for (int j = 0; j < tHeight; j++)
199199
{
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);
200+
if (AllGroupTiles[i, j])
201+
{
202+
Vector2 value = new((i * 8) + 4, (j * 8) + 4);
203+
Vector2 pos = value + Position + GroupOffset;
204+
MoveBlockDebris debris2 = Engine.Pooler.Create<MoveBlockDebris>().Init(pos, GroupCenter, startPosition + GroupOffset + value);
205+
debris.Add(debris2);
206+
Scene.Add(debris2);
207+
}
205208
}
206209
}
207210
}
@@ -260,7 +263,7 @@ MoveBlock.Directions.Up or
260263
}
261264

262265
Collidable = true;
263-
EventInstance instance = Audio.Play(SFX.game_04_arrowblock_reform_begin, debris[0].Position);
266+
EventInstance instance = Audio.Play(SFX.game_04_arrowblock_reform_begin, debris.FirstOrDefault()?.Position ?? Center);
264267
Coroutine component;
265268
Coroutine routine = component = new Coroutine(SoundFollowsDebrisCenter(instance, debris));
266269
Add(component);

0 commit comments

Comments
 (0)