Panda3D
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
PhasedObject Class Reference
Inheritance diagram for PhasedObject:
DistancePhasedNode AnfaPhasedObject BufferedDistancePhasedNode

Public Member Functions

 __init__ (self, aliasMap={})
 
 __repr__ (self)
 
 __str__ (self)
 
 cleanup (self)
 
 getAliasPhase (self, alias)
 
 getPhase (self)
 
 getPhaseAlias (self, phase)
 
 setAlias (self, phase, alias)
 
 setPhase (self, aPhase)
 

Public Attributes

 aliasPhaseMap
 
 phase
 
 phaseAliasMap
 

Static Public Attributes

 notify = directNotify.newCategory("PhasedObject")
 

Detailed Description

This class is governs the loading and unloading of successive
phases in an ordered and automatic manner.

An object can only have one phase at any given moment. At the
completion of setPhase() the current and all previous phases are
guaranteed to be loaded, while all later phases are guaranteed
to be unloaded.

In order to define a phase, simply define the functions:
loadPhase<#> and unloadPhase<#> where # corresponds to the number
of the phase to be defined and # >= 0.

You also have the ability to define alias for phases so that
your function definitions are more descriptive.  The way to do
this is to provide an aliasMap to __init__().  The aliasMap is
of the form {'alias':#, ...}. You can then call setPhase() with
this alias as well.

So for example, if you wanted to alias phase 0 to 'Far' you
would define loadPhaseFar() and unloadPhaseFar(). Upon calling
setPhase(0), setPhase('Far'), setPhase(<any phase greater than 0>),
or setPhase(<any alias greater than 'Far'>), loadPhaseFar() will
be invoked.

For a skeleton example class, see the AnfaPhasedObject class
definition lower in this file.

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self,
aliasMap = {} )

Member Function Documentation

◆ __repr__()

__repr__ ( self)

◆ __str__()

__str__ ( self)

◆ cleanup()

cleanup ( self)
Will force the unloading, in correct order, of all currently
loaded phases.

Reimplemented in DistancePhasedNode.

◆ getAliasPhase()

getAliasPhase ( self,
alias )
Returns the phase number of an alias, if it exists.
Otherwise, returns the alias.

◆ getPhase()

getPhase ( self)
Returns the current phase (or alias, if defined)
this object is currently in.

◆ getPhaseAlias()

getPhaseAlias ( self,
phase )
Returns the alias of a phase number, if it exists.
Otherwise, returns the phase number.

◆ setAlias()

setAlias ( self,
phase,
alias )
Map an alias to a phase number.

phase must be >= 0 and alias must be a string
of characters suitable for python variable names.

The mapping must be one-to-one.

◆ setPhase()

setPhase ( self,
aPhase )
aPhase can be either a phase number or a predefined alias.

Will invoke a sequence of loadPhase*() or unloadPhase*()
functions corresponding to the difference between the current
phase and aPhase, starting at the current phase.

Reimplemented in DistancePhasedNode, and BufferedDistancePhasedNode.

Member Data Documentation

◆ aliasPhaseMap

aliasPhaseMap

◆ notify

notify = directNotify.newCategory("PhasedObject")
static

◆ phase

phase

◆ phaseAliasMap

phaseAliasMap