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

__init__.py (1692B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\ballparkCommon\parkhelpers\__init__.py
      2 import math
      3 import random
      4 try:
      5     import geo2
      6 except ImportError:
      7     geo2 = None
      8 
      9 from eve.common.lib import appConst
     10 
     11 def HasWarpInPoint(item, radius):
     12     if radius >= 90000 and item.categoryID == appConst.categoryCelestial and item.groupID != appConst.groupWreck:
     13         return True
     14     return False
     15 
     16 
     17 def GetNearestPlanet(solarSystemID, position):
     18     minDist = None
     19     nearestPlanet = None
     20     for planetID, planet in GetPlanets(solarSystemID).items():
     21         dist = geo2.Vec3Distance(position, planet.position.data)
     22         if minDist is None or minDist > dist:
     23             nearestPlanet = planet
     24             minDist = dist
     25 
     26     return nearestPlanet
     27 
     28 
     29 def GetRandomPlanetID(solarSystemID):
     30     planets = GetPlanets(solarSystemID)
     31     planetIDs = planets.keys()
     32     return random.choice(planetIDs)
     33 
     34 
     35 def GetLocationNextToPlanet(solarSystemID, planetID, randomize = True):
     36     planet = GetPlanets(solarSystemID)[planetID]
     37     planetPos = planet.position.data
     38     directionFromCenter = geo2.Vec3Normalize(geo2.Vec3Cross(planetPos, (0, 1, 0)))
     39     offsetFromPlanetCenter = geo2.Vec3Scale(directionFromCenter, planet.radius * 2.5)
     40     rotationAngle = math.pi / 4
     41     if randomize:
     42         rotationAngle *= 1.0 + 0.1 * random.random()
     43     quat = geo2.QuaternionRotationAxis((0, 1, 0), rotationAngle)
     44     offsetFromPlanetCenter = geo2.QuaternionTransformVector(quat, offsetFromPlanetCenter)
     45     return geo2.Vec3Add(planetPos, offsetFromPlanetCenter)
     46 
     47 
     48 def GetPlanets(solarSystemID):
     49     return getattr(cfg.mapSolarSystemContentCache[solarSystemID], 'planets', {})