Wartbed:Data structures

From Dark Omen Wiki

(Difference between revisions)
Jump to: navigation, search
(Created page, some structures)
(Added Target and Unit classes)
Line 1: Line 1:
==WARTBED Data Structures==
==WARTBED Data Structures==
-
Atm I'm (Mikademus) is using this article to jot down structures and ideas about the internal functioning of (OMG-)WARTBED. Please feel free to partake and discuss.  
+
Atm I (Mikademus) am using this article to jot down structures and ideas about the internal functioning of (OMG-)WARTBED. Please feel free to partake and discuss.  
==<tt>wartbed</tt> namespace==
==<tt>wartbed</tt> namespace==
Line 20: Line 20:
Control enum for all targeting, which is relevant for orders.  
Control enum for all targeting, which is relevant for orders.  
 +
 +
struct Position;
 +
struct Unit;
 +
 +
class Target
 +
{
 +
    TARGET_MODE target_type;
 +
    union
 +
    {
 +
        mutable Position *pPos;
 +
        Unit const *pUnit;
 +
    }
 +
 +
public:
 +
 +
    Target( Position const &rPos ) : target_type(TARGET_position)
 +
    {
 +
        pPos = new Position( rPos );
 +
    }
 +
 +
    Target( Unit const &rUnit ) : target_type(TARGET_unit)
 +
    {
 +
        pUnit = &rUnit;
 +
    }
 +
 +
    ~Target()
 +
    {
 +
        if (TARGET_position == target_type)
 +
            delete pPos;
 +
    }
 +
 +
    Vector3 operator* () const
 +
    {
 +
        return (TARGET_position == target_type) ? **pPos : pUnit->getPosition();
 +
    }
 +
};
 +
 +
Might seem as a complex class for its purpose, but it will be very convenient for a uniform interface when issuing orders.
 +
 +
class Unit
 +
{
 +
    FLOCKING_BEHAVIOUR flocking_mode;
 +
    Target target;
 +
};
 +
 +
Very preliminary stub.
===<tt>orders</tt> namespace===
===<tt>orders</tt> namespace===
-
blah blah
+
Sub-namespace to <code>wartbed</code>. Contains control structures and values for all orders that can be issued to units.
  enum MOVE_ORDER
  enum MOVE_ORDER
Line 33: Line 79:
     MOVE_face          = 5,
     MOVE_face          = 5,
     MOVE_continuous    = 0xF0000000,
     MOVE_continuous    = 0xF0000000,
 +
};
 +
 +
enum HOLD_ORDER
 +
{
 +
    HOLD_no      = 0,
 +
    HOLD_grounds = 1,
 +
    HOLD_pursue  = 2,
  };
  };
Line 41: Line 94:
     ATTACK_at_will      = 2,
     ATTACK_at_will      = 2,
     ATTACK_charge      = 3,
     ATTACK_charge      = 3,
-
     ATTACK_missile      = 4,
+
     ATTACK_fire_missile = 4,
     ATTACK_continuous  = 0xF0000000,
     ATTACK_continuous  = 0xF0000000,
-
  }
+
  };
 +
 
 +
enum FIRE_ORDER
 +
{
 +
    FIRE_no_order = 0,
 +
    FIRE_hold    = 1,
 +
    FIRE_at_will  = 2,
 +
    FIRE_normal  = 3,
 +
    FIRE_force    = 4,
 +
};
 +
 
[[category:WARTBED]]
[[category:WARTBED]]

Revision as of 13:37, 25 July 2008

WARTBED Data Structures

Atm I (Mikademus) am using this article to jot down structures and ideas about the internal functioning of (OMG-)WARTBED. Please feel free to partake and discuss.

wartbed namespace

enum FLOCKING_BEHAVIOUR
{
    FLOCK_none     = 0,
    FLOCK_mill     = 1,
    FLOCK_formate  = 2,
};

This enum will determine which algorithm that controls the immediate movement behaviour of an unit.

enum TARGET_MODE
{
    TARGET_position,
    TARGET_unit,
};

Control enum for all targeting, which is relevant for orders.

struct Position;
struct Unit;

class Target
{
    TARGET_MODE target_type;
    union
    {
        mutable Position *pPos;
        Unit const *pUnit;
    }

public:

    Target( Position const &rPos ) : target_type(TARGET_position)
    {
        pPos = new Position( rPos );
    }

    Target( Unit const &rUnit ) : target_type(TARGET_unit)
    {
        pUnit = &rUnit;
    }

    ~Target()
    {
        if (TARGET_position == target_type)
            delete pPos;
    }

    Vector3 operator* () const 
    {
        return (TARGET_position == target_type) ? **pPos : pUnit->getPosition();
    }
};

Might seem as a complex class for its purpose, but it will be very convenient for a uniform interface when issuing orders.

class Unit
{
    FLOCKING_BEHAVIOUR flocking_mode;
    Target target;
};

Very preliminary stub.

orders namespace

Sub-namespace to wartbed. Contains control structures and values for all orders that can be issued to units.

enum MOVE_ORDER
{
    MOVE_no_order      = 0,
    MOVE_to            = 1,
    MOVE_approach      = 2,
    MOVE_avoid         = 3,
    MOVE_keep_distance = 4,
    MOVE_face          = 5,
    MOVE_continuous    = 0xF0000000,
};
enum HOLD_ORDER
{
    HOLD_no      = 0,
    HOLD_grounds = 1,
    HOLD_pursue  = 2,
};
enum ATTACK_ORDER
{
    ATTACK_no_order     = 0,
    ATTACK_await_charge = 1, 
    ATTACK_at_will      = 2,
    ATTACK_charge       = 3,
    ATTACK_fire_missile = 4,
    ATTACK_continuous   = 0xF0000000,
};
enum FIRE_ORDER
{
    FIRE_no_order = 0,
    FIRE_hold     = 1,
    FIRE_at_will  = 2,
    FIRE_normal   = 3,
    FIRE_force    = 4,
};
Personal tools
communication