111 lines
4.2 KiB
Lua
111 lines
4.2 KiB
Lua
|
-- Script.Global.BuffSystem.BuffAction.BuffAction_MarkPlayer
|
||
|
local BuffActionBase = require('Script.Global.BuffSystem.BuffActionBase')
|
||
|
|
||
|
|
||
|
|
||
|
local BuffAction_MarkPlayer = setmetatable(
|
||
|
{
|
||
|
---@param MarkWidgetPath string @控件ClassPath 控件需继承自UObjectPositionWidget
|
||
|
---@param Offset FVector @偏移量
|
||
|
---@param SizeAutoContent bool @大小适配
|
||
|
---@param OutViewHide bool @控件离开镜头后是否隐藏(比如在背后)
|
||
|
---@param BeOcclusionHide bool @被遮挡后是否隐藏
|
||
|
MarkWidgetPath = "";
|
||
|
Offset = {X = 0, Y = 0, Z = 80};
|
||
|
SizeAutoContent = true;
|
||
|
OutViewHide = true;
|
||
|
BeOcclusionHide = false;
|
||
|
AllPlayerVis = true; -- 全部可见
|
||
|
TeamVis = false, -- 仅队友可见
|
||
|
|
||
|
|
||
|
RemoveDoOnce = false;
|
||
|
},
|
||
|
{ __index = BuffActionBase, __metatable = BuffActionBase }
|
||
|
);
|
||
|
|
||
|
--[[
|
||
|
-- 常用接口
|
||
|
self:GetInstID() -- 获取BuffID
|
||
|
self:GetOwnerPawn() -- 获取拥有者
|
||
|
BuffSystemAPI.GetBuffCauser(self:GetInstID()) -- 获取Buff给予者
|
||
|
|
||
|
self:EnableTick() -- 开启Tick
|
||
|
self:StopTick() -- 会自动关
|
||
|
self:IsEnableTick() -- 是否已开启Tick
|
||
|
]]
|
||
|
|
||
|
function BuffAction_MarkPlayer:LuaDoAction()
|
||
|
BuffActionBase.LuaDoAction(self)
|
||
|
-- 启用Tick UndoAction会自动关
|
||
|
-- self:EnableTick()
|
||
|
if not UGCGameSystem.IsServer() then
|
||
|
local CanCreate = false
|
||
|
self.OwnerPlayerKey = self:GetOwnerPawn().PlayerKey
|
||
|
if self.AllPlayerVis then
|
||
|
CanCreate = true
|
||
|
elseif self.TeamVis then
|
||
|
local LocalPlayerTeamID = UGCGameSystem.GameState:GetPlayerTeamIDByPlayerKey(UGCSystemLibrary.GetLocalPlayerKey())
|
||
|
local TargetPlayerTeamID = UGCGameSystem.GameState:GetPlayerTeamIDByPlayerKey(self.OwnerPlayerKey)
|
||
|
if LocalPlayerTeamID ~= TargetPlayerTeamID then
|
||
|
CanCreate = true
|
||
|
end
|
||
|
end
|
||
|
|
||
|
if CanCreate then
|
||
|
---@return InstanceIndex int @实例Index
|
||
|
---@param Actor Actor @需要添加位置UI的Actor对象
|
||
|
---@param WidgetClassPath string @控件ClassPath 控件需继承自UObjectPositionWidget
|
||
|
---@param Offset FVector @偏移量
|
||
|
---@param SizeAutoContent bool @大小适配
|
||
|
---@param OutViewHide bool @控件离开镜头后是否隐藏(比如在背后)
|
||
|
---@param BeOcclusionHide bool @被遮挡后是否隐藏
|
||
|
self.InstanceIndex = UGCWidgetManagerSystem.AddObjectPositionUI(self:GetOwnerPawn(), self.MarkWidgetPath, self.Offset, true, false, false)
|
||
|
--local WidgetClass = UE.LoadClass(self.MarkWidgetPath)
|
||
|
--self.TraceWidget = UserWidget.NewWidgetObjectBP(UGCSystemLibrary.GetLocalPlayerController(), WidgetClass)
|
||
|
--self.TraceWidget:AddToViewport(10000)
|
||
|
--self.TraceWidget:SetTracePlayerKey(self.OwnerPlayerKey)
|
||
|
self.RemoveDoOnce = false
|
||
|
UGCEventSystem.AddListener(EventEnum.PlayerDeathInfo, self.PlayerDeathInfo, self)
|
||
|
end
|
||
|
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
function BuffAction_MarkPlayer:LuaUndoAction()
|
||
|
BuffActionBase.LuaUndoAction(self)
|
||
|
if not UGCGameSystem.IsServer() then
|
||
|
self:RemoveObjectPositionUI()
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BuffAction_MarkPlayer:LuaResetAction()
|
||
|
BuffActionBase.LuaResetAction(self)
|
||
|
end
|
||
|
|
||
|
function BuffAction_MarkPlayer:LuaUpdateAction(DeltaSeconds)
|
||
|
BuffActionBase.LuaUpdateAction(self, DeltaSeconds)
|
||
|
end
|
||
|
|
||
|
function BuffAction_MarkPlayer:RemoveObjectPositionUI()
|
||
|
if not UGCGameSystem.IsServer() and not self.RemoveDoOnce then
|
||
|
self.RemoveDoOnce = true
|
||
|
UGCEventSystem.RemoveListener(EventEnum.PlayerDeathInfo, self.PlayerDeathInfo, self)
|
||
|
UGCWidgetManagerSystem.RemoveObjectPositionUI(UGCGameSystem.GameState, self.InstanceIndex)
|
||
|
--if UE.IsValid(self.TraceWidget) then
|
||
|
-- self.TraceWidget:SetPlayerKey(-1)
|
||
|
-- self.TraceWidget:RemoveFromParent()
|
||
|
--end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function BuffAction_MarkPlayer:PlayerDeathInfo(VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue, Assister)
|
||
|
if self.OwnerPlayerKey == VictimKey then
|
||
|
self:RemoveObjectPositionUI()
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
return BuffAction_MarkPlayer;
|