Exemplo n.º 1
0
    def GetWarpCollisions(self, ball):
        space = sm.GetService('space')
        planets = space.planetManager.planets
        destination = self.destination
        source = (ball.x, ball.y, ball.z)
        self.direction = geo2.Vec3SubtractD(destination, source)
        direction = self.direction
        warpDistance = geo2.Vec3LengthD(direction)
        normDirection = geo2.Vec3NormalizeD(direction)
        self.normDirection = normDirection
        ballpark = sm.GetService('michelle').GetBallpark()
        collisions = []
        for planet in planets:
            planetBall = ballpark.GetBall(planet.id)
            if planetBall is None:
                log.LogWarn('Warping got a None planet ball.')
                continue
            planetRadius = planetBall.radius
            planetPosition = (planetBall.x, planetBall.y, planetBall.z)
            planetDir = geo2.Vec3SubtractD(planetPosition, source)
            if geo2.Vec3LengthSqD(
                    self.direction) < geo2.Vec3LengthSqD(planetDir):
                continue
            effectiveRadius = self.CalcEffectiveRadius(normDirection,
                                                       planetDir, planetRadius)
            if effectiveRadius is None:
                continue
            collisions.append((planetBall, effectiveRadius))
            blue.pyos.BeNice()

        return collisions
Exemplo n.º 2
0
 def GetBoundingSphereRadius(self, path):
     if path not in self.pooledExplosions:
         log.LogWarn('ExplosionManager::GetBoundingSphereRadius ' + path +
                     ' not loaded.')
         self.Preload(path)
     return getattr(self.pooledExplosions[path].resource,
                    'boundingSphereRadius', -1)
 def Cancel(self, path, count=1):
     """
     Let the explosion manager know we're no longer interested in this explosion.
     Should be called by objects that call Preload if they don't call GetExplosion.
     """
     if path not in self.pooledExplosions:
         log.LogWarn('ExplosionManager::Cancel ' + path + ' not loaded.')
         return
     self.pooledExplosions[path].DecRef(count)
Exemplo n.º 4
0
 def GetExplosion(self, path, scale=1.0, preloaded=False, callback=None):
     if path not in self.pooledExplosions:
         if preloaded:
             log.LogWarn('ExplosionManager::GetExplosion ' + path +
                         ' not loaded.')
         self.Preload(path)
     elif not preloaded:
         self.pooledExplosions[path].AddRef(1)
     explosion = self.pooledExplosions[path].Pop()
     explosion.scaling = (scale, scale, scale)
     explosion.Start()
     self._Append(callback, explosion, self.pooledExplosions[path])
     return explosion
Exemplo n.º 5
0
 def _GetModelTurret(self, moduleIdx):
     """Returns the turret python object
     """
     if getattr(self, 'sourceModuleIDList', None) is None:
         return
     if len(self.sourceModuleIDList) <= moduleIdx:
         log.LogWarn('moduleIdx: + ' + str(moduleIdx) +
                     ' is too high to index into list!')
         return
     slimItemID = self.sourceModuleIDList[moduleIdx]
     sourceShipBall = self.globalsGlob.GetTargetBall(self.sourceShipID)
     if sourceShipBall is not None:
         if not hasattr(sourceShipBall, 'modules'):
             return
         if sourceShipBall.modules is None:
             return
         if slimItemID in sourceShipBall.modules:
             return sourceShipBall.modules[slimItemID]
Exemplo n.º 6
0
 def Cancel(self, path, count=1):
     if path not in self.pooledExplosions:
         log.LogWarn('ExplosionManager::Cancel ' + path + ' not loaded.')
         return
     self.pooledExplosions[path].DecRef(count)