require 'common.globals' local Animation = require 'api.animation' local Animations = { Crit = Animation.new('gameplay/hit_animation_frames/critical_taps', { centered = true, }), Near = Animation.new('gameplay/hit_animation_frames/near_taps', { centered = true, }), }; local animationStates = { ---@type AnimationState[] Hold = { }, ---@type AnimationState[] Tap = { } }; for i = 1, 6 do --animationStates.Hold[i] = --animationStates.Tap[i] = Animations end local HitFX = { }; local LanePositions = { 1.5 / 6, 2.5 / 6, 3.5 / 6, 4.5 / 6, 1 / 3, 2 / 3 }; local function setupLaneTransform(lanePosition, critCenterX, critCenterY) local critLine = gameplay.critLine; local x = critCenterX + (critLine.line.x2 - critLine.line.x1) * lanePosition; local y = critCenterY + (critLine.line.y2 - critLine.line.y1) * lanePosition; setUpTransforms(x, y, -critLine.rotation); end function HitFX.render(deltaTime, critCenterX, critCenterY, critRotation, cursors) local baseHitSize = 325; for i = 1, 6 do local hitSize = baseHitSize; if (i > 4) then hitSize = hitSize * 1.5; end local laneWidth = (track.GetCurrentLaneXPos(2) - track.GetCurrentLaneXPos(1)) * (i <= 4 and 1 or 2); local lanePosition = track.GetCurrentLaneXPos(i) + laneWidth / 2 if (i == 5) then lanePosition = -track.GetCurrentLaneXPos(6) - laneWidth / 2 end local holdState = animationStates.Hold[i]; local tapState = animationStates.Tap[i]; local isHeld = gameplay.noteHeld[i]; if (isHeld) then if (holdState) then if (not holdState.running) then holdState:restart(); end setupLaneTransform(lanePosition, critCenterX, critCenterY); holdState:render(deltaTime); gfx.ResetTransform(); end else if (holdState and holdState.running) then holdState:restart(); end if (tapState and tapState.running) then setupLaneTransform(lanePosition, critCenterX, critCenterY); tapState:render(deltaTime, { centered = true, width = hitSize, height = hitSize, }); gfx.ResetTransform(); end end end end function HitFX.TriggerAnimation(name, lane) animationStates.Tap[lane] = Animations[name]:start(); end return HitFX;