Swim Sound implemented

This commit is contained in:
John 2015-06-27 18:14:04 +03:00
parent 812164a696
commit ab10d5f05f
7 changed files with 10 additions and 68 deletions

View file

@ -28,7 +28,6 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis
wantDevCameraPositions = base.config.GetBool('want-dev-camera-positions', 0)
wantMouse = base.config.GetBool('want-mouse', 0)
sleepTimeout = base.config.GetInt('sleep-timeout', 120)
swimTimeout = base.config.GetInt('afk-timeout', 600)
__enableMarkerPlacement = base.config.GetBool('place-markers', 0)
def __init__(self, cr, chatMgr, talkAssistant = None, passMessagesThrough = False):
@ -63,7 +62,6 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis
self.sleepFlag = 0
self.isDisguised = 0
self.movingFlag = 0
self.swimmingFlag = 0
self.lastNeedH = None
self.accept('friendOnline', self.__friendOnline)
self.accept('friendOffline', self.__friendOffline)
@ -977,42 +975,6 @@ class LocalAvatar(DistributedAvatar.DistributedAvatar, DistributedSmoothNode.Dis
self.sleepCallback = None
return
def startSleepSwimTest(self):
taskName = self.taskName('sleepSwimTest')
taskMgr.remove(taskName)
task = Task.Task(self.sleepSwimTest)
self.lastMoved = globalClock.getFrameTime()
self.lastState = None
self.lastAction = None
self.sleepSwimTest(task)
taskMgr.add(self.sleepSwimTest, taskName, 35)
return
def stopSleepSwimTest(self):
taskName = self.taskName('sleepSwimTest')
taskMgr.remove(taskName)
self.stopSound()
def sleepSwimTest(self, task):
now = globalClock.getFrameTime()
speed, rotSpeed, slideSpeed = self.controlManager.getSpeeds()
if speed != 0.0 or rotSpeed != 0.0 or inputState.isSet('jump'):
if not self.swimmingFlag:
self.swimmingFlag = 1
elif self.swimmingFlag:
self.swimmingFlag = 0
if self.swimmingFlag or self.hp <= 0:
self.wakeUp()
elif not self.sleepFlag:
now = globalClock.getFrameTime()
if now - self.lastMoved > self.swimTimeout:
self.swimTimeoutAction()
return Task.done
return Task.cont
def swimTimeoutAction(self):
pass
def trackAnimToSpeed(self, task):
speed, rotSpeed, slideSpeed = self.controlManager.getSpeeds()
if speed != 0.0 or rotSpeed != 0.0 or inputState.isSet('jump'):

View file

@ -316,7 +316,6 @@ class Estate(Place.Place):
self.__setUnderwaterFog()
base.playSfx(self.loader.underwaterSound, looping=1, volume=0.8)
self.cameraSubmerged = 1
self.walkStateData.setSwimSoundAudible(1)
def __emergeCamera(self):
if self.cameraSubmerged == 0:
@ -325,7 +324,6 @@ class Estate(Place.Place):
self.loader.hood.sky.setFogOff()
self.__setFaintFog()
self.cameraSubmerged = 0
self.walkStateData.setSwimSoundAudible(0)
def forceUnderWater(self):
self.toonSubmerged = 0

View file

@ -76,7 +76,6 @@ class DDPlayground(Playground.Playground):
self.loader.seagullSound.stop()
taskMgr.remove('dd-seagulls')
self.cameraSubmerged = 1
self.walkStateData.setSwimSoundAudible(1)
def __emergeCamera(self):
if self.cameraSubmerged == 0:
@ -86,7 +85,6 @@ class DDPlayground(Playground.Playground):
self.nextSeagullTime = random.random() * 8.0
taskMgr.add(self.__seagulls, 'dd-seagulls')
self.cameraSubmerged = 0
self.walkStateData.setSwimSoundAudible(0)
def __submergeToon(self):
if self.toonSubmerged == 1:

View file

@ -65,7 +65,6 @@ class OZPlayground(Playground.Playground):
self.loader.hood.setUnderwaterFog()
base.playSfx(self.loader.underwaterSound, looping=1, volume=0.8)
self.cameraSubmerged = 1
self.walkStateData.setSwimSoundAudible(1)
def __emergeCamera(self):
if self.cameraSubmerged == 0:
@ -73,7 +72,6 @@ class OZPlayground(Playground.Playground):
self.loader.hood.setNoFog()
self.loader.underwaterSound.stop()
self.cameraSubmerged = 0
self.walkStateData.setSwimSoundAudible(0)
def __submergeToon(self):
if self.toonSubmerged == 1:

View file

@ -47,7 +47,6 @@ class OZSafeZoneLoader(SafeZoneLoader):
waterfallPlacer = self.geom.find('**/waterfall*')
binMgr = CullBinManager.getGlobalPtr()
binMgr.addBin('water', CullBinManager.BTFixed, 29)
binMgr = CullBinManager.getGlobalPtr()
pool = self.geom.find('**/pPlane5*')
pool.setTransparency(1)
pool.setColorScale(1.0, 1.0, 1.0, 1.0)

View file

@ -15,7 +15,6 @@ class Walk(StateData.StateData):
State.State('swimming', self.enterSwimming, self.exitSwimming, ['walking', 'slowWalking']),
State.State('slowWalking', self.enterSlowWalking, self.exitSlowWalking, ['walking', 'swimming'])], 'off', 'off')
self.fsm.enterInitialState()
self.IsSwimSoundAudible = 0
self.swimSoundPlaying = 0
def load(self):
@ -66,36 +65,31 @@ class Walk(StateData.StateData):
def exitWalking(self):
base.localAvatar.stopTrackAnimToSpeed()
def setSwimSoundAudible(self, IsSwimSoundAudible):
self.IsSwimSoundAudible = IsSwimSoundAudible
if IsSwimSoundAudible == 0 and self.swimSoundPlaying:
self.swimSound.stop()
self.swimSoundPlaying = 0
def enterSwimming(self, swimSound):
base.localAvatar.setWalkSpeedNormal()
base.localAvatar.applyBuffs()
self.swimSound = swimSound
self.swimSoundPlaying = 0
base.localAvatar.b_setAnimState('swim', base.localAvatar.animMultiplier)
base.localAvatar.startSleepSwimTest()
taskMgr.add(self.__swim, 'localToonSwimming')
taskMgr.add(self.__swimSoundTest, 'localToonSwimming')
def exitSwimming(self):
taskMgr.remove('localToonSwimming')
self.swimSound.stop()
del self.swimSound
self.swimSoundPlaying = 0
base.localAvatar.stopSleepSwimTest()
def __swimSoundTest(self, task):
speed, rotSpeed, slideSpeed = base.localAvatar.controlManager.getSpeeds()
def __swim(self, task):
speed = base.mouseInterfaceNode.getSpeed()
if speed == 0 and self.swimSoundPlaying:
if (speed or rotSpeed):
if not self.swimSoundPlaying:
self.swimSoundPlaying = 1
base.playSfx(self.swimSound, looping=1)
elif self.swimSoundPlaying:
self.swimSoundPlaying = 0
self.swimSound.stop()
elif speed > 0 and self.swimSoundPlaying == 0 and self.IsSwimSoundAudible:
self.swimSoundPlaying = 1
base.playSfx(self.swimSound, looping=1)
return Task.cont
def enterSlowWalking(self):

View file

@ -1628,13 +1628,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar):
print 'Local Toon Anim State %s' % animName
DistributedToon.DistributedToon.b_setAnimState(self, animName, animMultiplier, callback, extraArgs)
def swimTimeoutAction(self):
self.ignore('wakeup')
self.takeOffSuit()
base.cr.playGame.getPlace().fsm.request('final')
self.b_setAnimState('TeleportOut', 1, self.__handleSwimExitTeleport, [0])
return Task.done
def __handleSwimExitTeleport(self, requestStatus):
self.notify.info('closing shard...')
base.cr.gameFSM.request('closeShard', ['afkTimeout'])