Skip to content

Commit cc94fe6

Browse files
authored
Merge pull request #8 from aonkeeper4/reskinnable-nonreturnkevins
Reskinnable non-return kevins
2 parents d980810 + 6f3a68a commit cc94fe6

3 files changed

Lines changed: 57 additions & 41 deletions

File tree

Code/Entities/NonReturnCrushBlock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ private IEnumerator AttackSequence()
682682
}, Alarm.AlarmMode.Oneshot);
683683
this.crushDir = Vector2.Zero;
684684
this.TurnOffImages();
685-
this.face.Play("hurt", false, false);
685+
yield return this.face.PlayRoutine("hurt", false);
686686
this.face.Play("idle", false, false);
687687
yield break;
688688
}

Loenn/entities/nonReturnKevin.lua

Lines changed: 51 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local drawableNPatch = require("structs.drawable_nine_patch")
22
local drawableRectangle = require("structs.drawable_rectangle")
33
local drawableSprite = require("structs.drawable_sprite")
4+
local utils = require("utils")
45

56
local axisOptions = {
67
Both = "both",
@@ -12,11 +13,14 @@ local nonReturnKevin = {}
1213

1314
nonReturnKevin.name = "CherryHelper/NonReturnKevin"
1415
nonReturnKevin.depth = 0
15-
nonReturnKevin.minimumSize = {24, 24}
16+
nonReturnKevin.minimumSize = { 24, 24 }
1617
nonReturnKevin.fieldInformation = {
1718
axes = {
1819
options = axisOptions,
1920
editable = false
21+
},
22+
fillColor = {
23+
fieldType = "color",
2024
}
2125
}
2226
nonReturnKevin.placements = {}
@@ -47,70 +51,77 @@ for _, axis in pairs(axisOptions) do
4751
})
4852
end
4953

50-
local frameTextures = {
51-
none = "objects/crushblock/block00",
52-
horizontal = "objects/crushblock/block01",
53-
vertical = "objects/crushblock/block02",
54-
both = "objects/crushblock/block03"
55-
}
54+
for _, axis in pairs(axisOptions) do
55+
table.insert(nonReturnKevin.placements, {
56+
name = "reskinnable" .. axis,
57+
data = {
58+
width = 24,
59+
height = 24,
60+
axes = axis,
61+
altTexture = true,
62+
spriteDirectory = "objects/noReturnKevin",
63+
fillColor = "242262",
64+
chillout = false
65+
}
66+
})
67+
end
5668

