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

defaultHangarBehaviours.py (5231B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\view\hangarBehaviours\defaultHangarBehaviours.py
      2 from __future__ import absolute_import
      3 import geo2
      4 import math
      5 import trinity
      6 from .baseHangarBehaviours import BaseHangarShipBehaviour, BaseHangarShipDroneBehaviour
      7 from carbonui.uicore import uicore
      8 
      9 class DefaultHangarShipBehaviour(BaseHangarShipBehaviour):
     10     SHIP_FLOATING_HEIGHT = 360.0
     11 
     12     def __init__(self):
     13         BaseHangarShipBehaviour.__init__(self)
     14         self.startPos = (0, 0, 0)
     15         self.endPos = (0, 0, 0)
     16         self.isEnlistmentDockingEnabled = False
     17 
     18     def SetEnlistmentDockingEnabled(self, enabled):
     19         self.isEnlistmentDockingEnabled = enabled
     20 
     21     def SetDockingEffectGraphicID(self, graphicID):
     22         self.dockingEffectGraphicID = graphicID
     23 
     24     def SetAnchorPoint(self, hangarModel, hangarScene):
     25         if hangarModel is None:
     26             self.log.error('DefaultHangarShipBehaviour.SetAnchorPoint: Setting anchor point when scene is None')
     27             return
     28         anchorPointLocatorSets = [ locatorSet for locatorSet in getattr(hangarModel, 'locatorSets', []) if locatorSet.name == 'anchorpoint' ]
     29         if len(anchorPointLocatorSets) > 0:
     30             if len(getattr(anchorPointLocatorSets[0], 'locators', [])) > 0:
     31                 self.shipAnchorPoint = anchorPointLocatorSets[0].locators[0][0]
     32                 return
     33         if self.shipAnchorPoint == (0.0, 0.0, 0.0):
     34             self.shipAnchorPoint = (0.0, self.SHIP_FLOATING_HEIGHT)
     35 
     36     def PlaceShip(self, model, typeID):
     37         self.model = model
     38         trinity.WaitForResourceLoads()
     39         self.InitModelPosition()
     40         center = self.GetShipCenter(model, typeID)
     41         self.model.translationCurve.value = center
     42         self.endPos = self.model.translationCurve.value
     43         uicore.animations.StopAnimation(self.model.translationCurve, 'value')
     44 
     45     def GetShipCenter(self, model, typeID):
     46         boundingBoxYBottom = self.GetBoundingBoxYBottom(model)
     47         translation = geo2.Vec3Subtract(self.shipAnchorPoint, (0.0, boundingBoxYBottom, 0.0))
     48         offset = geo2.Vec3Scale(model.GetBoundingSphereCenter(), 0.5)
     49         return geo2.Vec3Add(translation, offset)
     50 
     51     def InitModelPosition(self):
     52         self.model.rotationCurve = trinity.Tr2RotationAdapter()
     53         self.model.rotationCurve.value = geo2.QuaternionRotationAxis((0, 1, 0), math.pi)
     54         self.model.translationCurve = trinity.Tr2TranslationAdapter()
     55 
     56     def AnimModelBoosters(self, duration):
     57         if not self.model.boosters:
     58             return
     59         self.model.translationCurve.value = self.startPos
     60         self.model.boosters.alwaysOnIntensity = 0.65
     61         self.model.boosters.alwaysOn = True
     62         self.model.boosters.display = True
     63         uicore.animations.MorphScalar(self.model.boosters, 'alwaysOnIntensity', self.model.boosters.alwaysOnIntensity, 0.0, duration=0.3 * duration, timeOffset=0.5 * duration)
     64 
     65     def AnimateShipEntry(self, model, typeID, scene = None, duration = 5.0):
     66         self.PlaceShip(model, typeID)
     67         model.modelTranslationCurve = trinity.Tr2TranslationAdapter()
     68         self.startPos = model.translationCurve.value
     69         self.AnimModelBoosters(duration)
     70 
     71     def AnimateReflectionProbeEntry(self, reflectionProbe, duration = 5.0):
     72         if reflectionProbe:
     73             reflectionProbe.lockPosition = True
     74             self._createEntryCurveset(reflectionProbe, 'position', duration)
     75 
     76     def _createEntryCurveset(self, owner, attribute, duration, callback = None):
     77         cs = uicore.animations.MorphVector3(owner, attribute, self.startPos, self.endPos, duration=duration, callback=callback)
     78         tangent = geo2.Vec3Subtract(self.endPos, self.startPos)
     79         key = list(cs.curves[0].x.keys[0])
     80         key[3] = tangent[0] / duration
     81         cs.curves[0].x.keys[0] = tuple(key)
     82         key = list(cs.curves[0].y.keys[0])
     83         key[3] = tangent[1] / duration
     84         cs.curves[0].y.keys[0] = tuple(key)
     85         key = list(cs.curves[0].z.keys[0])
     86         key[3] = tangent[2] / duration
     87         cs.curves[0].z.keys[0] = tuple(key)
     88 
     89     def GetBoundingBoxYBottom(self, model):
     90         localBB = model.GetLocalBoundingBox()
     91         boundingBoxYBottom = localBB[0][1]
     92         return boundingBoxYBottom
     93 
     94     def GetAnimEndPosition(self):
     95         return self.endPos
     96 
     97     def GetAnimStartPosition(self):
     98         return self.startPos
     99 
    100     def OnAnimShipEntryEnd(self):
    101         initialPos = (0.0, 0.0, 0.0)
    102         yDelta = min(BaseHangarShipBehaviour.MIN_SHIP_BOBBING_HALF_DISTANCE, self.model.boundingSphereRadius * 0.05)
    103         delta = (0.0, yDelta, 0.0)
    104         bobTime = max(BaseHangarShipBehaviour.MIN_SHIP_BOBBING_TIME, self.model.boundingSphereRadius)
    105         bobTime = min(bobTime, BaseHangarShipBehaviour.MAX_SHIP_BOBBING_TIME)
    106         self.ApplyShipBobbing(self.model, initialPos, delta, bobTime)
    107 
    108     def UpdateUndockStatus(self, isUndocking):
    109         pass
    110 
    111 
    112 class DefaultHangarDroneBehaviour(BaseHangarShipDroneBehaviour):
    113 
    114     def SetRepairDroneCount(self, boundingRadius):
    115         count = int(math.ceil(boundingRadius / 12.0))
    116         if self.repairDroneBehaviourGroup:
    117             self.repairDroneBehaviourGroup.SetCount(count)