---@class UGCGameState_C:BP_UGCGameState_C ---@field WrapperClass UClass ---@field ShootWeaponClass UClass --Edit Below-- UGCGameSystem.UGCRequire('Script.Common.ue_enum_custom') require('Script.Global.Global') local UGCGameState = {}; --- 服务器时间 UGCGameState.ServerTime = 0; --- 服务器时间 - 客户端时间的差值;如果想在服务器求客户端时间:当前时间 - 该值; UGCGameState.ServerTimeDiff = 0; --- 地图数据 UGCGameState.MapData = { SelectMapIndex = {}; }; --- 玩家数据 UGCGameState.PlayerDatas = { ---@type table ArchiveData = {}; ---@type table AccountInfo = {}; }; ---@type table> 玩家 Key 列表 UGCGameState.PlayerList = {}; --- 游戏进程数据 UGCGameState.CountDownTime = 0; function UGCGameState:ReceiveBeginPlay() --- 初始化 GlobalInit.InitGlobalVar(); if IsServer then -- 补人 UGCMultiMode.SetPlayerFill(DefaultSettings.TotalPlayerCount > 0); self.ServerTime = 1; -- 设置好 DOREPONCE(self, "ServerTime") else end if self.MiniGameManager == nil then self.MiniGameManager = require("Script.Blueprint.Mini.MiniGameManager") end if GlobalBeginTool then GlobalBeginTool:ReceiveBeginPlay(); end table.func(self.MiniGameManager, "ReceiveBeginPlay", self); if self.BuffManager == nil then self.BuffManager = require('Script.Blueprint.SceneObj.Buff.BuffManager1') end UGCLogSystem.Log("[UGCGameState:ReceiveBeginPlay] 执行") table.func(self.BuffManager, "Init", self); if self.SkillManager == nil then self.SkillManager = require('Script.Blueprint.SceneObj.Skill.SkillManager') end self.SkillManager:Init(self); self.bIsOpenShovelingAbility = true if self.PoisonManager == nil then self.PoisonManager = require('Script.Blueprint.SceneObj.Poison.PoisonManager') end end function UGCGameState:ReceiveTick(DeltaTime) if GlobalTickTool then GlobalTickTool:ReceiveTick(DeltaTime, self:GetServerTime()); end end function UGCGameState:ReceiveEndPlay() DefaultSettings = nil; EventTypes = nil; GameState = nil; LocalPlayerKey = nil; LocalPlayerController = nil; LocalTeamPlayers = nil; EnemyTeamPlayers = nil; UnableTable(); UnableTool(); UnableWidgetManager(); UGCGameSystem.GameState = nil; end function UGCGameState:GetAvailableServerRPCs() return "LoadMap" , "CheckServerTime" , "SelectMap" , "MiniGameReceiveRPC" end function UGCGameState:GetReplicatedProperties() return { "MapData", "Lazy" } , { "PlayerDatas", "Lazy" } , { "CountDownTime", "Lazy" } , { "PlayerList", "Lazy" } , { "ServerTime", "Lazy" } , { "LoadMapName", "Lazy" } , { "CurrMiniType", "Lazy" } , { "MiniInfo", "Lazy" } end ----------------------------------------- 玩家属性 ----------------------------------------- ---@param InPlayerKey PlayerKey ---@param InArchiveData table ---@param InAccountData table function UGCGameState:HandlePlayerDatas(InPlayerKey, InArchiveData, InAccountData) InArchiveData.GameTimes = InArchiveData.GameTimes + 1; -- 又多玩了一局游戏 self.PlayerDatas.ArchiveData[InPlayerKey] = InArchiveData; self.PlayerDatas.AccountInfo[InPlayerKey] = InAccountData; DOREPONCE(self, "PlayerDatas"); end function UGCGameState:OnRep_PlayerDatas() -- 检查当前玩了多少局 if LocalPlayerKey == nil then return end if self.PlayerDatas.ArchiveData[LocalPlayerKey] == nil then return end -- 显示拍脸图 UGCLogSystem.LogTree(string.format("[UGCGameState:OnRep_PlayerDatas] self.PlayerDatas ="), self.PlayerDatas) if self.PlayerDatas.ArchiveData[LocalPlayerKey].GameTimes <= DefaultSettings.ShowFaceNoticeGameTimes then UGCLogSystem.Log("[UGCGameState:OnRep_PlayerDatas] 执行") if not DefaultSettings.EnableTest then WidgetManager:ShowPanel(WidgetConfig.EUIType.FaceNotice, false); end end end ---@param IsLogin bool ---@param InPlayerKey PlayerKey function UGCGameState:PlayerLoginOrLeave(IsLogin, InPlayerKey) local TeamId = UGCPlayerStateSystem.GetTeamID(InPlayerKey); local LogOut = false; local AlivePlayerCount = 0; if IsLogin then if self.PlayerList[TeamId] == nil then self.PlayerList[TeamId] = {}; end self.PlayerList[TeamId][#(self.PlayerList[TeamId]) + 1] = InPlayerKey; else if self.PlayerList[TeamId] ~= nil then local RemoveIndex = 0; for i, v in pairs(self.PlayerList[TeamId]) do if v == InPlayerKey then RemoveIndex = i; end end table.remove(self.PlayerList[TeamId], RemoveIndex); end --- 进行保存数据 UGCPlayerStateSystem.SavePlayerArchiveData(self.PlayerDatas.AccountInfo[InPlayerKey].UID, self.PlayerDatas.ArchiveData[InPlayerKey]); end for i, v in pairs(self.PlayerList) do AlivePlayerCount = table.getCount(v) + AlivePlayerCount; end if AlivePlayerCount == 0 then LogOut = true; end DOREPONCE(self, "PlayerList"); return LogOut, AlivePlayerCount; end function UGCGameState:OnPlayerDead(DeadPlayerKey, KillerPlayerKey) self.MiniGameManager:OnPlayerDead(DeadPlayerKey, KillerPlayerKey); table.func(self.BuffManager, "OnPlayerDead", DeadPlayerKey, KillerPlayerKey); end ---@param HasLeave bool 是否包含退出游戏的玩家 ---@return int32 玩家数量 function UGCGameState:GetPlayerCount(HasLeave) return table.getCount(self.PlayerList); end function UGCGameState:OnRep_PlayerList() if table.isEmpty(self.PlayerList) then return; end if LocalPlayerKey == nil then return; end -- 其他玩家 EnemyTeamPlayers = {}; LocalTeamPlayers = {}; LocalTeamId = UGCPlayerStateSystem.GetTeamID(LocalPlayerKey); for TeamId, PlayerArr in pairs(self.PlayerList) do if TeamId == LocalTeamId then for i, v in pairs(PlayerArr) do LocalTeamPlayers[#LocalTeamPlayers + 1] = v; end else for i, v in pairs(PlayerArr) do EnemyTeamPlayers[#EnemyTeamPlayers + 1] = v; end end end end ----------------------------------------- 地图加载 ----------------------------------------- --- 已经加载了的地图名称 UGCGameState.LoadMapName = {}; --- 加载地图(服务器/客户端都可以执行) ---@param MapNameList table 地图索引 function UGCGameState:LoadMap(MapNameList) -- 找到对应地图,然后进行加载 if not table.isEmpty(self.LoadMapName) then -- 先卸载,再安装 local List = {}; for i, v in pairs(self.LoadMapName) do table.insert(List, v.Name); end self:UnloadMap(List); end for i, v in pairs(MapNameList) do table.insert(self.LoadMapName, { Name = v, Load = false, }); end LevelStreamTool.LoadStreamLevels(MapNameList, { Object = self, Func = self.LoadMapFinish }, false); DOREPONCE(self, "LoadMapName") end function UGCGameState:OnRep_LoadMapName() if table.isEmpty(self.LoadMapName) then return ; end UGCLogSystem.LogTree(string.format("[UGCGameState:OnRep_LoadMapName] self.LoadMapName ="), self.LoadMapName); local LoadedMaps = {}; for i, v in pairs(self.LoadMapName) do if v.Load then table.insert(LoadedMaps, v.Name); end end if table.isEmpty(LoadedMaps) then return ; end self:PostOnMapLoaded() -- 加载小地图 UGCLogSystem.Log("[UGCGameState:OnRep_LoadMapName] 开始加载小地图") for i, v in pairs(LevelTable) do if v.MapName == self.LoadMapName[1].Name then UGCLogSystem.Log("[UGCGameState:OnRep_LoadMapName] 执行") self:LoadMinimap(i); break ; end end end --- 随机加载地图 ---@param function UGCGameState:LoadRandomMap(InIndex) if IsServer then self:UnloadMap(); -- 判断当前是不是随即关卡 UGCLogSystem.LogTree(string.format("[UGCGameState:LoadMap] LevelTable ="), LevelTable) self.MapData.SelectMapIndex = { InIndex }; local MapNames = {}; for i, v in pairs(self.MapData.SelectMapIndex) do table.insert(MapNames, LevelTable[v].MapName); end LevelStreamTool.LoadStreamLevels(MapNames, { Object = self, Func = self.LoadMapFinish }, false); DOREPONCE(self, "MapData"); else -- 发送 RPC 到服务器 UnrealNetwork.CallUnrealRPC(LocalPlayerController, self, "LoadMap", InIndex); end end --- 卸载地图 function UGCGameState:UnloadMap() if table.isEmpty(self.MapData.SelectMapIndex) then local MapNames = {}; for i, v in pairs(self.MapData.SelectMapIndex) do table.insert(MapNames, LevelTable[v].MapName) end LevelStreamTool.UnLoadStreamLevels(MapNames, { Object = self, Func = self.UnLoadMapFinish }, false); self.MapData.SelectMapIndex = {}; -- 重置 ClientAlready self.bInitOnce = false; end end function UGCGameState:OnRep_MapData() if table.isEmpty(self.MapData.SelectMapIndex) then return end --self:LoadMinimap(self.MapData.SelectMapIndex); end --- 地图加载完成 function UGCGameState:LoadMapFinish() UGCLogSystem.Log("[UGCGameState:LoadMapFinish] 地图加载完成"); -- 写一个通知 self:OnMapLoaded(); end function UGCGameState:UnLoadMapFinish() UGCLogSystem.Log("[UGCGameState:UnLoadMapFinish] 地图卸载成功") self.MiniGameManager:OnMapUnLoadedComplete(); end --- 加载小地图 function UGCGameState:LoadMinimap(InType) UGCLogSystem.Log("[UGCGameState:LoadMinimap] 开始加载 %s 的小地图", LevelTable[InType].MapName); local MinimapInfo = LevelTable[InType].MiniMapInfo; if not table.isEmpty(MinimapInfo) then UGCLogSystem.Log("[UGCGameState:LoadMinimap] 开始添加") UGCWidgetManagerSystem.ChangeMap(MinimapInfo.MapPath, MinimapInfo.MapCentre, MinimapInfo.MapSize, MinimapInfo.MapScale); end end UGCGameState.MapLoadTimer = nil; function UGCGameState:OnMapLoaded() --- 加载地图上的东西 UGCLogSystem.Log("[UGCGameState:OnMapLoaded] 执行") -- 检查是否加载完成 if Mini_BigWorld then if not RegTool:Do(RegTool.Enums.CheckBigWorldSubLevelLoad) then self.MapLoadTimer = UGCEventSystem.SetTimerLoop(self, function() if RegTool:Do(RegTool.Enums.CheckBigWorldSubLevelLoad) then if self.MapLoadTimer then UGCEventSystem.StopTimer(self.MapLoadTimer); self.MapLoadTimer = nil; end self:PostOnMapLoaded(); end end, 0.33); else self:PostOnMapLoaded(); end else self:PostOnMapLoaded(); end end UGCGameState.RadiationActor = nil; function UGCGameState:PostOnMapLoaded() UGCLogSystem.Log("[UGCGameState:PostOnMapLoaded] 执行") if IsServer then self.PoisonManager:Init(); for i, v in pairs(self.LoadMapName) do v.Load = true; end DOREPONCE(self, "LoadMapName"); else end self.MiniGameManager:OnMapLoadComplete(); --服务器客户端都加载类 self.RadiationActor = UE.FindActorByClass(ObjectPath.BP_radiation) if self.RadiationActor then UGCLogSystem.Log("[UGCGameState:PostOnMapLoaded] Radiation Actor = %s", UE.GetName(self.RadiationActor)) else UGCLogSystem.Log("[UGCGameState:PostOnMapLoaded] Radiation Actor = nil"); end end ----------------------------------------- 游戏进程 ----------------------------------------- ---@param InTime int32 初始化倒计时 function UGCGameState:OnGameActive(InTime) if self.MiniGameManager then table.func(self.MiniGameManager, "OnGameActive", InTime); end end --- 游戏结束 function UGCGameState:OnGameEnded(InTime) -- 打开结算界面 if IsServer then for i, v in pairs(UGCGameSystem.GetAllPlayerPawn()) do UGCPawnSystem.LeavePawnState(v, EPawnState.Move); v:K2_DestroyActor() end UGCLogSystem.Log("[UGCGameState:OnGameEnded] InTime = %s", tostring(InTime)) self:ShowUIByType(WidgetConfig.EUIType.GameEnd, true, InTime) end end --- 倒计时 function UGCGameState:OnGameProgress_Tick(InTime) self.CountDownTime = InTime; DOREPONCE(self, "CountDownTime"); end function UGCGameState:OnRep_CountDownTime() UGCEventSystem.SendEvent(EventTypes.CountDownTimeChange, self.CountDownTime); -- 执行客户端调用 if self.MiniGameManager then self.MiniGameManager:OnMiniGameTimeCount(self.CountDownTime); end end --- 当前游戏时间,以服务器为基准(因为服务器不会改变) ---客户端准备好之后会发送一个 RPC 过来,之后就是 function UGCGameState:CheckServerTime(InPlayerKey, InTime) if IsServer then local PC = UGCGameSystem.GetPlayerControllerByPlayerKey(InPlayerKey) UnrealNetwork.CallUnrealRPC(PC, self, "CheckClientTime", UE.GetCurrentTime()); self:OnClientAlready(); else UnrealNetwork.CallUnrealRPC(LocalPlayerController, self, "CheckServerTime", InPlayerKey, InTime); end end function UGCGameState:OnRep_ServerTime() -- 接收到之后就立刻发送 RPC 到服务器,或者也可以等一会 if self.ServerTime == 1 then if LocalPlayerKey == nil or LocalPlayerController == nil then UGCEventSystem.SetTimer(self, function() self:CheckServerTime(LocalPlayerKey, UE.GetCurrentTime()) end, 1.); return ; end self:CheckServerTime(LocalPlayerKey, UE.GetCurrentTime()) elseif self.ServerTime == 0 then else local Diff = self.ServerTime - UE.GetCurrentTime(); UGCLogSystem.Log("[UGCGameState:CheckClientTime] Diff = %f", Diff) self:OnClientAlready(); end end function UGCGameState:CheckClientTime(InTime) self.ServerTimeDiff = InTime - UE.GetCurrentTime(); UGCLogSystem.Log("[UGCGameState:CheckClientTime] self.ServerTimeDiff = %f", self.ServerTimeDiff); self:OnClientAlready(); end UGCGameState.bInitOnce = false; function UGCGameState:OnClientAlready() if self.bInitOnce then return end UGCEventSystem.SendEvent(EventTypes.ClientAlready) local ServerTime = self:GetServerTime() UGCLogSystem.Log("[UGCGameState:OnClientAlready] 执行 ServerTime = %f", ServerTime); if IsServer then UGCLogSystem.Log("[UGCGameState:OnClientAlready] 执行") self:OnGameActive(-1) end self:LoadResource(); if GlobalBeginTool then GlobalBeginTool:ReceiveClientAlready() GlobalBeginTool = nil; end self.bInitOnce = true; end --- S & C : 获取服务器时间 ---@return float|nil function UGCGameState:GetServerTime() if IsServer then return UE.GetCurrentTime(); else if self.ServerTimeDiff == 0 then return nil; else return self.ServerTimeDiff + UE.GetCurrentTime(); end end end --- 获取客户端时间 function UGCGameState:GetClientTime(InPlayerKey) if IsClient then return UE.GetCurrentTime(); else end end function UGCGameState:ClearAll() UnableTable() end --- 提前重置操作 function UGCGameState:BeforeReset(InTime) for i, v in pairs(self.PlayerList) do for c, d in pairs(v) do local Pawn = UGCGameSystem.GetPlayerPawnByPlayerKey(d) if Pawn then Pawn:K2_DestroyActor(); end UE.RespawnPlayer(d, InTime); end end self:ResetKill(); end function UGCGameState:ResetKill() -- 重置其他的 for i, v in pairs(UGCGameSystem.GetAllPlayerController(false)) do v:ResetGame(); end end --- 重置游戏 function UGCGameState:ResetGame() if IsServer then UnrealNetwork.CallUnrealRPC_Multicast(self, "ResetGame"); -- 重置击杀数 for i, v in pairs(UGCGameSystem.GetAllPlayerState(false)) do v:ResetKillNum(); end else WidgetManager:GetPanel(WidgetConfig.EUIType.Main):OnGameStart(); end end ----------------------------------------- 界面 UI ----------------------------------------- --- 显示 UI ---@param InUIType EUIType ---@param IsShow boolean function UGCGameState:ShowUIByType(InUIType, IsShow, ...) if IsServer then UnrealNetwork.CallUnrealRPC_Multicast(self, "ShowUIByType", InUIType, IsShow, ...); else --local Params = {...}; --UGCLogSystem.LogTree(string.format("[UGCGameState:ShowUIByType] Params ="), Params) if IsShow then WidgetManager:ShowPanel(InUIType, false, ...); else WidgetManager:ClosePanel(InUIType); end end end --- 显示 UI ---@param InUIType EUIType ---@param IsShow bool ---@param InPlayerKey PlayerKey function UGCGameState:PlayerShowUIByType(InUIType, IsShow, InPlayerKey, ...) if IsServer then if InPlayerKey == nil then UnrealNetwork.CallUnrealRPC_Multicast(self, "PlayerShowUIByType", InUIType, IsShow, ...); else UnrealNetwork.CallUnrealRPC(UGCGameSystem.GetPlayerControllerByPlayerKey(InPlayerKey), self, "PlayerShowUIByType", InUIType, IsShow, ...); end else if IsShow then WidgetManager:ShowPanel(InUIType, false, InPlayerKey, ...); else WidgetManager:ClosePanel(InUIType); end end end ----------------------------------------- 场景物品 ----------------------------------------- ---@type BP_ResourceBase_C UGCGameState.ResourceActor = nil; --- 加载资源类,服务器,客户端都需要加载一次 ---@return BP_ResourceBase_C function UGCGameState:LoadResource() if self.ResourceActor == nil then self.ResourceActor = UE.FindActorByClass(ObjectPath.BP_ResourceBase); end UGCLogSystem.Log("[UGCGameState:LoadResource] %s", UGCGameSystem.GetUGCResourcesFullPath('Asset/Blueprint/UGCPlayerPawn.UGCPlayerPawn_C')) return self.ResourceActor; end -- 清除场景上的 Wrappers function UGCGameState:ClearWrappers() local InTable = {}; UE.FindActorsByClass(self:GetWrapperClass(), InTable, function(InIndex, InActor) return InActor:GetOwner() == nil; end); for i, v in pairs(InTable) do v:K2_DestroyActor(); end end ----------------------------------------- BUFF ----------------------------------------- ---@type AActor UGCGameState.MapCenterActor = nil; --- 获取中心点 ---@return AActor function UGCGameState:GetCenterPointLocation() if self.MapCenterActor ~= nil then return self.MapCenterActor:K2_GetActorLocation() end local CenterActors = {}; UE.FindActorsByClass(ObjectPath.BP_ActorStart, CenterActors, function(InIndex, InActor) return InActor:ActorHasTag("MapCenter"); end); self.MapCenterActor = CenterActors[1]; if self.MapCenterActor == nil then return VectorHelper.ToLuaTable(DefaultSettings.MapCenterLocation) end return CenterActors[1]:K2_GetActorLocation(); end ----------------------------------------- 武器 ----------------------------------------- --- 获取武器基类 ---@return UClass 武器基类 function UGCGameState:GetShootWeaponClass() return self.ShootWeaponClass; end ---@return UClass function UGCGameState:GetWrapperClass() return self.WrapperClass; end ----------------------------------------- 载具 ----------------------------------------- --- 清空地面上的载具 function UGCGameState:ClearVehicles() if table.isEmpty(self.Vehicles) then self:FindVehicles(); end for i, v in pairs(self.Vehicles) do v:K2_DestroyActor(); end self.Vehicles = {}; end --- 加载地面上的载具,通过 ActorStart 进行查找 function UGCGameState:LoadVehicles() self:ClearVehicles(); local AllStarts = {}; UE.FindActorsByClass(ObjectPath.BP_ActorStart, AllStarts, function(InIndex, InActor) table.insert(self.Vehicles, UGCVehicleSystem.SpawnVehicleNew(VehicleTable.Car[InActor.Index].Path, InActor:K2_GetActorLocation(), InActor:K2_GetActorRotation(), false, false)); return true; end) end -- 查找载具 function UGCGameState:FindVehicles() if table.isEmpty(self.Vehicles) then self:LoadVehicles(); end return self.Vehicles; end ----------------------------------------- 信号圈 ----------------------------------------- function UGCGameState:TogglePoison(InConfigIndex) if IsServer then self.PoisonManager:Toggle(true); end end function UGCGameState:GetRadiationActor() return self.RadiationActor; end ----------------------------------------- FUNCTIONAL ----------------------------------------- --- 发送自定义事件 function UGCGameState:SendEvent(IsSend, InPlayerKey, InEvent, ...) if IsServer then if IsSend then if InPlayerKey == nil then UnrealNetwork.CallUnrealRPC_Multicast(self, "SendEvent", false, nil, InEvent, ...); else UnrealNetwork.CallUnrealRPC(UGCGameSystem.GetPlayerControllerByPlayerKey(InPlayerKey), UGCGameSystem.GameState, "SendEvent", false, InPlayerKey, InEvent, ...); end else UGCEventSystem.SendEvent(InEvent, InPlayerKey, ...) end else -- 从客户端发送出去 if IsSend then UnrealNetwork.CallUnrealRPC(DefaultSettings.LocalPlayerController, UGCGameSystem.GameState, "SendEvent", false, DefaultSettings.LocalPlayerKey, InEvent, ...); else UGCEventSystem.SendEvent(InEvent, InPlayerKey, ...); end end end ----------------------------------------- 玩家属性 ----------------------------------------- ---@param InPlayerKey PlayerKey function UGCGameState:PawnApplyBuff(InPlayerKey) local Pawn = UGCGameSystem.GetPlayerPawnByPlayerKey(InPlayerKey); Pawn:ApplyBuff("ApplyKillChange"); end ----------------------------------------- MINI ----------------------------------------- --- 当前选择的 MiniType UGCGameState.CurrMiniType = -1; ---@param InMiniType int32 function UGCGameState:SelectMiniType(InMiniType) self.CurrMiniType = InMiniType; DOREPONCE(self, "CurrMiniType"); end function UGCGameState:OnRep_CurrMiniType() if self.CurrMiniType < 0 then return ; end if self.MiniGameManager ~= nil then self.MiniGameManager:LoadMiniGame(self.CurrMiniType); end end --- 发送 MiniGame RPC ---@param InFuncName string 函数名称 ---@vararg any function UGCGameState:SendMiniGameRPC(InFuncName, ...) if IsServer then UnrealNetwork.CallUnrealRPC_Multicast(self, "MiniGameReceiveRPC", InFuncName, true, ...); else UnrealNetwork.CallUnrealRPC(LocalPlayerController, self, "MiniGameReceiveRPC", InFuncName, false, ...); end end --- Mini Game 接收到 RPC ---@param InFuncName string 函数名称 ---@param SendFromServer bool 是否发自服务器 function UGCGameState:MiniGameReceiveRPC(InFuncName, SendFromServer, ...) if table.hasFunc(self.MiniGameManager, InFuncName) then table.func(self.MiniGameManager, InFuncName, ...) else if self.MiniGameManager ~= nil and self.MiniGameManager.CurrMiniMode then table.func(self.MiniGameManager.CurrMiniMode, InFuncName, ...) end end end --- 小游戏需要同步的数据 UGCGameState.MiniInfo = {}; function UGCGameState:SetMiniInfo(InMiniInfo) self.MiniInfo = InMiniInfo; DOREPONCE(self, "MiniInfo"); end function UGCGameState:OnRep_MiniInfo(InOld) if table.isEmpty(self.MiniInfo) then return ; end -- 发送出去 UGCLogSystem.LogTree(string.format("[UGCGameState:OnRep_MiniInfo] MiniInfo"), self.MiniInfo) if self.MiniGameManager then self.MiniGameManager.MiniInfo = self.MiniInfo; self.MiniGameManager:OnRep_MiniInfo(InOld); end end --- 获取 MiniGame 的数据 function UGCGameState:GetMiniInfo(Name) if self.MiniGameManager then return table.func(self.MiniGameManager, "GetMiniInfo", Name); end return nil; end --- 获取配置 function UGCGameState:GetMiniConfig(Name) if self.MiniGameManager then return table.func(self.MiniGameManager, "GetMiniInfo", Name); end return nil; end function UGCGameState:MiniFunc(InFuncName, ...) UGCLogSystem.Log("[UGCGameState:MiniFunc] FuncName = %s", InFuncName) if self.MiniGameManager then UGCLogSystem.Log("[UGCGameState:MiniFunc] 执行") return table.func(self.MiniGameManager, "DoMiniFunc", InFuncName, ...) end end ----------------------------------------- BUFF ----------------------------------------- function UGCGameState:AddBuff(InBuffType, InPlayerKey, ...) if self.BuffManager then self.BuffManager:Add(InPlayerKey, InBuffType, ...); end end function UGCGameState:RemoveBuff(InBuffType, InPlayerKey, ...) if self.BuffManager then self.BuffManager:RemoveBuff(InBuffType, InPlayerKey, ...); end end function UGCGameState:SendBuffRPC(InFuncName, InPlayerKey, BuffType, ...) if self.BuffManager then table.func(self.BuffManager, InFuncName, InPlayerKey, BuffType, ...); end end ----------------------------------------- Skill ----------------------------------------- function UGCGameState:SendSkillRPC(InFuncName, InSkillId, InPlayerKey, ...) if self.SkillManager then table.func(self.SkillManager, InFuncName, InSkillId, InPlayerKey, ...) end end function UGCGameState:AddSkill(InSkillId, InPlayerKey, ...) if self.SkillManager then table.func(self.SkillManager, "AddSkill", InSkillId, InPlayerKey, ...); end end ----------------------------------------- 自定义函数 ----------------------------------------- ---显示TipsUI function UGCGameState:ShowTipsUI(InStr, ...) if IsServer then UnrealNetwork.CallUnrealRPC_Multicast_Unreliable(self, "ShowTipsUI", string.format(InStr, ...)); else UGCWidgetManagerSystem.ShowTipsUI(string.format(InStr, ...)); end end function UGCGameState:CustomLog(Color, InStr, ...) if DefaultSettings.EnableTest then if IsServer then -- 组装一下 if self.CustomLogList == nil then self.CustomLogList = {}; GlobalTickTool:AddTick(self, function(o, dt, st) if table.isEmpty(o.CustomLogList) then return ; end -- 发送 RPC UnrealNetwork.CallUnrealRPC_Multicast(self, "CustomLog", o.CustomLogList); o.CustomLogList = {}; end, 1); end -- 开始添加,然后启动函数 local Item = { c = Color, s = string.format('[Server]' .. string.format('[%0.1f]', UE.GetServerTime()) .. InStr:format(...)), }; table.insert(self.CustomLogList, Item); else if type(Color) == 'table' then WidgetManager:GetPanel(WidgetConfig.EUIType.Main, function(Widget) Widget:AddLogItems(Color); end); else local Params = { ... }; WidgetManager:GetPanel(WidgetConfig.EUIType.Main, function(Widget) Widget:AddLogItem(Color, InStr, table.unpackTable(Params)); end); end end end end ----------------------------------------- 自定义函数 ----------------------------------------- return UGCGameState;