Package populus :: Module Formation :: Class FormationUnit
[frames] | no frames]

Class FormationUnit


Base abstract class for formation units. A formation unit is the basic component of a formation.

The class lists the methods that a FormationUnit as an interface has to have in order to guarantee transparency along all the formation code.


Note: In Composite design pattern a FormationUnit has the role of a Component.

Instance Methods
 
position(self)
The unit position.
 
direction(self)
The unit direction.
 
radius(self)
The unit radius.
 
bounds(self)
The unit AABB.
 
speed(self)
The unit speed.
 
goTo(self, point)
Move the unit to a given destination point.
 
update(self, dt)
Update the formation unit.
 
turnTo(self, dir)
Turn the unit toward a given direction.
 
add(self, unit)
Add a unit to the formation.
 
remove(self, unit)
Remove a unit from the formation.
 
getUnit(self, n)
Get the n-th unit.
int
getNumUnits(self)
Get the numbers of units.

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

goTo(self, point)

 

Move the unit to a given destination point.

Parameters:
  • point (Point3) - Destination point in global coordinates.

update(self, dt)

 

Update the formation unit.

Parameters:
  • dt (float) - Delta time since the simulation step.

turnTo(self, dir)

 

Turn the unit toward a given direction.

Parameters:
  • dir (Vec3) - Direction in global coordinates.

add(self, unit)

 

Add a unit to the formation.

Parameters:

Note: The abstract class declare this method to keep transparency along all the subclasses.

remove(self, unit)

 

Remove a unit from the formation.

Parameters:

Note: The abstract class declare this method to keep transparency along all the subclasses.

getUnit(self, n)

 

Get the n-th unit.

Parameters:
  • n (int) - The index of the unit to get.

Note: The abstract class declare this method to keep transparency along all the subclasses.

getNumUnits(self)

 

Get the numbers of units.

Returns: int
The number of units.

Note: The abstract class declare this method to keep transparency along all the subclasses.