targeting.py (1388B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\behaviors\monitors\targeting.py 2 import logging 3 from ballpark.messenger.const import MESSAGE_TARGET_LOST 4 from behaviors.tasks import Task 5 from ccpProfile import TimedFunction 6 logger = logging.getLogger(__name__) 7 8 class TargetLostMonitor(Task): 9 10 @TimedFunction('behaviors::monitors::targeting::TargetLostMonitor::OnEnter') 11 def OnEnter(self): 12 self.SetTarget(self.GetLastBlackboardValue(self.attributes.targetAddress)) 13 if self.targetId: 14 self.SubscribeItem(self.context.myItemId, MESSAGE_TARGET_LOST, self.OnTargetLost) 15 self.SetStatusToSuccess() 16 else: 17 self.SetStatusToFailed() 18 19 def CleanUp(self): 20 if not self.IsInvalid(): 21 self.UnsubscribeItem(self.context.myItemId, MESSAGE_TARGET_LOST, self.OnTargetLost) 22 self.SetStatusToInvalid() 23 24 @TimedFunction('behaviors::monitors::targeting::TargetLostMonitor::OnTargetLost') 25 def OnTargetLost(self, targetId, reason): 26 if self.IsInvalid(): 27 return 28 if self.targetId == targetId: 29 logger.debug('%s: OnTargetLost target=%s reason=%s requesting reset', self.context.myItemId, targetId, reason) 30 self.behaviorTree.RequestReset(requestedBy=self) 31 32 def SetTarget(self, targetId): 33 self.targetId = targetId