This commit is contained in:
listik committed 2026-11-29 15:49:17 +03:00
commit a85391509d
211 files changed
+28903

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
--!strict
local Capture = {}
export type Status = "Idle" | "Capturing" | "Contested" | "Decaying" | "Captured"
function Capture.advance(progress: number, dt: number, attack: boolean, defense: boolean, seconds: number, decay: number): (number, Status)
local grows = attack and not defense
local nextProgress = math.clamp(progress + dt * (if grows then 1 else -decay) / seconds, 0, 1)
if nextProgress >= 1 - 1e-9 then return 1, "Captured" end
if defense then return nextProgress, "Contested" end
if grows then return nextProgress, "Capturing" end
return nextProgress, if progress > 0 then "Decaying" else "Idle"
end
return Capture