def _TryMaxDistanceMode(self, selectionComponent, pickedEntity): pickedPos = pickedEntity.GetComponent('position').position playerPos = self.entityService.GetPlayerEntity().GetComponent('position').position distSq = geo2.Vec3DistanceSq(pickedPos, playerPos) maxDist = selectionComponent.maxSelectionDistance maxSq = maxDist * maxDist return distSq <= maxSq
def _GetClosest(self, position, rowSet, maxDist): closestDist = float('inf') closestPlanet = None for each in rowSet: pos = (each.x, each.y, each.z) dist = geo2.Vec3DistanceSq(position, pos) if dist < maxDist * maxDist and dist < closestDist: closestPlanet = each.itemID closestDist = dist return closestPlanet
def _PollAudioPositions(self, pollInterval=DEFAULT_OBSTRUCTION_POLL_INTERVAL): entityClient = sm.GetService('entityClient') gameWorldClient = sm.GetService('gameWorldClient') while True: gameWorld = None playerPos = None sceneID = None player = entityClient.GetPlayerEntity() if player and player.HasComponent( 'position') and session.worldspaceid: playerPos = player.GetComponent('position').position gameWorld = gameWorldClient.GetGameWorld(session.worldspaceid) sceneID = player.scene.sceneID if playerPos and gameWorld and sceneID: audioEntities = set( self.audioEmitterPositionsByComponent.values( )).intersection( self.audioEmitterComponentsByScene[sceneID].values()) for audioEntity in audioEntities: src = self.audioEmitterPositionsByComponent[ audioEntity].position p = None if geo2.Vec3DistanceSq(src, playerPos) > 1e-05: p = gameWorld.MultiHitLineTestWithMaterials( src, playerPos) if p: obstruction = len(p) * (1 / 5.0) if obstruction > 1.0: obstruction = 1.0 audioEntity.emitter.SetObstructionAndOcclusion( 0, obstruction, 0.0) else: audioEntity.emitter.SetObstructionAndOcclusion( 0, 0.0, 0.0) blue.pyos.synchro.SleepWallclock(pollInterval)
def _IsShortWarp(self, ball): pos0 = (ball.x, ball.y, ball.z) pos1 = (ball.gotoX, ball.gotoY, ball.gotoZ) d = geo2.Vec3DistanceSq(pos0, pos1) return d < 4000000000000.0