Refactor arena modes and add objective event feed
This commit is contained in:
1 parent
df6ab8efe1
commit
b87a3770a1
26 files changed
+1221
-654
No files matched your search
@@ -0,0 +1,62 @@
|
||||
--!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 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()
|
||||
local contributions: {[number]: {[string]: number}} = {}
|
||||
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, function(_, points, reason, player)
|
||||
if not reason or not player then return end
|
||||
local stats = contributions[player.UserId] or {}
|
||||
stats[reason] = (stats[reason] or 0) + points
|
||||
contributions[player.UserId] = stats
|
||||
end),
|
||||
events = Events.new(config.members),
|
||||
status = function(value)
|
||||
if state:GetAttribute("ObjectiveStatus") ~= value then state:SetAttribute("ObjectiveStatus", value) end
|
||||
end,
|
||||
setStage = function(stage) 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
|
||||
Reference in new issue
Block a user