oldschool-toontown/toontown/cogdominium/CogdoLevelGameBase.py

39 lines
1.3 KiB
Python
Raw Normal View History

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()
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):
from . import CogdoEntityTypes
2019-11-02 17:27:54 -05:00
from otp.level import EntityTypeRegistry
typeReg = EntityTypeRegistry.EntityTypeRegistry(CogdoEntityTypes)
return typeReg