Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

TAction Class Reference

Handles atomic "action" performed by objects in the game. More...

#include <action.h>

Inheritance diagram for TAction:

Inheritance graph
[legend]
Collaboration diagram for TAction:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAction (const string &name, TActionType *type)
virtual ~TAction ()
virtual bool load (TDataPackageList *in)
virtual bool loadAttributes (TDataPackageList *in)
virtual bool save (TDataPackageList *out) const
virtual bool saveAttributes (TDataPackageList *out) const
void markAsExecuted ()
void objectValidationIsNeeded ()
virtual bool validateObjects ()
virtual bool checkActionConflicts ()
virtual bool resolveActionConflicts ()
virtual bool canUndo () const
virtual bool execute ()=0
void setActor (TActionObject *actor)
void setCreator (TRace *creator)
bool is (const TActionType type) const
virtual bool isPlayerAction () const
const TActionType getActionType () const
const string & getActionName () const
int2 getType () const
const string & getTypeName () const
TRacegetCreator () const

Static Public Methods

TAction * create (const string &actname)

Protected Methods

 TAction (const TActionType type, const string *tn)
virtual TAction * _new () const=0

Protected Attributes

TActionType Type
const string * TypeName
TLink< TRacefCreator
TLink< TActionObjectfActor
list< TLink< TActionObject > *> Objects
list< TLink< TActionObject > *> Observers

Static Private Methods

TAction * protoManager (TAction *act, const string &actname)

Private Attributes

bool Executed
bool ObjectsAreValid
bool IsPrototype

Static Private Attributes

uint4 iNumActionTypes

Detailed Description

Handles atomic "action" performed by objects in the game.

Author:
Alberto Barsella <Alberto.Barsella@univ-lille1.fr>
Version:
Id:
action.h,v 1.20 2002/06/04 09:21:18 mkrohn5 Exp

The three classes TAction, TActionObject and TActionSequencer are used to have the game objects perform "action" in the game world.

TAction is an abstract class which is to be used as base for deriving the specific actions which may take place in the universe.

TActionObject is an abstract class which is to be used as a base for any game object which can be involved in an action (either because it performs or is affected by one).

TActionSequencer is just a container for a list of action to be performed "simultaneously". The aim of TActionSequencer is to make sure that the action are executed in a way as to avoid or resolve any possible conflict resulting from the execution of actions (example, two fleets loading "all minerals" from a limited resource).

Actions are used for two main purposes:

The entire action framework is useless for "independent" events which may occur. For example, planetary population growth cannot in any way interfere across the planets. As a consequence it's completely useless to generate all the "grow population" actions and execute them. The growth can be simply performed on a per-planet basis with no risk of conflict.

Actions are useful when:


Member Function Documentation

virtual bool TAction::execute   [pure virtual]
 

The action object now is allowed to execute an action.

int2 TAction::getType   const [virtual]
 

Returns:
The type of the object (TType::TLinkable)

Reimplemented from TLinkable.

const string& TAction::getTypeName   const [virtual]
 

Returns:
"TLinkable".

Reimplemented from TLinkable.

virtual bool TAction::load TDataPackageList   in [virtual]
 

Loads a TLinkable. Note that classes that are derived from this class must call TLinkable::Load explicitly to load the data correctly.

Parameters:
in  The list of data packages.
Returns:
true means that everything was loaded correctly, otherwise this method will return false.

Reimplemented from TLinkable.

virtual bool TAction::loadAttributes TDataPackageList   in [virtual]
 

The attributes which a specific

virtual bool TAction::save TDataPackageList   out const [virtual]
 

Saves a TLinkable object by adding the data packages to the list. Note that classes that are derived from this class must call TLinkable::Save explicitly to save the data correctly.

Parameters:
out  The output stream of data packages.
Returns:
true means that everything was saved correctly, otherwise this method will return false.

Reimplemented from TLinkable.

void TAction::setActor TActionObject   actor
 

Sets a actor for this action. Note that an existing actor can not be changed--the method simply will ignore the parameter.

Parameters:
actor  Sets the actor of this action.

void TAction::setCreator TRace   creator
 

Sets a creator for this action. Note that an existing creator can not be changed--the method simply will ignore the parameter.

Parameters:
creator  Sets the creator of this action.


The documentation for this class was generated from the following file:
Generated on Thu Jun 20 18:13:17 2002 for Stellar Legacy by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001