Files

63 lines
2.6 KiB
Luau

--!strict
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ArenaModes = require(ReplicatedStorage.ArenaModes)
local Sites = require(script.Parent.Parent.ArenaObjectiveSites)
local Types = require(script.Parent.Types)
local Common = require(script.Parent.Common)
local Scoring = require(script.Parent.Scoring)
local Events = require(script.Parent.Events)
local Janitor = require(script.Parent.Janitor)
local Stats = require(script.Parent.Stats)
local Profiles = require(ReplicatedStorage.Hunter.ModeProfiles)
local Context = {}
function Context.collect(members: {Player}): {Types.Fighter}
local found: {Types.Fighter} = {}
for _, p in members do
local side = Common.sideOf(p)
local c = p.Character
local h = c and c:FindFirstChildOfClass("Humanoid")
local r = c and c:FindFirstChild("HumanoidRootPart")
if side and h and h.Health > 0 and r and r:IsA("BasePart") and p:GetAttribute("InArena") == true
and p:GetAttribute("ArenaWaiting") ~= true then
table.insert(found, {player = p, side = side, root = r})
end
end
return found
end
function Context.create(config: Types.Config, mode: Types.Mode, legacy: RemoteEvent): Types.ModeContext
local state = config.state
local world = ArenaModes.geometry(config.arena)
local geometry = ArenaModes.collision(config.arena)
local map = if mode.usesMap then Sites.resolve(config.arena) else nil
local folder = Instance.new("Folder")
folder.Name = "MatchObjectives"
folder.Parent = world
local janitor = Janitor.new()
state:SetAttribute("ObjectiveStatus", "")
state:SetAttribute("ResultReason", nil)
return {
arena = config.arena, rule = config.rule, state = state, liveAt = config.now, duration = config.duration,
world = world, geometry = geometry, map = map, folder = folder, janitor = janitor,
members = config.members, bench = config.bench, deploy = config.deploy, balanceWaiting = config.balanceWaiting,
scoring = Scoring.new(state, nil, Profiles[config.rule].scoreMultiplierInFinalPush),
contribute = Stats.add,
events = Events.new(config.members),
status = function(value)
if state:GetAttribute("ObjectiveStatus") ~= value then state:SetAttribute("ObjectiveStatus", value) end
end,
setStage = function(stage, stageEndsAt)
if stageEndsAt then state:SetAttribute("StageEndsAt", stageEndsAt) end
state:SetAttribute("RoundStage", stage)
end,
cue = function(fighters, captured, side)
for _, fighter in fighters do
if captured or fighter.side == side then legacy:FireClient(fighter.player, captured) end
end
end,
legacy = function(player, name) legacy:FireClient(player, name) end,
}
end
return Context