Unit Class Reference
[Engine Module]

#include <unit.h>

Inheritance diagram for Unit:

Root Flagged8 MessageReceiver< ActionEvent > MessageReceiver< StateEvent > MessageReceiver< InputEvent > MessageReceiver< PathResponse > Object TreeNode< Root > Referenced Flagged< Type > Counted Serialized List< Root > ListNode< Root > BuildingUnit ForceUnit

List of all members.

Public Types

enum  Type { TYPE_NONE, TYPE_FORCE, TYPE_BUILDING, TYPE_SOURCE }
enum  State {
  STATE_NONE, STATE_STAYING, STATE_NEXT_STEP, STATE_MOVING,
  STATE_ROTATING_LEFT, STATE_ROTATING_RIGHT, STATE_IS_BEING_BUILT, STATE_NEXT_HIDING,
  STATE_HIDING, STATE_NEXT_EJECTING, STATE_DYING, STATE_ZOMBIE,
  STATE_DELETE, STATE_GHOST
}
enum  Flag {
  FLAG_NONE = 0, FLAG_SELECTED = (1 << 0), FLAG_UNDER_CURSOR = (1 << 1), FLAG_VISIBLE = (1 << 2),
  FLAG_PROCESSED = (1 << 3), FLAG_ALL = (FLAG_SELECTED | FLAG_UNDER_CURSOR | FLAG_VISIBLE | FLAG_PROCESSED)
}
enum  Action {
  ACTION_NONE, ACTION_STAY, ACTION_MOVE, ACTION_ATTACK,
  ACTION_MINE, ACTION_REPAIR, ACTION_BUILD, ACTION_HIDE,
  ACTION_EJECT
}
enum  Input { INPUT_NONE, INPUT_MEETING_POINT }
enum  Aggressivity { AGGRESSIVITY_IGNORE, AGGRESSIVITY_PASSIVE, AGGRESSIVITY_GUARD, AGGRESSIVITY_OFFENSIVE }
 Aggresivity of the unit when detects enemy. More...
enum  ModelType {
  MODEL_STAY, MODEL_MOVE, MODEL_ATTACK, MODEL_BUILD,
  MODEL_REPAIR, MODEL_MINE, MODEL_ZOMBIE, MODEL_COUNT
}

Public Member Functions

 Unit (const char *id)
virtual ~Unit ()
void Say (bool possitive, const char *message,...) const
ushort_t GetRemoteID () const
Type GetType () const
bool TestType (Type type) const
State GetState () const
bool TestState (State state) const
void SetLife (float life)
float GetLife () const
float GetLifePercent () const
PlayerGetPlayer () const
PrototypeGetPrototype () const
bool SetPrototype (Prototype *prototype)
const MapPosition3DGetMapPosition () const
void SetMapPosition (const MapPosition3D &position, bool change_real=true)
const vector3GetRealPosition () const
void SetRealPosition (float x, float y)
MapEnums::Direction GetDirection () const
void SetDirection (MapEnums::Direction direction)
void GetCenterPosition (vector2 &position) const
bool GetMeetingPoint (MapPosition3D &meeting_point) const
SceneObjectGetSceneObject () const
Aggressivity SetAggressivity (Aggressivity aggressivity)
Aggressivity GetAggressivity () const
bool TestAggressivity (Aggressivity aggressivity) const
float GetHidingPercent () const
byte_t GetHidingCount () const
bool IsMy () const
bool IsIdle () const
bool IsMoving () const
bool IsFull () const
void Update (bool &create_ghost, bool &delete_unit)
Action GetAction () const
bool TestAction (Action action) const
bool CanEject () const
bool CanHide (const ForceUnit *unit) const
void AddToHidingList (ForceUnit *unit)
void RemoveFromHidingList (ForceUnit *unit)
void ShowMeetingPoint (bool show) const

Static Public Member Functions

static bool StringToModelType (const string &name, ModelType &type)
static bool ModelTypeToString (ModelType type, string &name)

Protected Member Functions

