Skip to content

Commit

Permalink
stuff kinda but whatever i dont know
Browse files Browse the repository at this point in the history
  • Loading branch information
earthwise01 committed Dec 30, 2024
1 parent 374d135 commit 1cdc5d0
Show file tree
Hide file tree
Showing 13 changed files with 352 additions and 173 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 67 additions & 16 deletions Loenn/entities/resizable_waterfall.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ local resizableWaterfall = {}

resizableWaterfall.name = "SorbetHelper/BigWaterfall"
resizableWaterfall.canResize = {true, false}
resizableWaterfall.minimumSize = {16, 0}
resizableWaterfall.minimumSize = {8, 0}
resizableWaterfall.fieldInformation = {
depth = {
fieldType = "integer",
options = {-9999, -49900},
editable = true
},
color = {
fieldType = "color",
allowXNAColors = false
},
wavePercent = {
options = {1.0, 0.8},
minimumValue = 0,
maximumValue = 1
}
}

Expand All @@ -34,21 +40,23 @@ resizableWaterfall.placements = {
name = "normal",
alternativeName = "bigwaterfall",
data = {
width = 16,
width = 8,
color = "87CEFA",
ignoreSolids = false,
lines = true,
wavePercent = 1.0,
depth = -9999
}
},
{
name = "abovefg",
alternativeName = "bigwaterfallabove",
data = {
width = 16,
width = 8,
color = "87CEFA",
ignoreSolids = true,
lines = true,
wavePercent = 1.0,
depth = -49900
}
}
Expand Down Expand Up @@ -100,22 +108,65 @@ local function getWaterfallHeight(room, entity, ignoreTiles)
return wantedHeight
end

function resizableWaterfall.sprite(room, entity)
-- height isn't ever supposed to be anything other than nil but it's probably bad practice to actively remove data anyway? meaning we back up the existing height value before doing a hackfix
local entityHeightHackfix = entity.height
-- temporarily change the height and layer to make the waterfall Actually Work visually
entity.height = getWaterfallHeight(room, entity, entity.ignoreSolids)
entity.layer = "FG"
local function getWithAlpha(color, alpha)
return { color[1] * alpha, color[2] * alpha, color[3] * alpha, alpha }
end

-- adapted from loenn's waterfall helper with some edits
local function getWaterfallSprite(room, entity, fillColor, borderColor)
local x, y = entity.x or 0, entity.y or 0
local width, height = entity.width or 16, getWaterfallHeight(room, entity, entity.ignoreSolids)

local hasLines = entity.lines or false
-- local linesOffset = (width <= 8 ? 1 : 2)
local borderOffset = (width <= 8 ? 1 : 2)

local sprites = {}

local middleRectangle = drawableRectangle.fromRectangle("fill", x, y, width, height, fillColor)
local leftRectangle = drawableRectangle.fromRectangle("fill", x - 1, y, borderOffset, height, borderColor)
local rightRectangle = drawableRectangle.fromRectangle("fill", x + width + 1 - borderOffset, y, borderOffset, height, borderColor)

table.insert(sprites, middleRectangle:getDrawableSprite())
table.insert(sprites, leftRectangle:getDrawableSprite())
table.insert(sprites, rightRectangle:getDrawableSprite())

local addWaveLineSprite = waterfallHelper.addWaveLineSprite

-- Add wave pattern
for i = 0, height, 21 do
-- From left to right in the waterfall
-- Parts connected to side borders
addWaveLineSprite(sprites, y, height, x - 1 + borderOffset, y + i + 9, 1, 12, borderColor)
addWaveLineSprite(sprites, y, height, x + borderOffset, y + i + 11, 1, 8, borderColor)
addWaveLineSprite(sprites, y, height, x + width - 1 - borderOffset, y + i, 1, 9, borderColor)
addWaveLineSprite(sprites, y, height, x + width - 0 - borderOffset, y + i - 2, 1, 13, borderColor)

