asteroid.py (2034B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\environment\spaceObject\asteroid.py 2 import math 3 import random 4 import trinity 5 from eve.client.script.environment.spaceObject.scalableSpaceObject import ScalableSpaceObject 6 from fsdBuiltData.client.groupGraphics import GetGraphicIdsFromTypeID, GetAttributeForCategory, GetCategoryGraphicIDsBasedOnAttribute 7 from evetypes import GetGraphicID 8 9 class Asteroid(ScalableSpaceObject): 10 11 def _GetGraphicID(self): 12 typeID = self.typeData.get('typeID') 13 graphics = GetGraphicIdsFromTypeID(typeID) 14 attribute = GetAttributeForCategory(typeID) 15 if attribute and hasattr(self, attribute): 16 categoryGraphics = GetCategoryGraphicIDsBasedOnAttribute(getattr(self, attribute), typeID) 17 if categoryGraphics: 18 return categoryGraphics[self.id % len(categoryGraphics)] 19 if graphics is None or len(graphics) == 0: 20 graphicid = GetGraphicID(typeID) 21 if graphicid is None: 22 raise RuntimeError('Error adding scalable object %d it has no graphicId or groupGraphic information', typeID) 23 return graphicid 24 return graphics[self.id % len(graphics)] 25 26 def Assemble(self): 27 if self.model is None: 28 self.logger.error('Cannot Assemble Asteroid, model failed to load') 29 return 30 super(Asteroid, self).Assemble() 31 r = random.Random() 32 r.seed(self.id) 33 duration = 50.0 * math.log(self.radius) 34 rdur = r.random() * 50.0 * math.log(self.radius) 35 duration += rdur 36 curve = trinity.Tr2CurveRandomAxisRotation() 37 curve.seed = self.id % 4294967296L 38 curve.period = duration 39 self.model.modelRotationCurve = curve 40 41 42 class NonInteractableAsteroid(Asteroid): 43 44 def Assemble(self): 45 super(NonInteractableAsteroid, self).Assemble() 46 if self.model is not None and hasattr(self.model, 'isPickable'): 47 self.model.isPickable = False