From 21274fd8b7822d65ecd40ecd1a592c0776125a4e Mon Sep 17 00:00:00 2001 From: Dave Schuyler Date: Thu, 4 Dec 2003 03:39:30 +0000 Subject: [PATCH] Added setIsOn to AI --- direct/src/fsm/FourState.py | 2 +- direct/src/fsm/FourStateAI.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/direct/src/fsm/FourState.py b/direct/src/fsm/FourState.py index 9b0a532fba..2c3bc0dcfc 100755 --- a/direct/src/fsm/FourState.py +++ b/direct/src/fsm/FourState.py @@ -139,7 +139,7 @@ class FourState: def changedOnState(self): """ - Allow derived classes to overide the this. + Allow derived classes to overide this. """ pass diff --git a/direct/src/fsm/FourStateAI.py b/direct/src/fsm/FourStateAI.py index d37b3ea1e8..87648ee729 100755 --- a/direct/src/fsm/FourStateAI.py +++ b/direct/src/fsm/FourStateAI.py @@ -146,10 +146,22 @@ class FourStateAI: def getInitialState(self): return self.stateIndex + def setIsOn(self, isOn): + assert(self.debugPrint("setIsOn(isOn=%s)"%(isOn,))) + if self.isOn != isOn: + self.isOn = isOn + self.changedOnState() + def getIsOn(self): assert(self.debugPrint("getIsOn() returning %s"%(self.isOn,))) return self.isOn + def changedOnState(self): + """ + Allow derived classes to overide this. + """ + pass + ##### states ##### def switchToNextStateTask(self, task): @@ -169,7 +181,7 @@ class FourStateAI: stateIndex, nextStateIndex))) self.stateIndex = stateIndex self.nextStateIndex = nextStateIndex - self.isOn = isOn + self.setIsOn(isOn) self.distributeStateChange() if self.durations[stateIndex] is not None: assert self.doLaterTask is None