EntityCreator.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. """EntityCreator module: contains the EntityCreator class"""
  2. import CutScene
  3. import EntityCreatorBase
  4. import BasicEntities
  5. from direct.directnotify import DirectNotifyGlobal
  6. import EditMgr
  7. import EntrancePoint
  8. import LevelMgr
  9. import LogicGate
  10. import ZoneEntity
  11. import ModelEntity
  12. import PathEntity
  13. import VisibilityExtender
  14. import PropSpinner
  15. import AmbientSound
  16. # some useful constructor functions
  17. # ctor functions must take (level, entId)
  18. # and they must return the entity that was created, or 'nothing'
  19. def nothing(*args):
  20. """For entities that don't need to be created by the client or don't
  21. exist on the client at all"""
  22. return 'nothing'
  23. class EntityCreator(EntityCreatorBase.EntityCreatorBase):
  24. """
  25. This class is responsible for creating instances of Entities on the
  26. client. It can be subclassed to handle more Entity types.
  27. """
  28. def __init__(self, level):
  29. EntityCreatorBase.EntityCreatorBase.__init__(self, level)
  30. self.level = level
  31. self.privRegisterTypes({
  32. 'ambientSound': AmbientSound.AmbientSound,
  33. 'cutScene': CutScene.CutScene,
  34. 'editMgr': EditMgr.EditMgr,
  35. 'entityGroup': nothing,
  36. 'entrancePoint': EntrancePoint.EntrancePoint,
  37. 'levelMgr': LevelMgr.LevelMgr,
  38. 'logicGate': LogicGate.LogicGate,
  39. 'model' : ModelEntity.ModelEntity,
  40. 'nodepath': BasicEntities.NodePathEntity,
  41. 'path' : PathEntity.PathEntity,
  42. 'propSpinner' : PropSpinner.PropSpinner,
  43. 'visibilityExtender': VisibilityExtender.VisibilityExtender,
  44. 'zone': ZoneEntity.ZoneEntity,
  45. })
  46. def doCreateEntity(self, ctor, entId):
  47. return ctor(self.level, entId)