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

spaceobjaudio.py (5879B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\eveSpaceObject\spaceobjaudio.py
      2 import logging
      3 import audio2
      4 import trinity
      5 from eveaudio.fsdUtils import GetSoundUrlForType
      6 from inventorycommon import const
      7 import shipmode.data as stancedata
      8 L = logging.getLogger(__name__)
      9 __all__ = ['SetupAudioEntity', 'SendEvent', 'PlayAmbientAudio']
     10 BILLBOARDS_PLAYING_AUDIO = {}
     11 
     12 def SetupAudioEntity(model, itemID):
     13     triObserver = trinity.TriObserverLocal()
     14     result = audio2.AudEmitter('spaceObject_%s_general' % itemID)
     15     triObserver.observer = result
     16     model.observers.append(triObserver)
     17     return result
     18 
     19 
     20 def SendEvent(audEntity, eventName):
     21     L.debug('playing audio event %s on emitter %s', eventName, id(audEntity))
     22     audEntity.SendEvent(unicode(eventName))
     23 
     24 
     25 def PlayAmbientAudio(audEntity, soundUrl = None):
     26     if soundUrl is not None:
     27         SendEvent(audEntity, soundUrl)
     28 
     29 
     30 def GetSoundUrl(slimItem = None, defaultSoundUrl = None):
     31     soundUrl = None
     32     if slimItem:
     33         soundUrl = GetSoundUrlForType(slimItem)
     34     if soundUrl is None:
     35         soundUrl = defaultSoundUrl
     36     return soundUrl
     37 
     38 
     39 def GetBoosterSizeStr(groupID):
     40     boosterMappings = {const.groupCapDrainDrone: 'd',
     41      const.groupCombatDrone: 'd',
     42      const.groupElectronicWarfareDrone: 'd',
     43      const.groupLogisticDrone: 'd',
     44      const.groupMiningDrone: 'd',
     45      const.groupProximityDrone: 'd',
     46      const.groupRepairDrone: 'd',
     47      const.groupSalvageDrone: 'd',
     48      const.groupStasisWebifyingDrone: 'd',
     49      const.groupUnanchoringDrone: 'd',
     50      const.groupWarpScramblingDrone: 'd',
     51      const.groupHybridDrone: 'd',
     52      const.groupSupportFighter: 'fs',
     53      const.groupLightFighter: 'fs',
     54      const.groupHeavyFighter: 'fs',
     55      const.groupStructureSupportFighter: 'fs',
     56      const.groupStructureLightFighter: 'fs',
     57      const.groupStructureHeavyFighter: 'fs',
     58      const.groupCapsule: 'd',
     59      const.groupRookieship: 'f',
     60      const.groupFrigate: 'f',
     61      const.groupShuttle: 'f',
     62      const.groupAssaultFrigate: 'f',
     63      const.groupCovertOps: 'f',
     64      const.groupInterceptor: 'f',
     65      const.groupStealthBomber: 'f',
     66      const.groupElectronicAttackShips: 'f',
     67      const.groupPrototypeExplorationShip: 'f',
     68      const.groupExpeditionFrigate: 'f',
     69      const.groupLogisticsFrigate: 'f',
     70      const.groupDestroyer: 'c',
     71      const.groupCruiser: 'c',
     72      const.groupStrategicCruiser: 'c',
     73      const.groupAttackBattlecruiser: 'c',
     74      const.groupBattlecruiser: 'c',
     75      const.groupInterdictor: 'c',
     76      const.groupHeavyAssaultCruiser: 'c',
     77      const.groupLogistics: 'c',
     78      const.groupForceReconShip: 'c',
     79      const.groupCombatReconShip: 'c',
     80      const.groupCommandShip: 'c',
     81      const.groupExpeditionCommandShip: 'c',
     82      const.groupHeavyInterdictors: 'c',
     83      const.groupMiningBarge: 'c',
     84      const.groupExhumer: 'c',
     85      const.groupTacticalDestroyer: 'c',
     86      const.groupCommandDestroyer: 'c',
     87      const.groupFlagCruiser: 'c',
     88      const.groupSpecialEditionYacht: 'c',
     89      const.groupIndustrial: 'bs',
     90      const.groupIndustrialCommandShip: 'bs',
     91      const.groupTransportShip: 'bs',
     92      const.groupBlockadeRunner: 'bs',
     93      const.groupBattleship: 'bs',
     94      const.groupEliteBattleship: 'bs',
     95      const.groupMarauders: 'bs',
     96      const.groupBlackOps: 'bs',
     97      const.groupFreighter: 'dr',
     98      const.groupJumpFreighter: 'dr',
     99      const.groupDreadnought: 'dr',
    100      const.groupLancerDreadnought: 'dr',
    101      const.groupCarrier: 'dr',
    102      const.groupCommandCarrier: 'dr',
    103      const.groupSupercarrier: 'dr',
    104      const.groupCapitalIndustrialShip: 'dr',
    105      const.groupForceAux: 'dr',
    106      const.groupTitan: 't'}
    107     return boosterMappings.get(groupID, 'f')
    108 
    109 
    110 def GetSharedAudioEmitter(itemID, eventName):
    111     return sm.GetService('audio').GetOrCreateAudioEmitterForItem(itemID, emitterName='spaceObject_{}_{}'.format(itemID, eventName))
    112 
    113 
    114 def SetupSharedEmitterForAudioEvent(itemID, model, eventName):
    115     triObserver = trinity.TriObserverLocal()
    116     emitter = GetSharedAudioEmitter(itemID, eventName)
    117     triObserver.observer = emitter
    118     model.observers.append(triObserver)
    119     if emitter:
    120         emitter.SendEvent(eventName)
    121 
    122 
    123 def bindAudioParameterToAttribute(sourceObject, attributeName, bindingsList):
    124     audparam = audio2.AudParameter()
    125     audparam.name = u'ship_invulnerability_link_strength'
    126     binding = trinity.TriValueBinding()
    127     binding.name = 'AudParameterBinding'
    128     binding.sourceObject = sourceObject
    129     binding.sourceAttribute = attributeName
    130     binding.destinationObject = audparam
    131     binding.destinationAttribute = 'value'
    132     bindingsList.append(binding)
    133     return audparam
    134 
    135 
    136 def SetBillboardAudio(billboard_model, enabled = True):
    137     try:
    138         for attachment in billboard_model.attachments.Find('trinity.EvePlaneSet'):
    139             resource = attachment.effect.resources.FindByName('ImageMap')
    140             if resource.resourcePath == 'dynamic:/inspacevideos' and enabled:
    141                 resource.resourcePath = 'dynamic:/inspacevideowithsounds'
    142             elif resource.resourcePath == 'dynamic:/inspacevideowithsounds' and not enabled:
    143                 resource.resourcePath = 'dynamic:/inspacevideos'
    144 
    145     except AttributeError:
    146         L.warning('Audio for the given billboard was not able to be activated due to an unexpected error. Check that the model given is actually for a billboard.')
    147         return
    148 
    149 
    150 def PlayBillboardAudio(emitter, entityID):
    151     for channel in [0,
    152      1,
    153      2,
    154      3]:
    155         if channel in BILLBOARDS_PLAYING_AUDIO.values():
    156             continue
    157         eventName = 'Play_billboard_stream_{}'.format(channel)
    158         emitter.SendEvent(eventName)
    159         BILLBOARDS_PLAYING_AUDIO[entityID] = channel
    160         break
    161 
    162 
    163 def StopBillboardAudio(entityID):
    164     try:
    165         del BILLBOARDS_PLAYING_AUDIO[entityID]
    166     except KeyError:
    167         pass