Wartbed:Game Engine Structures

From Dark Omen Wiki

Revision as of 13:24, 27 July 2008 by Mikademus (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 UNIT_STATE
{
    STATE_normal    = 0,
    STATE_routing   = 1,
    STATE_fleeing   = 2,
    STATE_inactive  = 3,
    STATE_destroyed = 4, 
    STATE_gone      = 4,
};

Both "destroyed" and "gone" (left battle field) are the same for in-battle purposes.

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;
    UNIT_STATE state;

    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