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

entityShip.py (4168B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\environment\spaceObject\entityShip.py
      2 import blue
      3 import destiny
      4 from caching import Memoize
      5 from eve.client.script.environment.spaceObject.spaceObject import SpaceObject
      6 from eve.client.script.environment.spaceObject.ship import Ship
      7 from eve.client.script.environment.model.turretSet import TurretSet
      8 import eve.common.lib.appConst as const
      9 import evetypes
     10 import mathext
     11 
     12 @Memoize
     13 def _GetTypesWithThreeTurretHardPoints():
     14     return evetypes.GetTypeIDsByListID(evetypes.TYPE_LIST_MAX_THREE_TURRET_HARD_POINTS)
     15 
     16 
     17 class EntityShip(Ship):
     18     launcherTypeCache = {}
     19 
     20     def __init__(self):
     21         Ship.__init__(self)
     22         self.gfxTurretID = None
     23         self.fitted = False
     24         self.typeID = None
     25         self.modules = {}
     26         self.model = None
     27         self.launcherTypeID = None
     28 
     29     def GetDNA(self):
     30         dna = Ship.GetDNA(self)
     31         if dna and ':class?' not in dna:
     32             dna += ':class?ship'
     33         return dna
     34 
     35     def LoadModel(self, fileName = None, loadedModel = None):
     36         godma = self.sm.GetService('godma')
     37         godmaStateManager = godma.GetStateManager()
     38         godmaType = godmaStateManager.GetType(self.typeID)
     39         self.turretTypeID = godmaType.gfxTurretID
     40         missileTypeID = godmaType.entityMissileTypeID
     41         self.launcherTypeID = self.DetermineLauncherTypeFromMissileID(self.typeID, missileTypeID)
     42         SpaceObject.LoadModel(self)
     43 
     44     def Assemble(self):
     45         Ship.Assemble(self)
     46         self.FitBoosters(isNPC=True)
     47         self.SetupSharedAmbientAudio()
     48         if self.model is not None:
     49             self.model.SetControllerVariable('isNPC', 1.0)
     50 
     51     def DetermineLauncherTypeFromMissileID(self, typeID, missileTypeID):
     52         launcherType = self.launcherTypeCache.get(missileTypeID, None)
     53         if launcherType:
     54             return launcherType
     55         clientDogma = self.sm.GetService('clientDogmaStaticSvc')
     56         usesMissiles = clientDogma.TypeHasEffect(typeID, const.effectMissileLaunchingForEntity)
     57         if not usesMissiles:
     58             return
     59         godma = self.sm.GetService('godma')
     60         group = int(godma.GetTypeAttribute2(missileTypeID, const.attributeLauncherGroup))
     61         for typeID in evetypes.GetTypeIDsByGroup(group):
     62             if evetypes.GetVariationChildren(typeID):
     63                 launcherType = typeID
     64                 self.launcherTypeCache[missileTypeID] = launcherType
     65                 break
     66 
     67         return launcherType
     68 
     69     def LookAtMe(self):
     70         if self.model is None:
     71             return
     72         if not self.fitted:
     73             self.FitHardpoints()
     74 
     75     def FitHardpoints(self, blocking = False):
     76         if self.model is None:
     77             self.logger.warning('FitHardpoints - No model')
     78             return
     79         if self.fitted:
     80             return
     81         self.fitted = True
     82         turretLocatorCount = int(self.model.GetTurretLocatorCount())
     83         if self.typeID in _GetTypesWithThreeTurretHardPoints():
     84             turretLocatorCount = mathext.clamp(turretLocatorCount, 1, 3)
     85         if self.launcherTypeID:
     86             launcherSet = TurretSet.FitTurret(self.model, self.launcherTypeID, turretLocatorCount, count=1)
     87             self.modules[0] = launcherSet
     88             turretLocatorCount = max(turretLocatorCount - 1, 1)
     89         if evetypes.GetGroupID(self.turretTypeID) in (const.groupPrecursorTurret, const.groupChainLightningTurret):
     90             turretLocatorCount = 1
     91         newTurretSet = TurretSet.FitTurret(self.model, self.turretTypeID, -1, count=turretLocatorCount)
     92         if newTurretSet is not None:
     93             self.modules[self.id] = newTurretSet
     94 
     95     def Release(self):
     96         if self.released:
     97             return
     98         for turretPair in self.modules.itervalues():
     99             if turretPair is not None:
    100                 turretPair.Release()
    101                 turretPair.owner = None
    102 
    103         self.modules = {}
    104         Ship.Release(self)
    105 
    106 
    107 class EntitySleeper(EntityShip):
    108 
    109     def FitHardpoints(self, blocking = False):
    110         if self.launcherTypeID:
    111             self.launcherTypeID = 0
    112         EntityShip.FitHardpoints(self)