Skip to content

Commit 7bd0b7d

Browse files
authored
Merge pull request #28 from coloursofnoise/main
Swap to SDK-Style project, general clean up and refactoring
2 parents 9275a47 + 708c2c5 commit 7bd0b7d

25 files changed

Lines changed: 334 additions & 425 deletions

.editorconfig

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
root = true
2+
3+
[*.cs]
4+
indent_style = space
5+
indent_size = 4
6+
7+
# https://kent-boogaart.com/blog/editorconfig-reference-for-c-developers
8+
9+
csharp_indent_block_contents = true
10+
csharp_indent_case_contents = true
11+
csharp_indent_labels = no_change
12+
csharp_indent_switch_labels = true
13+
csharp_new_line_before_catch = false
14+
csharp_new_line_before_else = false
15+
csharp_new_line_before_finally = false
16+
csharp_new_line_before_members_in_anonymous_types = true
17+
csharp_new_line_before_members_in_object_initializers = true
18+
csharp_new_line_before_open_brace = none
19+
csharp_prefer_braces = false:silent
20+
csharp_prefer_simple_default_expression = true:warning
21+
csharp_preserve_single_line_blocks = true
22+
csharp_preserve_single_line_statements = false
23+
csharp_space_after_cast = true
24+
csharp_space_after_colon_in_inheritance_clause = true
25+
csharp_space_after_comma = true
26+
csharp_space_after_dot = false
27+
csharp_space_after_keywords_in_control_flow_statements = true
28+
csharp_space_after_semicolon_in_for_statement = true
29+
csharp_space_around_binary_operators = before_and_after
30+
csharp_space_around_declaration_statements = do_not_ignore
31+
csharp_space_before_colon_in_inheritance_clause = true
32+
csharp_space_before_comma = false
33+
csharp_space_before_dot = false
34+
csharp_space_before_open_square_brackets = false
35+
csharp_space_before_semicolon_in_for_statement = false
36+
csharp_space_between_empty_square_brackets = false
37+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
38+
csharp_space_between_method_call_name_and_opening_parenthesis = false
39+
csharp_space_between_method_call_parameter_list_parentheses = false
40+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
41+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
42+
csharp_space_between_method_declaration_parameter_list_parentheses = false
43+
csharp_space_between_parentheses = false
44+
csharp_space_between_square_brackets = false
45+
csharp_style_conditional_delegate_call = true:warning
46+
csharp_style_expression_bodied_accessors = when_on_single_line:suggestion
47+
csharp_style_expression_bodied_constructors = false:silent
48+
csharp_style_expression_bodied_indexers = true:suggestion
49+
csharp_style_expression_bodied_methods = false:silent
50+
csharp_style_expression_bodied_operators = true:suggestion
51+
csharp_style_expression_bodied_properties = true:suggestion
52+
csharp_style_inlined_variable_declaration = true:warning
53+
csharp_style_pattern_matching_over_as_with_null_check = true:warning
54+
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
55+
csharp_style_throw_expression = true:warning
56+
csharp_style_var_elsewhere = false:warning
57+
csharp_style_var_for_built_in_types = false:warning
58+
csharp_style_var_when_type_is_apparent = false:silent
59+
dotnet_sort_system_directives_first = false
60+
dotnet_style_coalesce_expression = true:warning
61+
dotnet_style_collection_initializer = true:suggestion
62+
dotnet_style_explicit_tuple_names = true:suggestion
63+
dotnet_style_null_propagation = true:suggestion
64+
dotnet_style_object_initializer = true:silent
65+
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
66+
dotnet_style_predefined_type_for_member_access = true:warning
67+
dotnet_style_qualification_for_event = false:warning
68+
dotnet_style_qualification_for_field = false:warning
69+
dotnet_style_qualification_for_method = false:warning
70+
dotnet_style_qualification_for_property = false:warning
71+
72+
73+
# IDE0090: Use 'new(...)'
74+
dotnet_diagnostic.IDE0090.severity = silent
75+
76+
# IDE0044: Add readonly modifier
77+
dotnet_diagnostic.IDE0044.severity = silent

