Files
Hunter/scripts/ModeRuntime/Modes/HotPoint.luau
T

42 lines
1.7 KiB
Luau

--!strict
local Runtime = script.Parent.Parent
local Types = require(Runtime.Types)
local Common = require(Runtime.Common)
local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds)
local Strings = require(game.ReplicatedStorage.Hunter.Strings)
local HotPoint = require(Runtime.Parent.HotPoint)
local Sites = require(Runtime.Parent.ArenaObjectiveSites)
local function start(ctx: Types.ModeContext): Types.ModeInstance
local path = Sites.hotPath(ctx.arena, assert(ctx.map), HotPoint.Radius)
local nowAt = ctx.liveAt
local wasContested = false
local capture = HotPoint.start({
state = ctx.state, geometry = ctx.geometry, sites = path, startedAt = ctx.liveAt,
marker = function(site)
ctx.events.fire(Kinds.ZoneStarted, {text = site.name, at = site.position})
return Common.marker(ctx.folder, "HotPoint", Strings.hotPoint, site.position, Common.neutral, HotPoint.Radius * 2)
end,
score = function(side, points)
ctx.scoring.add(side, points, Kinds.ZoneCaptured)
ctx.events.fire(Kinds.ZoneCaptured, {side = side, text = Strings.hotPoint, value = nowAt - ctx.liveAt})
end,
status = ctx.status, contribute = ctx.contribute,
})
return Common.instance(ctx, {
step = function(now, dt, fighters, elapsed)
nowAt = now
capture.step(fighters, now, elapsed or dt)
local contested = ctx.state:GetAttribute("HotPointPhase") == "Contested"
if contested and not wasContested then
ctx.events.fire(Kinds.ZoneContested, {text = Strings.hotPoint})
end
wasContested = contested
return false
end,
hit = capture.hit, death = capture.death, leaving = capture.death, destroy = capture.destroy,
})
end
return {id = "HotPoint", usesMap = true, start = start}