POC for health panels in MP
This commit is contained in:
@@ -1,15 +1,26 @@
|
||||
local CommandsData = require("TOC/CommandsData")
|
||||
local ServerDataHandler = require("TOC/ServerDataHandler")
|
||||
|
||||
----------------------------
|
||||
|
||||
local DebugCommands = {}
|
||||
|
||||
---comment
|
||||
---@param playerObj IsoPlayer
|
||||
---@param args table
|
||||
function DebugCommands.PrintAllTocData(playerObj, args)
|
||||
TOC_DEBUG.printTable(ServerDataHandler.modData)
|
||||
end
|
||||
|
||||
|
||||
|
||||
---comment
|
||||
---@param playerObj IsoPlayer
|
||||
---@param args {username : string}
|
||||
---@param args printTocDataParams
|
||||
function DebugCommands.PrintTocData(playerObj, args)
|
||||
local data = ModData.get(CommandsData.GetKey(args.username))
|
||||
TOC_DEBUG.printTable(data)
|
||||
local key = CommandsData.GetKey(args.username)
|
||||
local tocData = ServerDataHandler.GetTable(key)
|
||||
TOC_DEBUG.printTable(tocData)
|
||||
end
|
||||
|
||||
--------------------
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
-- TODO Switch EVERYTHING to global mod data
|
||||
|
||||
local CommandsData = require("TOC/CommandsData")
|
||||
|
||||
local ServerDataCommands = {}
|
||||
local moduleName = "test_sync"
|
||||
|
||||
|
||||
local function PrintModDataTable(key, table)
|
||||
print("Received key: " .. key)
|
||||
end
|
||||
|
||||
|
||||
Events.OnReceiveGlobalModData.Add(PrintModDataTable)
|
||||
|
||||
|
||||
|
||||
-- TODO Consider delays
|
||||
|
||||
|
||||
|
||||
|
||||
-- TODO Use transmit from client
|
||||
-- ---comment
|
||||
-- ---@param playerObj IsoPlayer
|
||||
-- ---@param args any
|
||||
-- function ServerDataCommands.AddTable(playerObj, args)
|
||||
-- ModData.add(GetKey(playerObj), args.tocData)
|
||||
-- end
|
||||
|
||||
|
||||
-- function ServerDataCommands.GetTable(playerObj, args)
|
||||
-- local requestedPlayer = getSpecificPlayer(args.playerNum)
|
||||
-- local data = ModData.get(CommandsData.GetKey(requestedPlayer))
|
||||
|
||||
-- -- TODO Request from that client again just to be sure that it's synced?
|
||||
|
||||
-- sendServerCommand()
|
||||
-- end
|
||||
|
||||
|
||||
|
||||
------------------------------
|
||||
|
||||
-- local function OnClientDataCommand(module, command, playerObj, args)
|
||||
-- if module == moduleName and ServerDataCommands[command] then
|
||||
-- ServerDataCommands[command](playerObj, args)
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- Events.OnClientCommand.Add(OnClientDataCommand)
|
||||
|
||||
|
||||
|
||||
26
media/lua/server/TOC/ServerDataHandler.lua
Normal file
26
media/lua/server/TOC/ServerDataHandler.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
if isClient() then return end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local ServerDataHandler = {}
|
||||
ServerDataHandler.modData = {}
|
||||
|
||||
---Get the server mod data table containing that player TOC data
|
||||
---@param key string
|
||||
---@return tocModData
|
||||
function ServerDataHandler.GetTable(key)
|
||||
return ServerDataHandler.modData[key]
|
||||
end
|
||||
|
||||
|
||||
function ServerDataHandler.AddTable(key, table)
|
||||
ModData.add(key, table) -- Add it to the server mod data
|
||||
ServerDataHandler.modData[key] = table
|
||||
end
|
||||
|
||||
Events.OnReceiveGlobalModData.Add(ServerDataHandler.AddTable)
|
||||
|
||||
|
||||
return ServerDataHandler
|
||||
Reference in New Issue
Block a user