cameraAchievementEventTracker.py (2860B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\camera\cameraAchievementEventTracker.py 2 import math 3 import blue 4 import geo2 5 from monolith_task_tracker.common.const import TaskConsts, TaskEventConst 6 from monolith_task_tracker.common.eventExceptionEater import AchievementEventExceptionEater 7 from carbon.common.script.util import mathCommon 8 from logmodule import LogException 9 from operations.client.operationscontroller import operationsController, GetOperationsController 10 from operations.client.util import are_operations_active 11 import uthread 12 13 class CameraAchievementEventTracker(object): 14 cameraStillSpinning = False 15 16 def CameraMove_thread(self, camera_controller, camera): 17 try: 18 lastYawRad, _, _ = geo2.QuaternionRotationGetYawPitchRoll(camera.GetRotationQuat()) 19 radDelta = 0 20 while self.cameraStillSpinning: 21 blue.pyos.synchro.Yield() 22 if camera_controller.mouseDownPos is None or camera is None: 23 self.cameraStillSpinning = False 24 return 25 curYaw, pitch, roll = geo2.QuaternionRotationGetYawPitchRoll(camera.GetRotationQuat()) 26 angleBtwYaws = mathCommon.GetLesserAngleBetweenYaws(lastYawRad, curYaw) 27 radDelta += math.fabs(angleBtwYaws) 28 lastYawRad = curYaw 29 if abs(radDelta) > math.pi / 4: 30 sm.ScatterEvent('OnClientMouseSpinInSpace') 31 self.cameraStillSpinning = False 32 33 except Exception as e: 34 LogException(e) 35 36 def RecordOrbitForAchievements(self, camera_controller, camera): 37 with AchievementEventExceptionEater(): 38 if self.cameraStillSpinning: 39 return 40 if self.IsAchievementEventInteresting(TaskConsts.UI_ROTATE_IN_SPACE, TaskEventConst.UI_MOUSE_ROTATE_CLIENT): 41 self.cameraStillSpinning = True 42 uthread.new(self.CameraMove_thread, camera_controller, camera) 43 44 def IsAchievementEventInteresting(self, achievement_const, achievement_event_const): 45 return not sm.GetService('monolithTaskTrackerSvc').IsAchievementCompleted(achievement_const) or are_operations_active() 46 47 def RecordZoomForAchievements(self, amount): 48 with AchievementEventExceptionEater(): 49 if amount < 0: 50 if self.IsAchievementEventInteresting(TaskConsts.UI_ZOOM_IN_SPACE, TaskEventConst.UI_MOUSEZOOM_IN_CLIENT): 51 sm.ScatterEvent('OnClientMouseZoomInSpace', amount) 52 elif self.IsAchievementEventInteresting(TaskConsts.UI_ZOOM_IN_SPACE, TaskEventConst.UI_MOUSEZOOM_OUT_CLIENT): 53 sm.ScatterEvent('OnClientMouseZoomOutSpace', amount) 54 55 def StopRecordingOrbitForAchievements(self): 56 self.cameraStillSpinning = False