Skip to content

Commit aca233d

Browse files
committed
add reskin support to boom boxes and boom box zips
1 parent e1e3106 commit aca233d

5 files changed

Lines changed: 23 additions & 20 deletions

File tree

Code/Entities/BoomBox.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class BoomBox : Solid {
3636
private Coroutine _sequence;
3737
private bool _steamAnger = false;
3838

39-
public BoomBox(Vector2 position, string activationId, float initialDelay, bool startActive)
39+
public BoomBox(Vector2 position, string activationId, float initialDelay, bool startActive, string spriteDir)
4040
: base(position, 24, 24, false) {
4141
Add(Activator = new FactoryActivator());
4242
Activator.StartOn = startActive;
@@ -50,14 +50,16 @@ public BoomBox(Vector2 position, string activationId, float initialDelay, bool s
5050

5151
_initialDelay = initialDelay;
5252

53-
Add(_sprite = new Sprite(GFX.Game, "objects/FactoryHelper/boomBox/"));
53+
string spritePath = string.IsNullOrEmpty(spriteDir) ? "objects/FactoryHelper/boomBox/" : spriteDir + "/";
54+
55+
Add(_sprite = new Sprite(GFX.Game, spritePath));
5456
_sprite.Add("idle", "idle", 0.2f, "idle");
5557
_sprite.Add("activating", "activating", 0.2f, "activating");
5658
_sprite.Add("active", "active", 0.15f, "active");
5759
_sprite.Add("angry", "angry", 0.05f, "angry");
5860
_sprite.Add("resetting", "resetting", 0.15f, "active");
5961

60-
Add(_boomSprite = new Sprite(GFX.Game, "objects/FactoryHelper/boomBox/"));
62+
Add(_boomSprite = new Sprite(GFX.Game, spritePath));
6163
_boomSprite.Add("boom", "boom", 0.04f);
6264
_boomSprite.Color = Color.White * 0.5f;
6365
_boomSprite.Visible = false;
@@ -71,7 +73,7 @@ public BoomBox(Vector2 position, string activationId, float initialDelay, bool s
7173
}
7274

7375
public BoomBox(EntityData data, Vector2 offest)
74-
: this(data.Position + offest, data.Attr("activationId", ""), data.Float("initialDelay", 0f), data.Bool("startActive", false)) {
76+
: this(data.Position + offest, data.Attr("activationId", ""), data.Float("initialDelay", 0f), data.Bool("startActive", false), data.Attr("spriteDir", "")) {
7577
}
7678

7779
public FactoryActivator Activator { get; }

Code/Entities/BoomBoxZip.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ public class BoomBoxZip : BoomBox {
1313
private ZipMoverPathRenderer pathRenderer;
1414

1515
public BoomBoxZip(EntityData data, Vector2 offset)
16-
: this(data.Position + offset, data.Attr("activationId", ""), data.Float("initialDelay", 0f), data.Bool("startActive", false), data.Nodes[0] + offset) {
16+
: this(data.Position + offset, data.Attr("activationId", ""), data.Float("initialDelay", 0f), data.Bool("startActive", false), data.Attr("spriteDir", ""), data.Nodes[0] + offset) {
1717
}
1818

19-
public BoomBoxZip(Vector2 position, string activationId, float initialDelay, bool startActive, Vector2 target)
20-
: base(position, activationId, initialDelay, startActive) {
19+
public BoomBoxZip(Vector2 position, string activationId, float initialDelay, bool startActive, string spriteDir, Vector2 target)
20+
: base(position, activationId, initialDelay, startActive, spriteDir) {
2121
Add(new Coroutine(ZipMoverSequence()));
2222
this.start = this.Position;
2323
this.target = target;

Loenn/entities/boom_box.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ boomBox.placements = {
1313
data = {
1414
activationId = "",
1515
initialDelay = 0.0,
16-
startActive = true
16+
startActive = true,
17+
spriteDir = ""
1718
}
1819
}
1920

20-
local inactiveTexture = "objects/FactoryHelper/boomBox/idle00"
21-
local activeTexture = "objects/FactoryHelper/boomBox/active00"
22-
2321
function boomBox.texture(room, entity)
24-
return entity.startActive and activeTexture or inactiveTexture
22+
local spriteDir = (entity.spriteDir or "") == "" and "objects/FactoryHelper/boomBox" or entity.spriteDir
23+
return spriteDir .. (entity.startActive and "/active00" or "/idle00")
2524
end
2625

2726
boomBox.justification = {0.0, 0.0}

Loenn/entities/boom_box_zip.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ boomBoxZip.placements = {
2424
width = 24,
2525
activationId = "",
2626
initialDelay = 0.0,
27-
startActive = true
27+
startActive = true,
28+
spriteDir = ""
2829
}
2930
}
3031

31-
local inactiveTexture = "objects/FactoryHelper/boomBox/idle00"
32-
local activeTexture = "objects/FactoryHelper/boomBox/active00"
3332
local cogTexture = "objects/zipmover/cog"
3433
local ropeColor = {77 / 255, 60 / 255, 34 / 255}
3534

@@ -61,10 +60,10 @@ end
6160

6261
function boomBoxZip.sprite(room, entity)
6362
local sprites = {}
64-
63+
6564
local x, y = entity.x or 0, entity.y or 0
6665
local nodes = entity.nodes or {{x = 0, y = 0}}
67-
66+
6867
-- Draw cog + rope
6968
local halfWidth = 12
7069
local centerX = x + halfWidth
@@ -74,19 +73,20 @@ function boomBoxZip.sprite(room, entity)
7473
addNodeSprites(sprites, entity, centerX, centerY, centerNodeX, centerNodeY)
7574

7675
-- Draw boom box
77-
local boomBoxTex = entity.startActive and activeTexture or inactiveTexture
76+
local spriteDir = (entity.spriteDir or "") == "" and "objects/FactoryHelper/boomBox" or entity.spriteDir
77+
local boomBoxTex = spriteDir .. (entity.startActive and "/active00" or "/idle00")
7878
local boomBoxSprite = drawableSprite.fromTexture(boomBoxTex, entity)
7979
boomBoxSprite:setPosition(centerX, centerY)
8080
boomBoxSprite:setJustification(0.5, 0.5)
8181
table.insert(sprites, boomBoxSprite)
82-
82+
8383
return sprites
8484
end
8585

8686
function boomBoxZip.selection(room, entity)
8787
local x, y = entity.x or 0, entity.y or 0
8888
local nodes = entity.nodes or {{x = 0, y = 0}}
89-
89+
9090
local halfWidth = 12
9191
local centerX = x + halfWidth
9292
local centerY = y + halfWidth

Loenn/lang/en_gb.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ entities.FactoryHelper/BoomBox.placements.name.active=Boom Box
1313
entities.FactoryHelper/BoomBox.attributes.description.activationId=String value of the entity's activator ID. When a factory activator with this ID is turned on, the entity will toggle state.
1414
entities.FactoryHelper/BoomBox.attributes.description.initialDelay=The time it takes before the box starts turning on in seconds after activated.
1515
entities.FactoryHelper/BoomBox.attributes.description.startActive=If `true` the boom box will initially be active.
16+
entities.FactoryHelper/BoomBox.attributes.description.spriteDir=The directory to look in for boom box sprites, relative to "Graphics/Atlases/Gameplay/".\nThe directory must contain "idle", "activating", "active", "angry", and "resetting" animations for the block, and a "boom" animation for the explosion.\nIf left empty, the default sprites in "objects/FactoryHelper/boomBox" will be used.
1617

1718
# Boom Box Zip
1819
entities.FactoryHelper/BoomBoxZip.placements.name.active=Boom Box Zip
1920
entities.FactoryHelper/BoomBoxZip.attributes.description.activationId=String value of the entity's activator ID. When a factory activator with this ID is turned on, the entity will toggle state.
2021
entities.FactoryHelper/BoomBoxZip.attributes.description.initialDelay=The time it takes before the box starts turning on in seconds after activated.
2122
entities.FactoryHelper/BoomBoxZip.attributes.description.startActive=If `true` the boom box will initially be active.
23+
entities.FactoryHelper/BoomBoxZip.attributes.description.spriteDir=The directory to look in for boom box sprites, relative to "Graphics/Atlases/Gameplay/".\nThe directory must contain "idle", "activating", "active", "angry", and "resetting" animations for the block, and a "boom" animation for the explosion.\nIf left empty, the default sprites in "objects/FactoryHelper/boomBox" will be used.
2224

2325
# Conveyor
2426
entities.FactoryHelper/Conveyor.placements.name.start_left=Conveyor (Left)

0 commit comments

Comments
 (0)