mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
added AmbientSound
This commit is contained in:
parent
335370b515
commit
84e1b2ee2e
30
direct/src/level/AmbientSound.py
Executable file
30
direct/src/level/AmbientSound.py
Executable file
@ -0,0 +1,30 @@
|
||||
from IntervalGlobal import *
|
||||
import BasicEntities
|
||||
|
||||
class AmbientSound(BasicEntities.NodePathEntity):
|
||||
def __init__(self, level, entId):
|
||||
BasicEntities.NodePathEntity.__init__(self, level, entId)
|
||||
|
||||
def destroy(self):
|
||||
BasicEntities.NodePathEntity.destroy(self)
|
||||
|
||||
def initSound(self):
|
||||
if self.soundPath == '':
|
||||
return
|
||||
self.sound = base.loadSfx(self.soundPath)
|
||||
if self.sound is None:
|
||||
return
|
||||
self.soundIval = SoundInterval(self.sound, node=self)
|
||||
self.soundIval.loop()
|
||||
|
||||
def destroySound(self):
|
||||
if hasattr(self, 'soundIval'):
|
||||
self.soundIval.pause()
|
||||
del self.soundIval
|
||||
if hasattr(self, 'sound'):
|
||||
del self.sound
|
||||
|
||||
if __dev__:
|
||||
def attribChanged(self, *args):
|
||||
self.destroySound()
|
||||
self.initSound()
|
@ -13,6 +13,7 @@ import ModelEntity
|
||||
import PathEntity
|
||||
import VisibilityExtender
|
||||
import PropSpinner
|
||||
import AmbientSound
|
||||
|
||||
# some useful constructor functions
|
||||
# ctor functions must take (level, entId)
|
||||
@ -32,6 +33,7 @@ class EntityCreator(EntityCreatorBase.EntityCreatorBase):
|
||||
EntityCreatorBase.EntityCreatorBase.__init__(self, level)
|
||||
self.level = level
|
||||
self.privRegisterTypes({
|
||||
'ambientSound': AmbientSound.AmbientSound,
|
||||
'cutScene': CutScene.CutScene,
|
||||
'editMgr': EditMgr.EditMgr,
|
||||
'entityGroup': nothing,
|
||||
|
@ -44,6 +44,7 @@ class EntityCreatorAI(EntityCreatorBase.EntityCreatorBase):
|
||||
cLE = createLocalEntity
|
||||
|
||||
self.privRegisterTypes({
|
||||
'ambientSound': nothing,
|
||||
'cutScene': nothing,
|
||||
'editMgr': Functor(cLE, EditMgrAI.EditMgrAI),
|
||||
'entityGroup': nothing,
|
||||
|
@ -119,6 +119,12 @@ class VisibilityExtender(Entity):
|
||||
('newZones', [], 'visZoneList'),
|
||||
)
|
||||
|
||||
class AmbientSound(Entity):
|
||||
type = 'ambientSound'
|
||||
attribs = (
|
||||
('soundPath', '', 'bamfilename'),
|
||||
)
|
||||
|
||||
class PropSpinner(Entity):
|
||||
type = 'propSpinner'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user