void SetState (State state)
bool PreProcessEvent (StateEvent *pevent)
void PostProcessEvent ()
void SetGhostOwner (Unit *owner)
bool StartMoving (Unit *unit)
bool StartMoving (const MapPosition3D &dest_position)
bool StartEjecting ()
virtual void StopAction ()
void SetMeetingPoint (const MapPosition3D &meeting_point)
virtual void OnMessage (ActionEvent *pevent)
virtual void OnMessage (StateEvent *pevent)
virtual void OnMessage (InputEvent *pevent)
virtual void OnMessage (PathResponse *response)
bool IsAroundUnit (const Unit *unit) const
bool FindFreePositionAroundUnit (const Unit *unit, MapPosition3D &free_position, MapEnums::Direction &free_direction) const
void GetFirstEjectingPosition (MapPosition3D &position, const MapSize &unit_size) const
void GetNextEjectingPosition (MapPosition3D &position, const MapSize &unit_size) const
virtual bool SetModel (const string &model_id, byte_t num_id)
virtual bool ActivateModel (ModelType model)
virtual void RenderPred ()
virtual void RenderPost ()
virtual
SelectionRenderer
GetSelectionRenderer ()
virtual bool Serialize (Serializer &serializer)
virtual bool Deserialize (Serializer &serializer, bool first)
bool ReadPosition (Serializer &serializer)

Static Protected Member Functions

static void OnRenderBegin (void *data)
static void OnRenderEnd (void *data)

Protected Attributes

ushort_t remote_id
Type type
State state
 State of the unit. Can be set only by unit itself.
Playerplayer
string prototype_id
Prototypeprototype
SceneObjectscene_object
SceneObjectmeeting_object
float life
float life_percent
MapPosition3D map_position
vector3 real_position
MapEnums::Direction direction
Aggressivity aggressivity
HidingList hiding_units
byte_t hiding_count
 Total number of fields engaged by hiding units.
byte_t hiding_count_my
 Number of my units that are hiding here.
MapPosition3D meeting_point
Unitghost_owner
List< BaseMessagewaiting_queue
uint_t sequence
uint_t path_request_id
Pathpath

Private Types

typedef list
< ForceUnit * > 
HidingList

Private Member Functions

bool StartMoving (const MapArea &dest_area, MapEnums::Segment dest_segment, Unit *unit)

Friends

class Player


Member Typedef Documentation

typedef list<ForceUnit *> Unit::HidingList [private]


Member Enumeration Documentation

enum Unit::Type

Enumerator:
TYPE_NONE 
TYPE_FORCE 
TYPE_BUILDING 
TYPE_SOURCE 

enum Unit::State

Enumerator:
STATE_NONE 
STATE_STAYING 
STATE_NEXT_STEP 
STATE_MOVING 
STATE_ROTATING_LEFT 
STATE_ROTATING_RIGHT 
STATE_IS_BEING_BUILT 
STATE_NEXT_HIDING 
STATE_HIDING 
STATE_NEXT_EJECTING 
STATE_DYING 
STATE_ZOMBIE 
STATE_DELETE 
STATE_GHOST 

enum Unit::Flag

Enumerator:
FLAG_NONE 
FLAG_SELECTED  Whether unit is selected.
FLAG_UNDER_CURSOR  Whether unit is under mouse cursor (pick unit).
FLAG_VISIBLE  Whether unit is visible (= not under warfog).
FLAG_PROCESSED 
FLAG_ALL 

enum Unit::Action

Enumerator:
ACTION_NONE 
ACTION_STAY 
ACTION_MOVE 
ACTION_ATTACK 
ACTION_MINE 
ACTION_REPAIR 
ACTION_BUILD 
ACTION_HIDE 
ACTION_EJECT 

enum Unit::Input

Enumerator:
INPUT_NONE 
INPUT_MEETING_POINT 

enum Unit::Aggressivity

Aggresivity of the unit when detects enemy.

Enumerator:
AGGRESSIVITY_IGNORE  Ignores enemy - doesn't take any action.
AGGRESSIVITY_PASSIVE  Attack enemy when it is possible to aim him but doesn't follow him.
AGGRESSIVITY_GUARD  Attack and follow enemy, but not too far. Come back if run away.
AGGRESSIVITY_OFFENSIVE  Attack and follow enemy if run away.