VortexHelper.sln

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.31112.23
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "vortex-helper", "source\vortex-helper.csproj", "{4302273A-420A-4FB9-A20E-9F0A2D79CE84}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VortexHelper", "source\VortexHelper.csproj", "{4302273A-420A-4FB9-A20E-9F0A2D79CE84}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AF325E54-9A2F-40D2-98F9-0E951DD67BCE}"
9+
ProjectSection(SolutionItems) = preProject
10+
.editorconfig = .editorconfig
11+
EndProjectSection
712
EndProject
813
Global
914
GlobalSection(SolutionConfigurationPlatforms) = preSolution

source/CustomSFX.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
namespace VortexHelper {
2-
class CustomSFX {
1+
namespace Celeste.Mod.VortexHelper {
2+
public class CustomSFX {
33
// Color Switch
44
public const string game_colorSwitch_hit = "event:/vortexHelperEvents/game/colorSwitch/hit";
55

source/Entities/AttachedJumpThru.cs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Celeste.Mod.VortexHelper.Entities {
77
[CustomEntity("VortexHelper/AttachedJumpThru")]
88
[Tracked(false)]
9-
class AttachedJumpThru : JumpThru {
9+
public class AttachedJumpThru : JumpThru {
1010

1111
private int columns;
1212

@@ -28,7 +28,7 @@ public AttachedJumpThru(EntityData data, Vector2 offset)
2828
public AttachedJumpThru(Vector2 position, int width, string overrideTexture, int overrideSoundIndex = -1)
2929
: base(position, width, safe: false) {
3030
columns = width / 8;
31-
Depth = -60; // ?
31+
Depth = Depths.Dust - 10; // ?
3232

3333
this.overrideTexture = overrideTexture;
3434
this.overrideSoundIndex = overrideSoundIndex;
@@ -61,21 +61,12 @@ public override void Awake(Scene scene) {
6161
if (overrideSoundIndex > 0) {
6262
SurfaceSoundIndex = overrideSoundIndex;
6363
} else {
64-
switch (jumpthru.ToLower()) {
65-
case "dream":
66-
SurfaceSoundIndex = 32;
67-
break;
68-
case "temple":
69-
case "templeb":
70-
SurfaceSoundIndex = 8;
71-
break;
72-
case "core":
73-
SurfaceSoundIndex = 3;
74-
break;
75-
default:
76-
SurfaceSoundIndex = 5;
77-
break;
78-
}
64+
SurfaceSoundIndex = (jumpthru.ToLower()) switch {
65+
"dream" => SurfaceIndex.AuroraGlass,
66+
"temple" or "templeb" => SurfaceIndex.Brick,
67+
"core" => SurfaceIndex.Dirt,
68+
_ => SurfaceIndex.Wood,
69+
};
7970
}
8071

8172
MTexture mTexture = GFX.Game["objects/jumpthru/" + areaData.Jumpthru];
@@ -115,7 +106,7 @@ private bool IsRiding(Solid solid) {
115106
if (CollideCheck(solid, Position + Vector2.UnitX) || CollideCheck(solid, Position - Vector2.UnitX)) {
116107
staticMover.Platform = Platform = solid;
117108

118-
if (VisibleWhenDisabled = solid is CassetteBlock || solid is SwitchBlock) {
109+
if (VisibleWhenDisabled = solid is CassetteBlock or SwitchBlock) {
119110
DisabledColor = Color.Lerp(Color.Black, Color.White, .4f);
120111
}
121112
return true;
@@ -164,7 +155,7 @@ private void OnDisable() {
164155
}
165156

166157
private void SetColor(Color color) {
167-
foreach (Component component in base.Components) {
158+
foreach (Component component in Components) {
168159
if (component is Image image) {
169160
image.Color = color;
170161
}

source/Entities/AutoFallingBlock.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Celeste.Mod.VortexHelper.Entities {
88
[CustomEntity("VortexHelper/AutoFallingBlock")]
99
[Tracked]
10-
class AutoFallingBlock : Solid {
10+
public class AutoFallingBlock : Solid {
1111

1212
private TileGrid tiles;
1313
private char TileType;
@@ -121,13 +121,13 @@ private void LandParticles() {
121121

122122
private void ImpactSfx() {
123123
if (TileType == '3') {
124-
Audio.Play("event:/game/01_forsaken_city/fallblock_ice_impact", BottomCenter);
124+
Audio.Play(SFX.game_01_fallingblock_ice_impact, BottomCenter);
125125
} else if (TileType == '9') {
126-
Audio.Play("event:/game/03_resort/fallblock_wood_impact", BottomCenter);
126+
Audio.Play(SFX.game_03_fallingblock_wood_impact, BottomCenter);
127127
} else if (TileType == 'g') {
128-
Audio.Play("event:/game/06_reflection/fallblock_boss_impact", BottomCenter);
128+
Audio.Play(SFX.game_06_fallingblock_boss_impact, BottomCenter);
129129
} else {
130-
Audio.Play("event:/game/general/fallblock_impact", BottomCenter);
130+
Audio.Play(SFX.game_gen_fallblock_impact, BottomCenter);
131131
}
132132
}
133133
}

source/Entities/BowlPuffer.cs

Lines changed: 49 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Celeste.Mod.VortexHelper.Entities {
77
[CustomEntity("VortexHelper/BowlPuffer")]
8-
class BowlPuffer : Actor {
8+
public class BowlPuffer : Actor {
99

1010
[Tracked(false)]
1111
public class BowlPufferCollider : Component {
@@ -330,18 +330,7 @@ private void Explode(bool playsound = true) {
330330
}
331331

332332
private void DoEntityCustomInteraction() {
333-
// Player
334-
Player player = CollideFirst<Player>();
335-
if (player != null) {
336-
player.ExplodeLaunch(Position, snapUp: false, sidesOnly: true);
337-
}
338-
player = SceneAs<Level>().Tracker.GetEntity<Player>();
339-
340-
// Theo Crystal
341-
TheoCrystal theoCrystal = CollideFirst<TheoCrystal>();
342-
if (theoCrystal != null && !Scene.CollideCheck<Solid>(Position, theoCrystal.Center)) {
343-
theoCrystal.ExplodeLaunch(Position);
344-
}
333+
Player player = SceneAs<Level>().Tracker.GetEntity<Player>();
345334

346335
// Touch Switches
347336
foreach (TouchSwitch entity2 in Scene.Tracker.GetEntities<TouchSwitch>()) {
@@ -358,69 +347,57 @@ private void DoEntityCustomInteraction() {
358347
}
359348

360349
foreach (Actor e in CollideAll<Actor>()) {
361-
if (e is Puffer) {
362-
VortexHelperModule.Puffer_Explode.Invoke(e, new object[] { });
363-
VortexHelperModule.Puffer_GotoGone.Invoke(e, new object[] { });
364-
continue;
365-
}
366-
367-
if (e is BowlPuffer && e != this) {
368-
BowlPuffer e_ = e as BowlPuffer;
369-
e_.chainExplode = (!e_.exploded && e_.state != States.Gone);
370-
350+
switch (e) {
351+
case Player p:
352+
p.ExplodeLaunch(Position, snapUp: false, sidesOnly: true);
353+
break;
354+
case TheoCrystal crystal:
355+
if (!Scene.CollideCheck<Solid>(Position, crystal.Center))
356+
crystal.ExplodeLaunch(Position);
357+
break;
358+
case Puffer puffer:
359+
VortexHelperModule.Puffer_Explode.Invoke(puffer, null);
360+
VortexHelperModule.Puffer_GotoGone.Invoke(puffer, null);
361+
break;
362+
case BowlPuffer puffer:
363+
puffer.chainExplode = !puffer.exploded && puffer.state != States.Gone;
364+
break;
371365
}
372366
}
373367

374368
foreach (Solid e in CollideAll<Solid>()) {
375-
// Temple Cracked Blocks
376-
if (e is TempleCrackedBlock) {
377-
(e as TempleCrackedBlock).Break(Position); continue;
378-
}
379-
380-
// Color Switches
381-
if (e is ColorSwitch) {
382-
(e as ColorSwitch).Switch(Calc.FourWayNormal(e.Center - Center)); continue;
383-
}
384-
385-
// Dash Blocks
386-
if (e is DashBlock) {
387-
(e as DashBlock).Break(Center, Calc.FourWayNormal(e.Center - Center), true, true); continue;
388-
}
389-
390-
// Falling Blocks
391-
if (e is FallingBlock) {
392-
(e as FallingBlock).Triggered = true; continue;
393-
}
394-
395-
// Move Blocks
396-
if (e is MoveBlock) {
397-
(e as MoveBlock).OnStaticMoverTrigger(null); continue;
398-
}
399-
400-
// Kevins
401-
if (e is CrushBlock) {
402-
// e.OnDashed(Player player = null, Vector2 direction = Calc.FourWayNormal(e.Center - Center));
403-
VortexHelperModule.CrushBlock_OnDashed.Invoke(e as CrushBlock, new object[] { null, Calc.FourWayNormal(e.Center - Center) });
404-
continue;
405-
}
406-
407-
// Bubble Wrap Blocks
408-
if (e is BubbleWrapBlock) {
409-
(e as BubbleWrapBlock).Break();
410-
continue;
411-
}
412-
413-
// Lightning Breaker Boxes
414-
if (e is LightningBreakerBox) {
415-
if (player != null) {
416-
float stamina = player.Stamina;
417-
int dashes = player.Dashes;
418-
(e as LightningBreakerBox).OnDashCollide(player, Calc.FourWayNormal(e.Center - Center));
419-
player.Dashes = dashes;
420-
player.Stamina = stamina;
421-
}
422-
continue;
423-
}
369+
switch (e) {
370+
case TempleCrackedBlock block:
371+
block.Break(Position);
372+
break;
373+
case ColorSwitch @switch:
374+
@switch.Switch(Calc.FourWayNormal(e.Center - Center));
375+
break;
376+
case DashBlock block:
377+
block.Break(Center, Calc.FourWayNormal(e.Center - Center), true, true);
378+
break;
379+
case FallingBlock block:
380+
block.Triggered = true;
381+
break;
382+
case MoveBlock block:
383+
block.OnStaticMoverTrigger(null);
384+
break;
385+
case CrushBlock block:
386+
VortexHelperModule.CrushBlock_OnDashed.Invoke(block, new object[] { null, Calc.FourWayNormal(block.Center - Center) });
387+
break;
388+
case BubbleWrapBlock block:
389+
block.Break();
390+
break;
391+
case LightningBreakerBox box:
392+
if (player != null) {
393+
float stamina = player.Stamina;
394+
int dashes = player.Dashes;
395+
box.OnDashCollide(player, Calc.FourWayNormal(box.Center - Center));
396+
player.Dashes = dashes;
397+
player.Stamina = stamina;
398+
}
399+
break;
400+
};
424401
}
425402
}
426403

source/Entities/BubbleWrapBlock.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace Celeste.Mod.VortexHelper.Entities {
88
[CustomEntity("VortexHelper/BubbleWrapBlock")]
99
[Tracked(false)]
10-
class BubbleWrapBlock : Solid {
10+
public class BubbleWrapBlock : Solid {
1111

1212
private enum States {
1313
Idle,
@@ -123,7 +123,7 @@ public DashCollisionResults Dashed(Player player, Vector2 direction) {
123123
}
124124

125125
public void Break() {
126-
breakSfx.Play("event:/game/general/wall_break_stone");
126+
breakSfx.Play(SFX.game_gen_wallbreak_stone);
127127

128128
for (int i = 0; i < Width / 8f; i++) {
129129
for (int j = 0; j < Height / 8f; j++) {
@@ -164,7 +164,7 @@ private void Respawn() {
164164
rectEffectInflate = 0f;
165165

166166
EnableStaticMovers();
167-
breakSfx.Play("event:/game/05_mirror_temple/redbooster_reappear");
167+
breakSfx.Play(SFX.game_05_redbooster_reappear);
168168
Collidable = true;
169169
state = States.Idle;
170170
}

0 commit comments

Comments
 (0)