From 391268ed641a02eff640e1aeeed973d9e3011de3 Mon Sep 17 00:00:00 2001 From: Joe Shochet Date: Mon, 4 Dec 2000 18:37:29 +0000 Subject: [PATCH] *** empty log message *** --- direct/src/{showbase => fsm}/FSM.py | 16 ++++++++++++---- direct/src/{showbase => fsm}/State.py | 0 direct/src/showbase/ShowBase.py | 6 +----- 3 files changed, 13 insertions(+), 9 deletions(-) rename direct/src/{showbase => fsm}/FSM.py (87%) rename direct/src/{showbase => fsm}/State.py (100%) diff --git a/direct/src/showbase/FSM.py b/direct/src/fsm/FSM.py similarity index 87% rename from direct/src/showbase/FSM.py rename to direct/src/fsm/FSM.py index 1ddae872a8..974675664f 100644 --- a/direct/src/showbase/FSM.py +++ b/direct/src/fsm/FSM.py @@ -97,7 +97,7 @@ class FSM(DirectObject): def __exitCurrent(self, argList): """__exitCurrent(self) Exit the current state""" - FSM.notify.info("exiting %s" % self.__currentState.getName()) + FSM.notify.debug("exiting %s" % self.__currentState.getName()) self.__currentState.exit(argList) messenger.send(self.getName() + '_' + self.__currentState.getName() + '_exited') @@ -107,11 +107,11 @@ class FSM(DirectObject): """__enter(self, State) Enter a given state, if it exists""" if (aState in self.__states): + FSM.notify.debug("entering %s" % aState.getName()) self.__currentState = aState aState.enter(argList) messenger.send(self.getName() + '_' + aState.getName() + '_entered') - FSM.notify.info("entering %s" % aState.getName()) else: FSM.notify.error("enter: no such state") @@ -125,14 +125,22 @@ class FSM(DirectObject): """request(self, string) Attempt transition from currentState to given one. Return true is transition exists to given state, - false otherwise""" + false otherwise. + """ if (aStateName in self.__currentState.getTransitions()): self.__transition(self.getStateNamed(aStateName), enterArgList, exitArgList) return 1 + # We can implicitly always transition to our final state. + elif (aStateName == self.__finalState.getName()): + FSM.notify.debug("implicit transition to final state: %s" % aStateName) + self.__transition(self.getStateNamed(aStateName), + enterArgList, + exitArgList) + return 1 else: - FSM.notify.info("no transition exists to %s" % aStateName) + FSM.notify.debug("no transition exists to %s" % aStateName) return 0 diff --git a/direct/src/showbase/State.py b/direct/src/fsm/State.py similarity index 100% rename from direct/src/showbase/State.py rename to direct/src/fsm/State.py diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 457627ff70..aec6b16e9f 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -110,7 +110,7 @@ class ShowBase: return Task.cont def restart(self): - #self.shutdown() + self.shutdown() self.taskMgr.spawnTaskNamed(Task.Task(self.igloop), 'igloop') self.eventMgr.restart() @@ -166,7 +166,3 @@ class ShowBase: def run(self): self.taskMgr.run() -if __name__ == '__main__': - base = ShowBase() - base.run() -