Ejemplo n.º 1
0
 def __init__(self,
              name,
              phaseParamMap={},
              autoCleanup=True,
              enterPrefix='enter',
              exitPrefix='exit',
              phaseCollideMask=BitMask32.allOn(),
              fromCollideNode=None):
     NodePath.__init__(self, name)
     self.phaseParamMap = phaseParamMap
     self.phaseParamList = sorted(phaseParamMap.items(),
                                  key=lambda x: x[1],
                                  reverse=True)
     PhasedObject.__init__(
         self,
         dict([(alias, phase) for phase, alias in enumerate(
             [item[0] for item in self.phaseParamList])]))
     self.__id = self.__allocateId()
     self.autoCleanup = autoCleanup
     self.enterPrefix = enterPrefix
     self.exitPrefix = exitPrefix
     self.phaseCollideMask = phaseCollideMask
     self.cTrav = base.cTrav
     self.fromCollideNode = fromCollideNode
     self._colSpheres = []
     self.reset()
Ejemplo n.º 2
0
    def cleanup(self):
        self.__disableCollisions(cleanup=True)
        for sphere in self._colSpheres:
            sphere.remove()

        self._colSpheres = []
        PhasedObject.cleanup(self)
Ejemplo n.º 3
0
 def setPhase(self, aPhase):
     phase = self.getAliasPhase(aPhase)
     PhasedObject.setPhase(self, aPhase)
     self.__disableCollisions()
     self.__enableCollisions(phase)
     if phase == -1 and self.autoCleanup:
         self.cleanup()
     else:
         self.__oneTimeCollide()
Ejemplo n.º 4
0
 def cleanup(self):
     """
     Disables all collisions.
     Ignores all owned event listeners.
     Unloads all unloaded phases.        
     """
     self.__disableCollisions(cleanup = True)
     for sphere in self._colSpheres:
         sphere.remove()
     self._colSpheres = []
     PhasedObject.cleanup(self)
Ejemplo n.º 5
0
 def cleanup(self):
     """
     Disables all collisions.
     Ignores all owned event listeners.
     Unloads all unloaded phases.        
     """
     self.__disableCollisions(cleanup=True)
     for sphere in self._colSpheres:
         sphere.remove()
     self._colSpheres = []
     PhasedObject.cleanup(self)
Ejemplo n.º 6
0
 def setPhase(self, aPhase):
     """
     See PhasedObject.setPhase()
     """
     phase = self.getAliasPhase(aPhase)
     PhasedObject.setPhase(self, aPhase)
     self.__disableCollisions()
     self.__enableCollisions(phase)
     
     if phase == -1 and self.autoCleanup:
         self.cleanup()
     else:
         self.__oneTimeCollide()
Ejemplo n.º 7
0
    def __init__(self, name, phaseParamMap = {},
                 autoCleanup = True,
                 enterPrefix = 'enter', exitPrefix = 'exit',
                 phaseCollideMask = BitMask32.allOn(),
                 fromCollideNode = None):
        NodePath.__init__(self, name)
        self.phaseParamMap = phaseParamMap
        self.phaseParamList = sorted(phaseParamMap.items(),
                                     key = lambda x: x[1],
                                     reverse = True)
        PhasedObject.__init__(self,
                              dict([(alias,phase) for (phase,alias) in enumerate([item[0] for item in self.phaseParamList])]))
        self.__id = self.__allocateId()

        self.autoCleanup = autoCleanup
        self.enterPrefix = enterPrefix
        self.exitPrefix = exitPrefix
        self.phaseCollideMask = phaseCollideMask
        self.cTrav = base.cTrav
        self.fromCollideNode = fromCollideNode
        self._colSpheres = []
        
        self.reset()