if hasLines then
-- Wave on left border
addWaveLineSprite(sprites, y, height, x + 0 + borderOffset, y + i, 1, 9, borderColor)
addWaveLineSprite(sprites, y, height, x + 1 + borderOffset, y + i + 9, 1, 2, borderColor)
addWaveLineSprite(sprites, y, height, x + 1 + borderOffset, y + i + 19, 1, 2, borderColor)
addWaveLineSprite(sprites, y, height, x + 2 + borderOffset, y + i + 11, 1, 8, borderColor)

-- Wave on right border
addWaveLineSprite(sprites, y, height, x + width - 1 - borderOffset, y + i - 10, 1, 8, borderColor)
addWaveLineSprite(sprites, y, height, x + width - 2 - borderOffset, y + i - 2, 1, 2, borderColor)
addWaveLineSprite(sprites, y, height, x + width - 2 - borderOffset, y + i + 9, 1, 2, borderColor)
addWaveLineSprite(sprites, y, height, x + width - 3 - borderOffset, y + i, 1, 9, borderColor)
end
end

return sprites
end

function resizableWaterfall.sprite(room, entity)
local color = utils.getColor(entity.color)
local fillColor = getWithAlpha(color, 0.3)
local borderColor = getWithAlpha(color, 0.8)

local result = getWaterfallSprite(room, entity, fillColor, borderColor)

local fillColor = {color[1] * 0.3, color[2] * 0.3, color[3] * 0.3, 0.3}
local borderColor = {color[1] * 0.8, color[2] * 0.8, color[3] * 0.8, 0.8}
-- using the hackfixed height and layer values from earlier, grab a correct big waterfall sprite
local result = waterfallHelper.getBigWaterfallSprite(room, entity, fillColor, borderColor)
-- reset the height back to what it was before (it *should* always be nil but we're doing this instead of just setting it to nil due to the reason stated earlier)
entity.height = entityHeightHackfix
entity.layer = nil
return result
end

Expand Down
6 changes: 3 additions & 3 deletions Loenn/entities/return_bubble_behavior.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local easings = require("mods").requireFromPlugin("libraries.easings")
local collisionModes = { "Vanilla", "DisableSquish", "NoCollide" }
local collisionModes = { "Vanilla", "SquishFix", "TriggersOnly", "NoCollide" }

local returnBubbleBehavior = {}

Expand All @@ -14,8 +14,8 @@ returnBubbleBehavior.placements = {
easing = "SineInOut", -- this is a mistake probably but whatever
smoothCamera = true, -- vanilla value is off but its nicer on i think
-- canSkip = false,
-- refillDash = false,
collisionMode = "DisableSquish"
refillDash = false,
collisionMode = "SquishFix"
}
}
returnBubbleBehavior.fieldInformation = {
Expand Down
11 changes: 8 additions & 3 deletions Loenn/entities/strawberry_with_return.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ end

function return_berry.sprite(room, entity, viewport)
local bubbleTexture = "characters/player/bubble"
local smallBubbleTexture = "particles/bubble"
local berryTexture = ""

local x, y = entity.x or 0, entity.y or 0
Expand All @@ -131,16 +132,20 @@ function return_berry.sprite(room, entity, viewport)

local sprites = {}

-- bubbles behind berry
table.insert(sprites, drawableSprite.fromTexture(smallBubbleTexture, {x = x + 2, y = y - 8, color = getWhite(0.25)}))

-- berry
table.insert(sprites, drawableSprite.fromTexture(berryTexture, entity))

-- bubbles above berry
table.insert(sprites, drawableSprite.fromTexture(smallBubbleTexture, {x = x - 5, y = y - 2, color = getWhite(0.6)}))
table.insert(sprites, drawableSprite.fromTexture(smallBubbleTexture, {x = x + 4, y = y + 3, color = getWhite(0.6)}))

-- end bubble
local nx, ny = nodes[2].x or 0, nodes[2].y or 0
table.insert(sprites, drawableSprite.fromTexture(bubbleTexture, {x = nx, y = ny, color = getWhite(0.5)}))

-- bubble around berry
-- table.insert(sprites, drawableSprite.fromTexture(emptyBubbleTexture, {x = x, y = y, color = getWhite(0.2)}))

-- seeds
addSeeds(sprites, entity, false)

Expand Down
Loading

0 comments on commit 1cdc5d0

Please sign in to comment.