57-
local altFrameTextures = {
58-
none = "objects/noReturnKevin/block00",
59-
horizontal = "objects/noReturnKevin/block01",
60-
vertical = "objects/noReturnKevin/block02",
61-
both = "objects/noReturnKevin/block03"
69+
local frameTextures = {
70+
none = "/block00",
71+
horizontal = "/block01",
72+
vertical = "/block02",
73+
both = "/block03"
6274
}
6375

6476
local nPatchOptions = {
6577
mode = "border",
6678
borderMode = "repeat"
6779
}
6880

69-
local kevinColor = {98 / 255, 34 / 255, 43 / 255}
70-
local smallFaceTexture = "objects/crushblock/idle_face"
71-
local giantFaceTexture = "objects/crushblock/giant_block00"
81+
local function isempty(s)
82+
return s == nil or s == ""
83+
end
7284

73-
local altKevinColor = {36 / 255, 34 / 255, 98 / 255}
74-
local altSmallFaceTexture = "objects/noReturnKevin/idle_face"
75-
local altGiantFaceTexture = "objects/noReturnKevin/giant_block00"
85+
local function getBlockStyle(entity)
86+
local entitySpriteDir = entity.altTexture
87+
and (isempty(entity.spriteDirectory) and "objects/noReturnKevin" or entity.spriteDirectory)
88+
or "objects/crushblock"
89+
local frameTexture = entitySpriteDir .. frameTextures[entity.axes or "both"]
90+
local smallFaceTexture = entitySpriteDir .. "/idle_face"
91+
local giantFaceTexture = entitySpriteDir .. "/giant_block00"
92+
local fillColor = entity.altTexture
93+
and (isempty(entity.fillColor) and { 36 / 255, 34 / 255, 98 / 255 } or utils.getColor(entity.fillColor))
94+
or { 98 / 255, 34 / 255, 43 / 255 }
95+
96+
return {
97+
spriteDir = entitySpriteDir,
98+
frameTexture = frameTexture,
99+
smallFaceTexture = smallFaceTexture,
100+
giantFaceTexture = giantFaceTexture,
101+
fillColor = fillColor
102+
}
103+
end
76104

77105
function nonReturnKevin.sprite(room, entity)
78-
local altTexture = entity.altTexture or false
106+
local blockStyle = getBlockStyle(entity)
79107

80108
local x, y = entity.x or 0, entity.y or 0
81109
local width, height = entity.width or 24, entity.height or 24
82110

83-
local axes = entity.axes or "both"
84111
local chillout = entity.chillout
85-
86112
local giant = height >= 48 and width >= 48 and chillout
87113

88-
local faceTexture = giant and giantFaceTexture or smallFaceTexture
89-
if altTexture then
90-
faceTexture = giant and altGiantFaceTexture or altSmallFaceTexture
91-
end
92-
93-
local frameTexture = frameTextures[axes] or frameTextures["both"]
94-
if altTexture then
95-
frameTexture = altFrameTextures[axes] or altFrameTextures["both"]
96-
end
97-
98-
local ninePatch = drawableNPatch.fromTexture(frameTexture, nPatchOptions, x, y, width, height)
99-
100-
local rectangle = drawableRectangle.fromRectangle("fill", x + 2, y + 2, width - 4, height - 4, kevinColor)
101-
if altTexture then
102-
rectangle = drawableRectangle.fromRectangle("fill", x + 2, y + 2, width - 4, height - 4, altKevinColor)
103-
end
114+
local ninePatch = drawableNPatch.fromTexture(blockStyle.frameTexture, nPatchOptions, x, y, width, height)
115+
local rectangle = drawableRectangle.fromRectangle("fill", x + 2, y + 2, width - 4, height - 4, blockStyle.fillColor)
104116

117+
local faceTexture = giant and blockStyle.giantFaceTexture or blockStyle.smallFaceTexture
105118
local faceSprite = drawableSprite.fromTexture(faceTexture, entity)
106119
faceSprite:addPosition(math.floor(width / 2), math.floor(height / 2))
107120

108121
local sprites = ninePatch:getDrawableSprite()
109-
110122
table.insert(sprites, 1, rectangle:getDrawableSprite())
111123
table.insert(sprites, 2, faceSprite)
112-
113124
return sprites
114125
end
115126

116-
return nonReturnKevin
127+
return nonReturnKevin

Loenn/lang/en_gb.lang

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ entities.CherryHelper/NonReturnKevin.placements.name.horizontal=Non Return Kevin
1212
entities.CherryHelper/NonReturnKevin.placements.name.altboth=Non Return Kevin (Alt Texture) (Both)
1313
entities.CherryHelper/NonReturnKevin.placements.name.altvertical=Non Return Kevin (Alt Texture) (Vertical)
1414
entities.CherryHelper/NonReturnKevin.placements.name.althorizontal=Non Return Kevin (Alt Texture) (Horizontal)
15+
entities.CherryHelper/NonReturnKevin.placements.name.reskinnableboth=Non Return Kevin (Reskinnable) (Both)
16+
entities.CherryHelper/NonReturnKevin.placements.name.reskinnablevertical=Non Return Kevin (Reskinnable) (Vertical)
17+
entities.CherryHelper/NonReturnKevin.placements.name.reskinnablehorizontal=Non Return Kevin (Reskinnable) (Horizontal)
18+
entities.CherryHelper/NonReturnKevin.attributes.description.spriteDirectory=Directory custom sprites will be taken from. Custom sprites must be formatted in the same way as vanilla kevins. This option does nothing if the "Alt Texture" field is unchecked.
19+
entities.CherryHelper/NonReturnKevin.attributes.description.fillColor=Fill color of the kevin. This option does nothing if the "Alt Texture" field is unchecked.
1520

1621
entities.CherryHelper/UI_NRCB.placements.name.both=Uninterruptible Non Return Kevin (Both)
1722
entities.CherryHelper/UI_NRCB.placements.name.vertical=Uninterruptible Non Return Kevin (Vertical)

0 commit comments

Comments
 (0)