GlobalInit = {}; ---@type table 己方队友 LocalTeamPlayers = LocalTeamPlayers == nil and nil or LocalTeamPlayers; ---@type table 敌方队友 EnemyTeamPlayers = EnemyTeamPlayers == nil and nil or EnemyTeamPlayers; ---@type TeamId 本地队伍 ID LocalTeamId = LocalTeamId == nil and nil or LocalTeamId; ---@type PlayerKey 本地玩家 Key LocalPlayerKey = LocalPlayerKey == nil and nil or LocalPlayerKey; ---@type UGCPlayerController_C 本地玩家控制器 LocalPlayerController = LocalPlayerController == nil and nil or LocalPlayerController; ---@type UGCGameState_C GameState GameState = GameState == nil and nil or GameState; ---@type bool 是否在客户端 IsClient = IsClient == nil and nil or IsClient; ---@type bool 是否在服务器 IsServer = IsServer == nil and nil or IsServer; --- 初始化 function GlobalInit.Init() GlobalInit.InitGlobalVar(); end --- 初始化全局变量 function GlobalInit.InitGlobalVar() if GameState == nil then GameState = UGCGameSystem.GameState; end if IsServer == nil then IsServer = UGCGameSystem.IsServer(); end if IsClient == nil then IsClient = not IsServer end --UGCLogSystem.Log("[GlobalInit.InitGlobalVar] IsClient = %s", tostring(IsClient)) if IsClient then if LocalPlayerController == nil then LocalPlayerController = STExtraGameplayStatics.GetFirstPlayerController(GameState); end if LocalPlayerKey == nil then if LocalPlayerController then LocalPlayerKey = LocalPlayerController.PlayerKey; end end end GlobalInit.RemoveUnused() end function GlobalInit.UnableVals() LocalTeamPlayers = nil; IsClient = nil; IsServer = nil; GameState = nil; LocalPlayerKey = nil; LocalPlayerController = nil; EnemyTeamPlayers = nil; end --- 移除不会被使用的东西 function GlobalInit.RemoveUnused() if IsServer then WidgetManager = nil; WidgetConfig = { EUIType = WidgetConfig.EUIType == nil and {} or WidgetConfig.EUIType, } --ItemTable = nil; UITool = nil; end GlobalInit.RemoveWeaponTable() end function GlobalInit.RemoveWeaponTable() --require("Script.Global.Table.ItemTable") --WeaponTypeInfo = nil; end