1
This commit is contained in:
commit
a85391509d
211 files changed
+28903
No files matched your search
@@ -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
|
||||
Reference in new issue
Block a user