72 lines
2.3 KiB
Lua
72 lines
2.3 KiB
Lua
|
---@class UGCPlayerStartManager_C:BP_PlayerStartManager_C
|
||
|
---@field PlayerStartClass UClass
|
||
|
--Edit Below--
|
||
|
---@type UGCPlayerStartManager_C
|
||
|
local UGCPlayerStartManager = {};
|
||
|
|
||
|
---@type table<int32, BP_STPlayerStart_C>
|
||
|
UGCPlayerStartManager.AllPlayerStarts = {};
|
||
|
|
||
|
function UGCPlayerStartManager:ReceiveBeginPlay()
|
||
|
self.SuperClass.ReceiveBeginPlay(self);
|
||
|
if IsServer then UGCEventSystem.AddListener(EventTypes.ClientAlready, self.OnMapLoaded, self); end
|
||
|
RegTool:Register(RegTool.Enums.CheckBigWorldSubLevelLoad, self.CheckBigWorldLoadSuccess, self);
|
||
|
end
|
||
|
|
||
|
function UGCPlayerStartManager:CheckBigWorldLoadSuccess()
|
||
|
self:LoadAllPlayerStarts()
|
||
|
return not table.isEmpty(self.AllPlayerStarts);
|
||
|
end
|
||
|
|
||
|
--[[
|
||
|
function UGCPlayerStartManager:ReceiveTick(DeltaTime)
|
||
|
self.SuperClass.ReceiveTick(self, DeltaTime);
|
||
|
end
|
||
|
--]]
|
||
|
|
||
|
--[[
|
||
|
function UGCPlayerStartManager:ReceiveEndPlay()
|
||
|
self.SuperClass.ReceiveEndPlay(self);
|
||
|
end
|
||
|
--]]
|
||
|
|
||
|
--[[
|
||
|
function UGCPlayerStartManager:GetReplicatedProperties()
|
||
|
return
|
||
|
end
|
||
|
--]]
|
||
|
|
||
|
--[[
|
||
|
function UGCPlayerStartManager:GetAvailableServerRPCs()
|
||
|
return
|
||
|
end
|
||
|
--]]
|
||
|
|
||
|
function UGCPlayerStartManager:LoadAllPlayerStarts()
|
||
|
self.AllPlayerStarts = {};
|
||
|
UE.FindActorsByClass(self.PlayerStartClass, self.AllPlayerStarts);
|
||
|
UGCLogSystem.LogTree(string.format("[UGCPlayerStartManager:LoadAllPlayerStarts] self.AllPlayerStarts ="), self.AllPlayerStarts)
|
||
|
end
|
||
|
|
||
|
function UGCPlayerStartManager:OnMapLoaded(LoadedMapIndex, IsLoad)
|
||
|
self:LoadAllPlayerStarts();
|
||
|
end
|
||
|
|
||
|
---@param Controller UGCPlayerController_C
|
||
|
---@return BP_STPlayerStart_C
|
||
|
function UGCPlayerStartManager:GetUGCModePlayerStart(Controller)
|
||
|
if table.isEmpty(self.AllPlayerStarts) then self:LoadAllPlayerStarts() end
|
||
|
local PlayerStart = table.func(UGCGameSystem.GameState.MiniGameManager, "SelectPlayerStart", self.AllPlayerStarts, Controller);
|
||
|
if PlayerStart and UE.IsValid(PlayerStart) then return PlayerStart; end
|
||
|
return self:GetPlayerStart_Internal(Controller);
|
||
|
end
|
||
|
|
||
|
function UGCPlayerStartManager:GetPlayerStart_Internal(Controller)
|
||
|
-- 出生的时候默认使用
|
||
|
local PlayerKey = Controller.PlayerKey;
|
||
|
if table.isEmpty(self.AllPlayerStarts) then self:LoadAllPlayerStarts() end
|
||
|
if DefaultSettings.EnableTest then return self.AllPlayerStarts[1]; end
|
||
|
return self.AllPlayerStarts[math.random(table.getCount(self.AllPlayerStarts))];
|
||
|
end
|
||
|
|
||
|
return UGCPlayerStartManager;
|