enum Unit::ModelType

Enumerator:
MODEL_STAY 
MODEL_MOVE 
MODEL_ATTACK 
MODEL_BUILD 
MODEL_REPAIR 
MODEL_MINE 
MODEL_ZOMBIE 
MODEL_COUNT 


Constructor & Destructor Documentation

Unit::Unit ( const char *  id  ) 

Direction of unit is set to random number.

Unit::~Unit (  )  [virtual]

Releases scene objects, ghost owner, path and all waiting events.


Member Function Documentation

void Unit::Say ( bool  possitive,
const char *  message,
  ... 
) const

ushort_t Unit::GetRemoteID (  )  const [inline]

Unit::Type Unit::GetType (  )  const [inline]

bool Unit::TestType ( Type  type  )  const [inline]

Unit::State Unit::GetState (  )  const [inline]

bool Unit::TestState ( State  state  )  const [inline]

void Unit::SetLife ( float  life  ) 

float Unit::GetLife (  )  const [inline]

float Unit::GetLifePercent (  )  const [inline]

Player * Unit::GetPlayer (  )  const [inline]

Prototype * Unit::GetPrototype (  )  const [inline]

bool Unit::SetPrototype ( Prototype prototype  ) 

const MapPosition3D & Unit::GetMapPosition (  )  const [inline]

void Unit::SetMapPosition ( const MapPosition3D position,
bool  change_real = true 
) [inline]

Sets new map position. Real position is changed only if second paramater is set to true. Meeting point is reset to the same value as map position.

const vector3 & Unit::GetRealPosition (  )  const [inline]

void Unit::SetRealPosition ( float  x,
float  y 
)

MapEnums::Direction Unit::GetDirection (  )  const [inline]

void Unit::SetDirection ( MapEnums::Direction  direction  )  [inline]

void Unit::GetCenterPosition ( vector2 position  )  const

bool Unit::GetMeetingPoint ( MapPosition3D meeting_point  )  const [inline]

SceneObject * Unit::GetSceneObject (  )  const [inline]

Unit::Aggressivity Unit::SetAggressivity ( Aggressivity  aggressivity  ) 

The method sets new unit's aggressivity. If given aggressivity is not compatible, the highest possible is set.

Returns:
New aggressivity of the unit.

Unit::Aggressivity Unit::GetAggressivity (  )  const [inline]

bool Unit::TestAggressivity ( Unit::Aggressivity  aggressivity  )  const [inline]

float Unit::GetHidingPercent (  )  const

byte_t Unit::GetHidingCount (  )  const [inline]

bool Unit::IsMy (  )  const

bool Unit::IsIdle (  )  const [inline]

bool Unit::IsMoving (  )  const [inline]

bool Unit::IsFull (  )  const

void Unit::Update ( bool &  create_ghost,
bool &  delete_unit 
)

Unit::Action Unit::GetAction (  )  const [inline]

bool Unit::TestAction ( Unit::Action  action  )  const [inline]

bool Unit::CanEject (  )  const [inline]

bool Unit::CanHide ( const ForceUnit unit  )  const

void Unit::AddToHidingList ( ForceUnit unit  ) 

Simply adds unit into the list. No checks and actions are done here. Use CanHide method to test if unit can be hide to this one.

void Unit::RemoveFromHidingList ( ForceUnit unit  ) 

Simply removes unit from list. No other actions are done here.

void Unit::ShowMeetingPoint ( bool  show  )  const

bool Unit::StringToModelType ( const string &  name,
ModelType type 
) [static]

bool Unit::ModelTypeToString ( ModelType  type,
string &  name 
) [static]

void Unit::SetState ( State  state  )  [protected]

bool Unit::PreProcessEvent ( StateEvent pevent  )  [protected]

void Unit::PostProcessEvent (  )  [protected]

void Unit::SetGhostOwner ( Unit owner  )  [inline, protected]

bool Unit::StartMoving ( Unit unit  )  [protected]

