Skip to content

Commit 8caabe9

Browse files
committed
Clean up
Just a few things here and there
1 parent e22848a commit 8caabe9

File tree

2 files changed

+37
-58
lines changed

2 files changed

+37
-58
lines changed

Ahorn/lang/en_gb.lang

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ placements.entities.SpringCollab2020/caveWall.tooltips.tiletype=Changes the visu
33

44
# Variable Crumble Blocks
55

6-
placements.entities.SpringCollab2020/variableCrumbleBlock.tooltips.texture=The texture of the blocks that are crumbling.
6+
placements.entities.SpringCollab2020/variableCrumbleBlock.tooltips.texture=The texture of the blocks that are crumbling.2
77
placements.entities.SpringCollab2020/variableCrumbleBlock.tooltips.timer=How long the blocks will shake for before falling.
88

99
# Floatier Space Block

Entities/VariableCrumbleBlock.cs

Lines changed: 36 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -58,63 +58,49 @@ private IEnumerator Sequence() {
5858
} else {
5959
player = GetPlayerClimbing();
6060
if (player == null) {
61-
yield return (object) null;
61+
yield return null;
6262
continue;
6363
}
6464
onTop = false;
6565
Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium);
6666
}
6767
Audio.Play("event:/game/general/platform_disintegrate", Center);
68-
shaker.ShakeFor(onTop ? crumbleTime + 0.1f : crumbleTime + 0.2f, false);
69-
List<Image>.Enumerator enumerator = images.GetEnumerator();
70-
try {
71-
while (enumerator.MoveNext()) {
72-
Image img2 = enumerator.Current;
73-
SceneAs<Level>().Particles.Emit(P_Crumble, 2, Position + img2.Position + new Vector2(0f, 2f), Vector2.One * 3f);
74-
}
75-
} finally {
76-
((IDisposable) enumerator).Dispose();
68+
shaker.ShakeFor(onTop ? crumbleTime + 0.4f : crumbleTime + 0.8f, false);
69+
foreach (Image img2 in images) {
70+
SceneAs<Level>().Particles.Emit(P_Crumble, 2, Position + img2.Position + new Vector2(0f, 2f), Vector2.One * 3f);
7771
}
78-
enumerator = default(List<Image>.Enumerator);
79-
for (int m = 0; m < (onTop ? 1 : 3); m++) {
80-
yield return (object) 0.2f;
81-
List<Image>.Enumerator enumerator2 = images.GetEnumerator();
82-
try {
83-
while (enumerator2.MoveNext()) {
84-
Image img = enumerator2.Current;
85-
SceneAs<Level>().Particles.Emit(P_Crumble, 2, Position + img.Position + new Vector2(0f, 2f), Vector2.One * 3f);
86-
}
87-
} finally {
88-
((IDisposable) enumerator2).Dispose();
72+
for (int l = 0; l < (onTop ? 1 : 3); l++) {
73+
yield return 0.2f;
74+
foreach (Image img in images) {
75+
SceneAs<Level>().Particles.Emit(P_Crumble, 2, Position + img.Position + new Vector2(0f, 2f), Vector2.One * 3f);
8976
}
90-
enumerator2 = default(List<Image>.Enumerator);
9177
}
9278
float timer = crumbleTime;
93-
if (!onTop) {
94-
while (timer > 0f) {
95-
yield return (object) null;
79+
if (onTop) {
80+
while (timer > 0f && GetPlayerOnTop() != null) {
81+
yield return null;
9682
timer -= Engine.DeltaTime;
9783
}
9884
} else {
99-
while (timer > 0f && GetPlayerOnTop() != null) {
100-
yield return (object) null;
85+
while (timer > 0f) {
86+
yield return null;
10187
timer -= Engine.DeltaTime;
10288
}
10389
}
10490
outlineFader.Replace(OutlineFade(1f));
10591
occluder.Visible = false;
10692
Collidable = false;
10793
float delay = 0.05f;
108-
for (int l = 0; l < 4; l++) {
94+
for (int m = 0; m < 4; m++) {
10995
for (int i = 0; i < images.Count; i++) {
110-
if (i % 4 - l == 0) {
111-
falls[i].Replace(TileOut(images[fallOrder[i]], delay * (float) l));
96+
if (i % 4 - m == 0) {
97+
falls[i].Replace(TileOut(images[fallOrder[i]], delay * (float) m));
11298
}
11399
}
114100
}
115-
yield return (object) (1.6f + crumbleTime);
101+
yield return 2f;
116102
while (CollideCheck<Actor>() || CollideCheck<Solid>()) {
117-
yield return (object) null;
103+
yield return null;
118104
}
119105
outlineFader.Replace(OutlineFade(0f));
120106
occluder.Visible = true;
@@ -133,27 +119,20 @@ private IEnumerator OutlineFade(float to) {
133119
float from = 1f - to;
134120
for (float t = 0f; t < 1f; t += Engine.DeltaTime * 2f) {
135121
Color color = Color.White * (from + (to - from) * Ease.CubeInOut(t));
136-
List<Image>.Enumerator enumerator = outline.GetEnumerator();
137-
try {
138-
while (enumerator.MoveNext()) {
139-
Image img = enumerator.Current;
140-
img.Color = color;
141-
}
142-
} finally {
143-
((IDisposable) enumerator).Dispose();
122+
foreach (Image img in outline) {
123+
img.Color = color;
144124
}
145-
enumerator = default(List<Image>.Enumerator);
146-
yield return (object) null;
125+
yield return null;
147126
}
148127
}
149128

150129
private IEnumerator TileOut(Image img, float delay) {
151130
img.Color = Color.Gray;
152-
yield return (object) delay;
131+
yield return delay;
153132
float distance = (img.X * 7f % 3f + 1f) * 12f;
154133
Vector2 from = img.Position;
155134
for (float time = 0f; time < 1f; time += Engine.DeltaTime / 0.4f) {
156-
yield return (object) null;
135+
yield return null;
157136
img.Position = from + Vector2.UnitY * Ease.CubeIn(time) * distance;
158137
img.Color = Color.Gray * (1f - time);
159138
img.Scale = Vector2.One * (1f - time * 0.5f);
@@ -162,13 +141,13 @@ private IEnumerator TileOut(Image img, float delay) {
162141
}
163142

164143
private IEnumerator TileIn(int index, Image img, float delay) {
165-
yield return (object) delay;
144+
yield return delay;
166145
Audio.Play("event:/game/general/platform_return", Center);
167146
img.Visible = true;
168147
img.Color = Color.White;
169-
img.Position = new Vector2((float) (index * 8 + 4), 4f);
148+
img.Position = new Vector2(index * 8 + 4, 4f);
170149
for (float time = 0f; time < 1f; time += Engine.DeltaTime / 0.25f) {
171-
yield return (object) null;
150+
yield return null;
172151
img.Scale = Vector2.One * (1f + Ease.BounceOut(1f - time) * 0.2f);
173152
}
174153
img.Scale = Vector2.One;
@@ -179,47 +158,47 @@ public void orig_Added(Scene scene) {
179158
MTexture mTexture = GFX.Game["objects/crumbleBlock/outline"];
180159
outline = new List<Image>();
181160
if (base.Width <= 8f) {
182-
Image image = new Image(mTexture.GetSubtexture(24, 0, 8, 8, null));
161+
Image image = new Image(mTexture.GetSubtexture(24, 0, 8, 8));
183162
image.Color = Color.White * 0f;
184163
Add(image);
185164
outline.Add(image);
186165
} else {
187166
for (int i = 0; (float) i < base.Width; i += 8) {
188167
int num = (i != 0) ? ((i > 0 && (float) i < base.Width - 8f) ? 1 : 2) : 0;
189-
Image image2 = new Image(mTexture.GetSubtexture(num * 8, 0, 8, 8, null));
190-
image2.Position = new Vector2((float) i, 0f);
168+
Image image2 = new Image(mTexture.GetSubtexture(num * 8, 0, 8, 8));
169+
image2.Position = new Vector2(i, 0f);
191170
image2.Color = Color.White * 0f;
192171
Add(image2);
193172
outline.Add(image2);
194173
}
195174
}
196-
Add(outlineFader = new Coroutine(true));
175+
Add(outlineFader = new Coroutine());
197176
outlineFader.RemoveOnComplete = false;
198177
images = new List<Image>();
199178
falls = new List<Coroutine>();
200179
fallOrder = new List<int>();
201180
MTexture mTexture2 = GFX.Game["objects/crumbleBlock/" + AreaData.Get(scene).CrumbleBlock];
202181
for (int j = 0; (float) j < base.Width; j += 8) {
203182
int num2 = (int) ((Math.Abs(base.X) + (float) j) / 8f) % 4;
204-
Image image3 = new Image(mTexture2.GetSubtexture(num2 * 8, 0, 8, 8, null));
205-
image3.Position = new Vector2((float) (4 + j), 4f);
183+
Image image3 = new Image(mTexture2.GetSubtexture(num2 * 8, 0, 8, 8));
184+
image3.Position = new Vector2(4 + j, 4f);
206185
image3.CenterOrigin();
207186
Add(image3);
208187
images.Add(image3);
209-
Coroutine coroutine = new Coroutine(true);
188+
Coroutine coroutine = new Coroutine();
210189
coroutine.RemoveOnComplete = false;
211190
falls.Add(coroutine);
212191
Add(coroutine);
213192
fallOrder.Add(j / 8);
214193
}
215194
fallOrder.Shuffle();
216-
Add(new Coroutine(Sequence(), true));
195+
Add(new Coroutine(Sequence()));
217196
Add(shaker = new ShakerList(images.Count, false, delegate (Vector2[] v) {
218197
for (int k = 0; k < images.Count; k++) {
219-
images[k].Position = new Vector2((float) (4 + k * 8), 4f) + v[k];
198+
images[k].Position = new Vector2(4 + k * 8, 4f) + v[k];
220199
}
221200
}));
222201
Add(occluder = new LightOcclude(0.2f));
223202
}
224203
}
225-
}
204+
}

0 commit comments

Comments
 (0)