2019-11-02 17:27:54 -05:00
|
|
|
from direct.fsm.StatePush import FunctionCall
|
|
|
|
from otp.level.EntityStateVarSet import EntityStateVarSet
|
|
|
|
from otp.level.LevelSpec import LevelSpec
|
|
|
|
|
|
|
|
class CogdoLevelGameBase:
|
|
|
|
|
|
|
|
def getLevelSpec(self):
|
|
|
|
return LevelSpec(self.getSpec())
|
|
|
|
|
|
|
|
if __dev__:
|
|
|
|
|
|
|
|
def startHandleEdits(self):
|
|
|
|
fcs = []
|
|
|
|
Consts = self.getConsts()
|
2019-12-30 00:07:56 -06:00
|
|
|
for item in Consts.__dict__.values():
|
2019-11-02 17:27:54 -05:00
|
|
|
if isinstance(item, EntityStateVarSet):
|
|
|
|
for attribName in item._getAttributeNames():
|
|
|
|
handler = getattr(self, '_handle%sChanged' % attribName, None)
|
|
|
|
if handler:
|
|
|
|
stateVar = getattr(item, attribName)
|
|
|
|
fcs.append(FunctionCall(handler, stateVar))
|
|
|
|
|
|
|
|
self._functionCalls = fcs
|
|
|
|
return
|
|
|
|
|
|
|
|
def stopHandleEdits(self):
|
|
|
|
if __dev__:
|
|
|
|
for fc in self._functionCalls:
|
|
|
|
fc.destroy()
|
|
|
|
|
|
|
|
self._functionCalls = None
|
|
|
|
return
|
|
|
|
|
|
|
|
def getEntityTypeReg(self):
|
2019-12-30 00:07:56 -06:00
|
|
|
from . import CogdoEntityTypes
|
2019-11-02 17:27:54 -05:00
|
|
|
from otp.level import EntityTypeRegistry
|
|
|
|
typeReg = EntityTypeRegistry.EntityTypeRegistry(CogdoEntityTypes)
|
|
|
|
return typeReg
|