forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStagedObject.py
More file actions
executable file
·64 lines (49 loc) · 1.87 KB
/
StagedObject.py
File metadata and controls
executable file
·64 lines (49 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class StagedObject:
"""
Use this class as a mixin to provide an interface for onStage/offStage objects.
The idea here is that a DistributedObject could be present and active due to
simple visibility, but we want to hide or otherwise disable it for some reason.
"""
UNKNOWN = -1
OFF = 0
ON = 1
def __init__(self, initState = UNKNOWN):
"""
Only sets the initial state of this object. This will not
call any "handle" functions.
"""
self.__state = initState
def goOnStage(self, *args, **kw):
"""
If a stage switch is needed, the correct "handle" function
will be called. Otherwise, nothing happens.
"""
# This is the high level function that clients of
# your class should call to set the on/off stage state.
if not self.isOnStage():
self.handleOnStage(*args, **kw)
def handleOnStage(self):
"""
Override this function to provide your on/off stage funcitionality.
Don't forget to call down to this one, though.
"""
self.__state = StagedObject.ON
def goOffStage(self, *args, **kw):
"""
If a stage switch is needed, the correct "handle" function
will be called. Otherwise, nothing happens.
"""
# This is the high level function that clients of
# your class should call to set the on/off stage state.
if not self.isOffStage():
self.handleOffStage(*args, **kw)
def handleOffStage(self):
"""
Override this function to provide your on/off stage funcitionality.
Don't forget to call down to this one, though.
"""
self.__state = StagedObject.OFF
def isOnStage(self):
return self.__state == StagedObject.ON
def isOffStage(self):
return self.__state == StagedObject.OFF