bool Unit::StartMoving ( const MapPosition3D dest_position  )  [protected]

bool Unit::StartEjecting (  )  [protected]

void Unit::StopAction (  )  [protected, virtual]

Reimplemented in ForceUnit.

void Unit::SetMeetingPoint ( const MapPosition3D meeting_point  )  [protected]

void Unit::OnMessage ( ActionEvent pevent  )  [protected, virtual]

Reimplemented from MessageReceiver< ActionEvent >.

Reimplemented in ForceUnit.

void Unit::OnMessage ( StateEvent pevent  )  [protected, virtual]

Todo:
Removing unit from map and adding back while moving is really ineffecive.

Todo:
Do not change real position.

Reimplemented from MessageReceiver< StateEvent >.

Reimplemented in ForceUnit.

void Unit::OnMessage ( InputEvent pevent  )  [protected, virtual]

Reimplemented from MessageReceiver< InputEvent >.

void Unit::OnMessage ( PathResponse response  )  [protected, virtual]

Reimplemented from MessageReceiver< PathResponse >.

bool Unit::IsAroundUnit ( const Unit unit  )  const [protected]

bool Unit::FindFreePositionAroundUnit ( const Unit unit,
MapPosition3D free_position,
MapEnums::Direction free_direction 
) const [protected]

void Unit::GetFirstEjectingPosition ( MapPosition3D position,
const MapSize unit_size 
) const [protected]

void Unit::GetNextEjectingPosition ( MapPosition3D position,
const MapSize unit_size 
) const [protected]

bool Unit::SetModel ( const string &  model_id,
byte_t  num_id 
) [protected, virtual]

Reimplemented in BuildingUnit, and ForceUnit.

bool Unit::ActivateModel ( ModelType  model  )  [protected, virtual]

Reimplemented in BuildingUnit, and ForceUnit.

void Unit::RenderPred (  )  [protected, virtual]

void Unit::RenderPost (  )  [protected, virtual]

SelectionRenderer * Unit::GetSelectionRenderer (  )  [protected, virtual]

Reimplemented in BuildingUnit.

void Unit::OnRenderBegin ( void *  data  )  [static, protected]

void Unit::OnRenderEnd ( void *  data  )  [static, protected]

bool Unit::Serialize ( Serializer serializer  )  [protected, virtual]

Todo:
Implement.

Reimplemented from Root.

bool Unit::Deserialize ( Serializer serializer,
bool  first 
) [protected, virtual]

Recursively deserialize all children.

Reimplemented from Root.

bool Unit::ReadPosition ( Serializer serializer  )  [protected]

bool Unit::StartMoving ( const MapArea dest_area,
MapEnums::Segment  dest_segment,
Unit unit 
) [private]


Friends And Related Function Documentation

friend class Player [friend]


Member Data Documentation

ushort_t Unit::remote_id [protected]

Type Unit::type [protected]

State Unit::state [protected]

State of the unit. Can be set only by unit itself.

Player* Unit::player [protected]

string Unit::prototype_id [protected]

Prototype* Unit::prototype [protected]

SceneObject* Unit::scene_object [protected]

SceneObject* Unit::meeting_object [protected]

float Unit::life [protected]

float Unit::life_percent [protected]

MapPosition3D Unit::map_position [protected]

vector3 Unit::real_position [protected]

MapEnums::Direction Unit::direction [protected]

Aggressivity Unit::aggressivity [protected]

HidingList Unit::hiding_units [protected]

byte_t Unit::hiding_count [protected]

Total number of fields engaged by hiding units.

byte_t Unit::hiding_count_my [protected]

Number of my units that are hiding here.

MapPosition3D Unit::meeting_point [protected]

Unit* Unit::ghost_owner [protected]

List<BaseMessage> Unit::waiting_queue [protected]

uint_t Unit::sequence [protected]

uint_t Unit::path_request_id [protected]

Path* Unit::path [protected]


The documentation for this class was generated from the following files:
Generated on Sat Oct 20 14:47:37 2007 for Dark Oberon by  doxygen 1.5.3