78 lines
2.4 KiB
Lua
78 lines
2.4 KiB
Lua
|
---@class UGCPlayerStartManager_C:BP_PlayerStartManager_C
|
||
|
---@field PlayerStartClass UClass
|
||
|
--Edit Below--
|
||
|
---@type UGCPlayerStartManager_C
|
||
|
local UGCPlayerStartManager = {};
|
||
|
|
||
|
-- 添加一个试试
|
||
|
local PlayerNum = 0;
|
||
|
|
||
|
---@type table<int32, BP_STPlayerStart_C>
|
||
|
UGCPlayerStartManager.AllPlayerStarts = {};
|
||
|
UGCPlayerStartManager.AllPlayerIndies = {};
|
||
|
|
||
|
function UGCPlayerStartManager:ReceiveBeginPlay()
|
||
|
self.SuperClass.ReceiveBeginPlay(self);
|
||
|
if IsServer then UGCEventSystem.AddListener(EventTypes.ClientAlready, self.OnMapLoaded, self); end
|
||
|
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()
|
||
|
if self.PlayerStartClass == nil then return end
|
||
|
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
|
||
|
|
||
|
UGCPlayerStartManager.TestPlayerStart = nil
|
||
|
|
||
|
---@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(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 self.AllPlayerIndies[PlayerKey] == nil then
|
||
|
PlayerNum = PlayerNum + 1;
|
||
|
self.AllPlayerIndies[PlayerKey] = PlayerNum;
|
||
|
else
|
||
|
self.AllPlayerIndies[PlayerKey] = (self.AllPlayerIndies[PlayerKey] + 1) % (#self.AllPlayerStarts);
|
||
|
end
|
||
|
if DefaultSettings.EnableTest then return self.AllPlayerStarts[1]; end
|
||
|
return self.AllPlayerStarts[self.AllPlayerIndies[PlayerKey] + 1];
|
||
|
end
|
||
|
|
||
|
return UGCPlayerStartManager;
|