local PoisonManager = {}; PoisonManager.PoisonConfigIndex = 7; -- 该数值是在 GameMode->DataManager->DataSources 中配置的 ---@type PoisonConfigItem[] PoisonManager.ConstConfig = { { delaytime = 8, SafeZoneAppeartime = 30, lasttime = 40, blueradius = 7500, whiteradius = 6500, pain = 1.5, }, { delaytime = 20, SafeZoneAppeartime = 30, lasttime = 40, blueradius = 6500, whiteradius = 5000, pain = 3, }, { delaytime = 30, SafeZoneAppeartime = 40, lasttime = 50, blueradius = 5000, whiteradius = 4000, pain = 4.5, }, --{ -- delaytime = 5, -- SafeZoneAppeartime = 10, -- lasttime = 15, -- blueradius = 500, -- whiteradius = 0, -- pain = 6, --}, }; ---@type table PoisonManager.MapCenterActors = {}; PoisonManager.SelectCenterIndex = 0; --- 选择地图之后,执行 function PoisonManager:Init() -- 计算当前的位置 self.MapCenterActors = {}; local AllActors = {}; if ObjectPath.BP_ActorStart then UGCLogSystem.Log("[PoisonManager:Init] ObjectPath.BP_ActorStart = %s", UE.GetName(ObjectPath.BP_ActorStart)); end UE.FindActorsByClass(ObjectPath.BP_ActorStart, AllActors, function(InIndex, InActor) return InActor:ActorHasTag("Poison"); end); for i, v in pairs(AllActors) do self.MapCenterActors[v.Index] = v; end UGCLogSystem.LogTree(string.format("[PoisonManager:Init] self.MapCenterActors ="), self.MapCenterActors) end --- 选择一个地图中心点进行刷圈 function PoisonManager:SelectMapCenter() self:Clear(); -- 从中选取一个 self.Config = TableHelper.DeepCopyTable(self.ConstConfig); -- 选取一个 if table.isEmpty(self.MapCenterActors) then self:Init(); if table.isEmpty(self.MapCenterActors) then UGCLogSystem.Log("[PoisonManager:SelectMapCenter] 加载不到地图中心点") return ; end end local Keys = {}; for i, v in pairs(self.MapCenterActors) do table.insert(Keys, i); end self.SelectCenterIndex = table.func(GlobalMiniMode, "SelectMapCenter", self.MapCenterActors); if self.SelectCenterIndex == nil then self.SelectCenterIndex = Keys[math.random(#Keys)]; end local Center = self.MapCenterActors[self.SelectCenterIndex]; local CenterLoc = Center:K2_GetActorLocation(); for i = 1, #self.Config do local ConfigItem = self.Config[i]; local CirCleCfg = self:CreateNewCirCleCfg() ConfigItem.bluepoint = VectorHelper.ToLuaTable2D(CenterLoc); local MinCenter = math.randomCircleInCircle(CenterLoc, ConfigItem.blueradius, ConfigItem.whiteradius); for Index, config in pairs(ConfigItem) do CirCleCfg[Index] = config; end CirCleCfg.bUseCustomBluePoint = true; CirCleCfg.bUseCustomWhitePoint = true; CirCleCfg.whitepoint = MinCenter; UGCGameSystem.GameMode.DataManager.DataSources[self.PoisonConfigIndex].CircleConfigs:Add(CirCleCfg); CenterLoc = MinCenter; end UGCLogSystem.Log("[PoisonManager:SelectMapCenter] self.SelectCenterIndex = %d", self.SelectCenterIndex) end --- 游戏正式开始的时候调用 function PoisonManager:Toggle(Enable) UGCLogSystem.Log("[PoisonManager:Toggle] 启动") if Enable then self:SelectMapCenter(); end UGCBlueprintFunctionLibrary.TogglePoisonCircle(GameState, Enable); end function PoisonManager:GetSelectMapIndex() return self.SelectCenterIndex; end function PoisonManager:Clear() UGCGameSystem.GameMode.DataManager.DataSources[self.PoisonConfigIndex].CircleConfigs:Empty(); UGCLogSystem.Log("[PoisonManager:Clear] 清空") end function PoisonManager:GetRadiationActor() return GameState:GetRadiationActor(); end --- 判断一个 Actor 是否在圈内 ---@param InActor AActor function PoisonManager:IsActorInCircle(InActor) if self:GetRadiationActor() == nil then return end local Dis = VectorHelper.GetActorDis2D(self:GetRadiationActor(), InActor) local Scale = self:GetRadiationActor():GetActorScale3D().X return Dis / 100 <= Scale; end function PoisonManager:CreateNewCirCleCfg() return UE.CreateStruct("CirCleCfg"); end function PoisonManager:GetMapCenterActors() return self.MapCenterActors; end function PoisonManager:GetMapCenterActor(InIndex) return self.MapCenterActors[InIndex]; end function PoisonManager:GetCurrCenter() return self.MapCenterActors[self.SelectCenterIndex]; end return PoisonManager;