---@class BP_ShowEnemyPos_C:AActor ---@field Widget UWidgetComponent ---@field DefaultSceneRoot USceneComponent ---@field PlayerKey int64 --Edit Below-- ---@type BP_ShowEnemyPos_C local BP_ShowEnemyPos = { TickFrequency = 20; TickTimer = nil; }; function BP_ShowEnemyPos:ReceiveBeginPlay() self.SuperClass.ReceiveBeginPlay(self); UGCLogSystem.Log("[BP_ShowEnemyPos:ReceiveBeginPlay] 执行") if self:HasAuthority() then else self:OnTick(); end end --[[ function BP_ShowEnemyPos:ReceiveTick(DeltaTime) self.SuperClass.ReceiveTick(self, DeltaTime); end --]] --[[ function BP_ShowEnemyPos:ReceiveEndPlay() self.SuperClass.ReceiveEndPlay(self); end --]] --function BP_ShowEnemyPos:GetReplicatedProperties() -- return { "PlayerKey", "Lazy"} --end function BP_ShowEnemyPos:OnTick() UGCLogSystem.Log("[BP_ShowEnemyPos:OnTick] 执行 Tick") self.TickTimer = UGCEventSystem.SetTimerLoop(self, self.ExecTick, 1. / self.TickFrequency); end --function BP_ShowEnemyPos:GetAvailableServerRPCs() -- return -- "ClientUpdatePlayerKey" -- ; --end --]] function BP_ShowEnemyPos:ExecTick() --print(string.format('[BP_ShowEnemyPos:Tick] 执行')) if self.bShowWidget then UGCLogSystem.Log("[BP_ShowEnemyPos:Tick] 每帧执行一次") self:ShowWidget(); end end function BP_ShowEnemyPos:ShowWidget() UGCLogSystem.Log("[BP_ShowEnemyPos:ShowWidget] 执行") if self.PlayerKey ~= nil and self.PlayerKey ~= 0 then UGCLogSystem.Log("[BP_ShowEnemyPos:ShowWidget] 当前 PlayerKey 不为空") local Pawn = UGCGameSystem.GetPlayerPawnByPlayerKey(self.PlayerKey); if UE.IsValid(Pawn) then print(string.format('[BP_ShowEnemyPos:ShowWidget] 存在当前玩家')) self:K2_SetActorLocation(Pawn:K2_GetActorLocation()); end end UGCLogSystem.Log("[BP_ShowEnemyPos:ShowWidget] 设置 Widget") local Widget = self.Widget:GetUserWidgetObject(); if UE.IsValid(Widget) then Widget:ShowDistanceByPlayerKey(self.PlayerKey); end end function BP_ShowEnemyPos:SetTrackPlayerKey(InPlayerKey) UGCLogSystem.Log("[BP_ShowEnemyPos:SetTrackPlayerKey] PlayerKey = %s", tostring(InPlayerKey)); self.PlayerKey = InPlayerKey; self:ClientUpdatePlayerKey(InPlayerKey) end function BP_ShowEnemyPos:OnRep_PlayerKey() --UGCLogSystem.Log("[BP_ShowEnemyPos:OnRep_PlayerKey] self.PlayerKey = %s", tostring(self.PlayerKey)); --self:ClientUpdatePlayerKey(self.PlayerKey) end function BP_ShowEnemyPos:ClientUpdatePlayerKey(InPlayerKey) UGCLogSystem.Log("[BP_ShowEnemyPos:ClientUpdatePlayerKey] InPlayerKey = %s, Local PlayerKey = %s", tostring(InPlayerKey), tostring(LocalPlayerKey)); if self.TickTimer == nil then self:OnTick(); end if InPlayerKey == nil or InPlayerKey == 0 then self:ShowWidget(); self.bShowWidget = false; else self.bShowWidget = true; end UGCEventSystem.SetTimer(self, function() local Widget1 = self.Widget:GetUserWidgetObject(); UGCLogSystem.Log("[BP_ShowEnemyPos:ShowWidget] 执行") if UE.IsValid(Widget1) then Widget1:ShowDistanceByPlayerKey(nil); self.bShowWidget = false; end end, SoldierConfig.Skills[SoldierConfig.ESoldierType.Sniper].ContinueTime) end return BP_ShowEnemyPos;