85 lines
2.7 KiB
Lua
Raw Permalink Normal View History

2025-01-04 23:00:19 +08:00
---@class BP_Poison_Outer_C:AActor
---@field Cylinder_Base UStaticMeshComponent
---@field Cylinder UStaticMeshComponent
---@field DefaultSceneRoot USceneComponent
--Edit Below--
---@type BP_Poison_Outer_C
local BP_Poison_Outer = {};
BP_Poison_Outer.PawnsInCircle = {};
BP_Poison_Outer.CachedPawnsInCircle = {};
function BP_Poison_Outer:ReceiveBeginPlay()
self.SuperClass.ReceiveBeginPlay(self);
self.Cylinder.OnComponentBeginOverlap:Add(self.OnCylinderBeginOverlap, self)
self.Cylinder.OnComponentEndOverlap:Add(self.OnCylinderEndOverlap, self);
-- 初始化的时候所有玩家都在圈内
UGCEventSystem.AddListener(EventTypes.ClientAlready, self.OnClientAlready, self)
end
--- 当玩家进入的时候
function BP_Poison_Outer:OnCylinderBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult)
if UE.IsPlayerPawn(OtherActor) then
table.insertonce(self.PawnsInCircle, OtherActor);
UGCLogSystem.LogTree(string.format("[BP_Poison_Outer:OnCylinderBeginOverlap] self.PawnsInCircle ="), self.PawnsInCircle)
UGCEventSystem.SendEvent(EventTypes.PlayerInCircle, OtherActor.PlayerKey, true)
end
end
function BP_Poison_Outer:OnCylinderEndOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex)
if UE.IsPlayerPawn(OtherActor) then
table.removeValue(self.PawnsInCircle, OtherActor, true);
if IsServer then DOREPONCE(self, "PawnsInCircle") end
UGCLogSystem.LogTree(string.format("[BP_Poison_Outer:OnCylinderEndOverlap] self.PawnsInCircle ="), self.PawnsInCircle)
UGCEventSystem.SendEvent(EventTypes.PlayerInCircle, OtherActor.PlayerKey, false);
end
end
--- 在初始化的时候添加所有玩家
function BP_Poison_Outer:OnClientAlready()
end
function BP_Poison_Outer:InitOuterPoison()
for i, v in pairs(UGCGameSystem.GetAllPlayerPawn()) do
local Dis = VectorHelper.GetActorDis2D(v, self);
if Dis < self:GetActorScale3D().X then table.insert(self.PawnsInCircle, v); end
end
UGCLogSystem.LogTree(string.format("[BP_Poison_Outer:InitOuterPoison] self.PawnsInCircle ="), self.PawnsInCircle)
end
function BP_Poison_Outer:OnRep_PawnsInCircle()
self.CachedPawnsInCircle = TableHelper.DeepCopyTable(self.PawnsInCircle);
end
function BP_Poison_Outer:GetPawnsInCircle()
return self.CachedPawnsInCircle;
end
--[[
function BP_Poison_Outer:ReceiveTick(DeltaTime)
self.SuperClass.ReceiveTick(self, DeltaTime);
end
--]]
--[[
function BP_Poison_Outer:ReceiveEndPlay()
self.SuperClass.ReceiveEndPlay(self);
end
--]]
function BP_Poison_Outer:GetReplicatedProperties()
return { "PawnsInCircle", "Lazy" }
end
--[[
function BP_Poison_Outer:GetAvailableServerRPCs()
return
end
--]]
function BP_Poison_Outer:SetShowCircle(IsShow)
self:SetActorHiddenInGame(not IsShow);
end
return BP_Poison_Outer;