Skip to content

Commit 99e9985

Browse files
committed
Add reskin functionnality to vortex bumper
1 parent 7bd0b7d commit 99e9985

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

Ahorn/entities/vortexCustomBumper.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ styles_options = String["Green", "Orange"]
77
x::Integer, y::Integer,
88
style::String="Green",
99
nodes::Array{Tuple{Integer, Integer}, 1}=Tuple{Integer, Integer}[],
10-
notCoreMore::Bool = false, wobble::Bool = true)
10+
notCoreMore::Bool=false, wobble::Bool=true,
11+
sprite::String="")
1112

1213
const placements = Ahorn.PlacementDict(
1314
"Bumper ($style) (Vortex Helper)" => Ahorn.EntityPlacement(

source/Entities/VortexBumper.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,29 @@ public class VortexBumper : Entity {
3535
private bool wobble;
3636

3737
public VortexBumper(EntityData data, Vector2 offset)
38-
: this(data.Position + offset, data.FirstNodeNullable(offset), data.Attr("style", "Green"), data.Bool("notCoreMore"), data.Bool("wobble", true)) { }
38+
: this(data.Position + offset, data.FirstNodeNullable(offset), data.Attr("style", "Green"), data.Bool("notCoreMore"), data.Bool("wobble", true), data.Attr("sprite").Trim().TrimEnd('/')) { }
3939

40-
public VortexBumper(Vector2 position, Vector2? node, string style, bool notCoreMode, bool wobble)
40+
public VortexBumper(Vector2 position, Vector2? node, string style, bool notCoreMode, bool wobble, string customSpritePath)
4141
: base(position) {
4242
Collider = new Circle(12f);
4343
Add(new PlayerCollider(OnPlayer));
4444

4545
Add(sine = new SineWave(0.44f, 0f).Randomize());
4646
this.wobble = wobble;
4747

48+
if (!string.IsNullOrEmpty(customSpritePath))
49+
sprite = BuildCustomSprite(customSpritePath, style.ToLower());
50+
4851
switch (style) {
4952
default:
5053
case "Green":
51-
sprite = VortexHelperModule.VortexBumperSpriteBank.Create("greenBumper");
54+
sprite ??= VortexHelperModule.VortexBumperSpriteBank.Create("greenBumper");
5255
twoDashes = true;
5356
p_ambiance = P_GreenAmbience;
5457
p_launch = P_GreenLaunch;
5558
break;
5659
case "Orange":
57-
sprite = VortexHelperModule.VortexBumperSpriteBank.Create("orangeBumper");
60+
sprite ??= VortexHelperModule.VortexBumperSpriteBank.Create("orangeBumper");
5861
oneUse = true;
5962
p_ambiance = P_OrangeAmbience;
6063
p_launch = P_OrangeLaunch;
@@ -99,6 +102,26 @@ public VortexBumper(Vector2 position, Vector2? node, string style, bool notCoreM
99102
}
100103
}
101104

105+
private static Sprite BuildCustomSprite(string path, string name) {
106+
Sprite sprite = new Sprite(GFX.Game, path + "/");
107+
108+
// <Anim id="on" path=name frames="42-44" delay="0.06" goto="idle"/>
109+
sprite.Add("on", name, 0.06f, "idle", 42, 43, 44);
110+
111+
// <Loop id="idle" path=name frames="0-33" delay="0.06"/>
112+
sprite.AddLoop("idle", name, 0.06f, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33); // yes
113+
114+
// <Anim id="hit" path=name frames="34-42" delay="0.06" goto="off"/>
115+
sprite.Add("hit", name, 0.06f, "off", 34, 35, 36, 37, 38, 39, 40, 41, 42);
116+
117+
// <Loop id="off" path=name frames="42" delay="0.06"/>
118+
sprite.AddLoop("off", name, 0.06f, 42);
119+
120+
sprite.JustifyOrigin(0.5f, 0.5f);
121+
sprite.Play("idle");
122+
return sprite;
123+
}
124+
102125
public override void Added(Scene scene) {
103126
base.Added(scene);
104127
if (!notCoreMode) {

0 commit comments

Comments
 (0)