261 lines
9.2 KiB
Lua
261 lines
9.2 KiB
Lua
-- YataiDON-HSS override of PyTaikoGreen/background/bg_collabs/imas.lua
|
|
-- (ROUND 52, r52-lua-divergence-fixes): byte-copy of the parent plus the reference
|
|
-- dance_b_* dancer-count model, the fever falling edge, and the renda
|
|
-- drumroll-only rule -- see collab_dancer_model.lua / background.lua.
|
|
local DonBGBase = require("background/bg_objects/donbg/base")
|
|
local Fever = require("background/bg_objects/fever")
|
|
local Footer = require("background/bg_objects/footer")
|
|
local Dancer = require("background/bg_objects/dancer")
|
|
local RendaController = require("background/bg_objects/renda")
|
|
local ChibiController = require("background/bg_objects/chibi")
|
|
local DancerModel = require("background/bg_objects/collab_dancer_model")
|
|
|
|
local COLLAB_PATH -- set per-variant in create()
|
|
local MAX_DANCERS -- set per-variant in create()
|
|
|
|
-- Spotlight colors: {r,g,b,a}
|
|
local SPOTLIGHT_COLORS = {
|
|
{ 0, 255, 255, 255 }, -- cyan
|
|
{ 255, 255, 0, 255 }, -- yellow
|
|
{ 255, 0, 255, 255 }, -- magenta
|
|
{ 0, 255, 255, 255 }, -- cyan
|
|
{ 255, 255, 0, 255 }, -- yellow
|
|
}
|
|
|
|
-- BGNormal: flicker fade + 5 alternating spotlights
|
|
local ImasBGNormal = {}
|
|
ImasBGNormal.__index = ImasBGNormal
|
|
|
|
function ImasBGNormal.new(path)
|
|
local self = setmetatable({}, ImasBGNormal)
|
|
self.name = "bg_0"
|
|
self.path = path
|
|
tex.load_folder(path, "bg_normal/" .. self.name)
|
|
self.overlay_fade = anim.fade(1000, {
|
|
initial_opacity = 0.0,
|
|
final_opacity = 1.0,
|
|
reverse_delay = 500,
|
|
delay = 500,
|
|
loop = true
|
|
})
|
|
self._id_bg = tex.get_id(self.name, "background") or 0
|
|
self._id_overlay = tex.get_id(self.name, "overlay") or 0
|
|
self._id_spotlight = tex.get_id(self.name, "spotlight") or 0
|
|
return self
|
|
end
|
|
|
|
function ImasBGNormal:update(current_time_ms)
|
|
self.overlay_fade:update(current_time_ms)
|
|
end
|
|
|
|
function ImasBGNormal:draw()
|
|
local ov = self.overlay_fade.attribute
|
|
tex.draw_texture(self._id_bg)
|
|
tex.draw_texture(self._id_overlay, { fade = ov })
|
|
for i = 0, 4 do
|
|
local fade = (i % 2 == 0) and math.min(0.5, ov) or math.min(0.5, 1 - ov)
|
|
tex.draw_texture(self._id_spotlight, {
|
|
index = i, color = SPOTLIGHT_COLORS[i + 1], fade = fade
|
|
})
|
|
end
|
|
end
|
|
|
|
function ImasBGNormal:destroy()
|
|
tex.unload_folder(self.path, "bg_normal/" .. self.name)
|
|
end
|
|
|
|
-- BGFever: same flicker fade + spotlights + orange/green lights
|
|
local ImasBGFever = {}
|
|
ImasBGFever.__index = ImasBGFever
|
|
|
|
function ImasBGFever.new(path)
|
|
local self = setmetatable({}, ImasBGFever)
|
|
self.name = "bg_fever_0"
|
|
self.path = path
|
|
tex.load_folder(path, "bg_fever/" .. self.name)
|
|
self.transitioned = false
|
|
self.overlay_fade = anim.fade(1000, {
|
|
initial_opacity = 0.0,
|
|
final_opacity = 1.0,
|
|
reverse_delay = 500,
|
|
delay = 500,
|
|
loop = true
|
|
})
|
|
self._id_bg = tex.get_id(self.name, "background") or 0
|
|
self._id_overlay = tex.get_id(self.name, "overlay") or 0
|
|
self._id_light_orange = tex.get_id(self.name, "light_orange") or 0
|
|
self._id_light_green = tex.get_id(self.name, "light_green") or 0
|
|
self._id_spotlight = tex.get_id(self.name, "spotlight") or 0
|
|
return self
|
|
end
|
|
|
|
function ImasBGFever:start()
|
|
self.transitioned = true
|
|
end
|
|
|
|
function ImasBGFever:update(current_time_ms)
|
|
self.overlay_fade:update(current_time_ms)
|
|
end
|
|
|
|
function ImasBGFever:draw()
|
|
local ov = self.overlay_fade.attribute
|
|
tex.draw_texture(self._id_bg)
|
|
tex.draw_texture(self._id_overlay, { fade = ov })
|
|
tex.draw_texture(self._id_light_orange, { fade = ov })
|
|
tex.draw_texture(self._id_light_green, { fade = 1 - ov })
|
|
for i = 0, 4 do
|
|
local fade = (i % 2 == 0) and math.min(0.5, ov) or math.min(0.5, 1 - ov)
|
|
tex.draw_texture(self._id_spotlight, {
|
|
index = i, color = SPOTLIGHT_COLORS[i + 1], fade = fade
|
|
})
|
|
end
|
|
end
|
|
|
|
function ImasBGFever:destroy()
|
|
tex.unload_folder(self.path, "bg_fever/" .. self.name)
|
|
end
|
|
|
|
-- Fever: BaseFever + 2-frame texture_change overlay (2-beat cycle)
|
|
-- ROUND 58 (r58-2p-background-polish): the class now CHAINS to Fever.Base
|
|
-- (metatable __index) instead of only copying a base instance's fields --
|
|
-- the ROUND 52 per-method stop/destroy/is_visible/alpha shims are gone, and
|
|
-- any method Fever.Base gains in the future is inherited automatically
|
|
-- (this was the "copied-fields-without-metatable" latent pattern that made
|
|
-- destroy unreachable before ROUND 52).
|
|
local ImasFever = setmetatable({}, { __index = Fever.Base })
|
|
ImasFever.__index = ImasFever
|
|
|
|
function ImasFever.new(bpm, path)
|
|
local self = setmetatable({}, ImasFever)
|
|
local base = Fever.Base.new(0, bpm, path)
|
|
for k, v in pairs(base) do self[k] = v end
|
|
local total = 120000 / bpm
|
|
self.texture_change = anim.texture_change(total, {
|
|
{ 0, total / 2, 0 },
|
|
{ total / 2, total, 1 }
|
|
}, { loop = true })
|
|
return self
|
|
end
|
|
|
|
-- start/stop/destroy/is_visible/alpha: inherited from Fever.Base via the
|
|
-- ROUND 58 metatable chain above.
|
|
|
|
function ImasFever:update(current_time_ms, bpm)
|
|
Fever.Base.update(self, current_time_ms, bpm)
|
|
self.texture_change:update(current_time_ms)
|
|
end
|
|
|
|
function ImasFever:draw()
|
|
local a = self:alpha()
|
|
if a <= 0.001 then return end
|
|
local y = self.bounce_down.attribute - self.bounce_up.attribute
|
|
tex.draw_texture(self._id_overlay, { y = y, frame = self.texture_change.attribute, fade = a })
|
|
end
|
|
|
|
-- Background factory (used for IMAS, IMAS_CG, IMAS_ML)
|
|
|
|
local ImasBackground = {}
|
|
ImasBackground.__index = ImasBackground
|
|
|
|
function ImasBackground.new(player_num, bpm, path, max_dancers)
|
|
local self = setmetatable({}, ImasBackground)
|
|
self.donbg = DonBGBase.new(1, player_num, path)
|
|
self.bg_normal = ImasBGNormal.new(path)
|
|
self.bg_fever = ImasBGFever.new(path)
|
|
self.footer = Footer.new(path, 0)
|
|
self.fever = ImasFever.new(bpm, path)
|
|
self.dancer = Dancer.BaseDancerGroup.new(0, bpm, max_dancers, path)
|
|
self.renda = RendaController.new(path, 0)
|
|
self.chibi = ChibiController.new(bpm, path, 0)
|
|
self.max_dancers = max_dancers
|
|
self.is_clear = false
|
|
self.is_rainbow = false
|
|
-- ROUND 52 (r52-lua-divergence-fixes): reference dance_b_* count model
|
|
-- (collab_dancer_model.lua) replaces the pre-R18 milestone counter.
|
|
self.dancer_model = DancerModel.new(max_dancers)
|
|
return self
|
|
end
|
|
|
|
function ImasBackground:update(current_ms, bpm)
|
|
self.donbg:update(current_ms)
|
|
self.bg_normal:update(current_ms)
|
|
self.bg_fever:update(current_ms)
|
|
self.fever:update(current_ms, bpm)
|
|
self.dancer:update(current_ms, bpm)
|
|
self.renda:update(current_ms)
|
|
self.chibi:update(current_ms, bpm)
|
|
end
|
|
|
|
function ImasBackground:handle_good(player_num) self.chibi:add_chibi(player_num, false) end
|
|
|
|
function ImasBackground:handle_ok(player_num) self.chibi:add_chibi(player_num, false) end
|
|
|
|
function ImasBackground:handle_bad(player_num) self.chibi:add_chibi(player_num, true) end
|
|
|
|
function ImasBackground:handle_drumroll(player_num) self.renda:add_renda() end
|
|
|
|
-- ROUND 52: no renda on balloons/kusudama -- the reference build RendaEffect fires for
|
|
-- note kinds 6/9 (drumrolls) only; see background.lua.
|
|
function ImasBackground:handle_balloon(player_num) end
|
|
|
|
function ImasBackground:handle_gauge(player_num, progress, is_clear, is_rainbow, clear_progress)
|
|
self.donbg:set_clear(is_clear)
|
|
-- ROUND 52: both edges, re-triggerable (the reference build BgFever/FeverEffect::Process).
|
|
if is_clear and not self.is_clear then self.bg_fever:start() end
|
|
if not is_clear and self.is_clear and self.bg_fever.reset then self.bg_fever:reset() end
|
|
if is_rainbow and not self.is_rainbow then self.fever:start() end
|
|
if not is_rainbow and self.is_rainbow and self.fever.stop then self.fever:stop() end
|
|
self.is_clear = is_clear
|
|
self.is_rainbow = is_rainbow
|
|
|
|
-- ROUND 52: reference dance_b_* model, symmetric every frame.
|
|
self.dancer_model:apply(self.dancer, progress, is_clear, clear_progress)
|
|
end
|
|
|
|
function ImasBackground:draw_back()
|
|
if self.is_clear then
|
|
if not self.bg_fever.transitioned then
|
|
self.bg_normal:draw()
|
|
self.bg_fever:draw()
|
|
else
|
|
self.bg_fever:draw()
|
|
end
|
|
else
|
|
self.bg_normal:draw()
|
|
end
|
|
self.donbg:draw()
|
|
self.renda:draw()
|
|
self.dancer:draw()
|
|
self.footer:draw()
|
|
-- ROUND 52: covers the exit ramp, not just the raw flag.
|
|
if self.fever.is_visible and self.fever:is_visible() then self.fever:draw() end
|
|
self.chibi:draw()
|
|
end
|
|
|
|
function ImasBackground:draw_fore() end
|
|
|
|
function ImasBackground:destroy()
|
|
self.donbg:destroy()
|
|
self.bg_normal:destroy()
|
|
self.bg_fever:destroy()
|
|
self.fever:destroy()
|
|
self.dancer:destroy()
|
|
self.footer:destroy()
|
|
self.renda:destroy()
|
|
self.chibi:destroy()
|
|
end
|
|
|
|
-- Export the factory and the ImasFever class (reused by imas_sidem)
|
|
local Imas = {}
|
|
Imas.new = ImasBackground.new
|
|
Imas.ImasFever = ImasFever
|
|
|
|
-- Callable as a collab constructor: Imas.new(player_num, bpm, path, max_dancers)
|
|
setmetatable(Imas, {
|
|
__call = function(_, player_num, bpm, path, max_dancers)
|
|
return ImasBackground.new(player_num, bpm, path, max_dancers)
|
|
end
|
|
})
|
|
|
|
return Imas
|