NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

SpaceTear.py (4634B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\environment\effects\SpaceTear.py
      2 from eve.client.script.environment.effects.GenericEffect import GenericEffect, STOP_REASON_DEFAULT
      3 from tacticalNavigation.ballparkFunctions import AddClientBall, RemoveClientBall
      4 from fsdBuiltData.common.graphicIDs import GetGraphicFile
      5 import trinity
      6 import geo2
      7 import logging
      8 log = logging.getLogger(__name__)
      9 SPACETEAR_AUDIO_STRETCH_EFFECT_GRAPHIC_ID = 28897
     10 
     11 class SpaceTear(GenericEffect):
     12     __guid__ = 'effects.SpaceTear'
     13 
     14     def __init__(self, trigger, effect = None, graphicFile = None):
     15         super(SpaceTear, self).__init__(trigger, effect, graphicFile)
     16         self.sourceBall = None
     17         self.destBall = None
     18         self.model = None
     19         self.audioStretch = None
     20         self.riftLength = 500000.0
     21         self.riftBubbleRadius = 200000.0
     22         self.riftProgress = [0.0, 1234.0]
     23         self.globalVisibilityFraction = 0.5
     24         self._SetupRiftModel()
     25         self._ExtractGraphicInfo(trigger.graphicInfo)
     26         self.UpdateModelState()
     27 
     28     def _SetupRiftModel(self):
     29         sourceID = self.ballIDs[0]
     30         targetID = self.ballIDs[1]
     31         sourceBall = self.fxSequencer.GetBall(sourceID)
     32         targetBall = self.fxSequencer.GetBall(targetID)
     33         sourceBallEgoPos = (sourceBall.x, sourceBall.y, sourceBall.z)
     34         targetBallEgoPos = (targetBall.x, targetBall.y, targetBall.z)
     35         self.model = trinity.Load(self.graphicFile)
     36         trinity.WaitForResourceLoads()
     37         riftVector = (targetBallEgoPos[0] - sourceBallEgoPos[0], targetBallEgoPos[1] - sourceBallEgoPos[1], targetBallEgoPos[2] - sourceBallEgoPos[2])
     38         riftDirection = geo2.QuaternionRotationArc(geo2.Vec3Normalize(riftVector), (0.0, 0.0, -1.0))
     39         constRotation = trinity.Tr2RotationAdapter()
     40         constRotation.value = geo2.QuaternionInverse(riftDirection)
     41         self.sourceBall = AddClientBall(sourceBallEgoPos)
     42         self.destBall = AddClientBall(targetBallEgoPos)
     43         self.model.translationCurve = self.sourceBall
     44         self.model.rotationCurve = constRotation
     45         self._SetupAudioStretchEffect()
     46 
     47     def _SetupAudioStretchEffect(self):
     48         audioStretchEffect = GetGraphicFile(SPACETEAR_AUDIO_STRETCH_EFFECT_GRAPHIC_ID)
     49         self.audioStretch = trinity.Load(audioStretchEffect)
     50         trinity.WaitForResourceLoads()
     51         self.audioStretch.source = self.sourceBall
     52         self.audioStretch.dest = self.destBall
     53 
     54     def _ExtractGraphicInfo(self, graphicInfo):
     55         if graphicInfo is not None:
     56             self.riftLength = graphicInfo.get('fractureLength', 420420.0)
     57             self.riftBubbleRadius = graphicInfo.get('bubbleRadius', 69420.0)
     58             self.globalVisibilityFraction = graphicInfo.get('globalVisibilityFraction', 0.5)
     59             elapsedTime = graphicInfo.get('elapsedDuration', 0.0)
     60             totalTime = graphicInfo.get('totalDuration', 1234.0)
     61             self.riftProgress = [elapsedTime, totalTime]
     62 
     63     def Start(self, duration):
     64         if self.model is None:
     65             return
     66         self.AddToScene(self.model)
     67         self.AddToScene(self.audioStretch)
     68         self.model.StartControllers()
     69         self.audioStretch.StartFiring(0)
     70 
     71     def Stop(self, reason = STOP_REASON_DEFAULT):
     72         scene = self.fxSequencer.GetScene()
     73         if scene is not None:
     74             if self.model is not None:
     75                 scene.objects.fremove(self.model)
     76                 self.model = None
     77             if self.audioStretch is not None:
     78                 scene.objects.fremove(self.audioStretch)
     79                 self.audioStretch = None
     80         if self.sourceBall is not None:
     81             RemoveClientBall(self.sourceBall)
     82             self.sourceBall = None
     83         if self.destBall is not None:
     84             RemoveClientBall(self.destBall)
     85             self.destBall = None
     86 
     87     def Repeat(self, duration):
     88         self.UpdateModelState()
     89 
     90     def UpdateModelState(self):
     91         if self.model is None:
     92             return
     93         self.model.SetControllerVariable('breachLength', self.riftLength)
     94         self.model.SetControllerVariable('sphereRadius', self.riftBubbleRadius)
     95         self.model.SetControllerVariable('elapsedTime', self.riftProgress[0])
     96         self.model.SetControllerVariable('totalTime', self.riftProgress[1])
     97         self.model.SetControllerVariable('globallyVisibleThreshold', self.globalVisibilityFraction)
     98 
     99     def UpdateGraphicInfo(self, newGraphicInfo):
    100         super(SpaceTear, self).UpdateGraphicInfo(newGraphicInfo)
    101         self._ExtractGraphicInfo(newGraphicInfo)
    102         self.UpdateModelState()