86 lines
3.0 KiB
Lua
86 lines
3.0 KiB
Lua
---@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)
|
|
UGCLogSystem.Log("[BP_Poison_Outer:OnCylinderBeginOverlap] OtherActor = %s", UE.GetName(OtherActor))
|
|
if UE.IsA(OtherActor, ObjectPath.PlayerPawnClass) 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)
|
|
UGCLogSystem.Log("[BP_Poison_Outer:OnCylinderEndOverlap] OtherActor = %s", UE.GetName(OtherActor))
|
|
if UE.IsA(OtherActor, ObjectPath.PlayerPawnClass) then
|
|
table.removeValue(self.PawnsInCircle, OtherActor, true);
|
|
if UGCGameSystem.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; |