[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Enigma-cvs] enigma/src objects.hh,1.59,1.60
From: |
Daniel Heck <address@hidden> |
Subject: |
[Enigma-cvs] enigma/src objects.hh,1.59,1.60 |
Date: |
Wed, 26 Nov 2003 08:11:53 +0000 |
Update of /cvsroot/enigma/enigma/src
In directory subversions:/tmp/cvs-serv8930/src
Modified Files:
objects.hh
Log Message:
- Doxygenified comments.
Index: objects.hh
===================================================================
RCS file: /cvsroot/enigma/enigma/src/objects.hh,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -d -r1.59 -r1.60
*** objects.hh 20 Nov 2003 20:24:42 -0000 1.59
--- objects.hh 26 Nov 2003 08:11:51 -0000 1.60
***************
*** 30,51 ****
#include <string>
- /*
- * Object is the base class for all ``objects'' in the world. The
- * most important facilities this class provides are:
- *
- * (1) A way to clone() and dispose() objects. This is mainly used in
- * function MakeObject() to create new objects of a given type.
- *
- * (2) A way to pass messages between unrelated objects via message().
- * This allows us to send messages to objects from Lua and to
- * decouple objects types as much as possible.
- *
- * (3) A way to get and set attributes. These attributes are quite
- * similar to instance variables, but they can be easily modified
- * from Lua. This makes it possible to modify certain object
- * parameters (such as the text on a piece of paper or the color
- * of an oxyd stone) in level descriptions.
- */
-
namespace world
{
--- 30,33 ----
***************
*** 103,106 ****
--- 85,109 ----
};
+
+
+ /* -------------------- Objects -------------------- */
+
+ /*! Object is the base class for all ``objects'' in the world.
+ The most important facilities this class provides are:
+
+ (1) A way to clone() and dispose() objects. This is mainly used
+ in function MakeObject() to create new objects of a given
+ type.
+
+ (2) A way to pass messages between unrelated objects via message().
+ This allows us to send messages to objects from Lua and to
+ decouple objects types as much as possible.
+
+ (3) A way to get and set attributes. These attributes are quite
+ similar to instance variables, but they can be easily modified
+ from Lua. This makes it possible to modify certain object
+ parameters (such as the text on a piece of paper or the color
+ of an oxyd stone) in level descriptions.
+ */
class Object {
public:
***************
*** 109,112 ****
--- 112,119 ----
virtual ~Object() {}
+ /* ---------- Attributes ---------- */
+
+ typedef px::AssocList<std::string, Value> AttribMap;
+
bool string_attrib (const string &name, string *val) const;
int int_attrib (const string &name) const;
***************
*** 118,125 ****
bool is_kind(const string& kind) const;
void send_impulse(const GridPos& dest, Direction dir);
void send_impulse(const GridPos& dest, Direction dir, double delay);
! // Object interface
virtual void message(const string& msg, const Value &val);
virtual void set_attrib(const string& key, const Value &val);
--- 125,137 ----
bool is_kind(const string& kind) const;
+ const AttribMap &get_attribs() const { return attribs; }
+
+
+
void send_impulse(const GridPos& dest, Direction dir);
void send_impulse(const GridPos& dest, Direction dir, double delay);
! /* ---------- Object interface ---------- */
!
virtual void message(const string& msg, const Value &val);
virtual void set_attrib(const string& key, const Value &val);
***************
*** 132,148 ****
virtual void warning(const char *format, ...) const;
- typedef px::AssocList<std::string, Value> AttribMap;
- const AttribMap &get_attribs() const { return attribs; }
private:
AttribMap attribs;
};
- }
! /*
! * GridObject is the base class for everything that can only be placed
! * on "The Grid", i.e., for floor tiles, items, and stones.
! */
! namespace world
! {
class GridObject : public Object, public display::ModelCallback {
public:
--- 144,158 ----
virtual void warning(const char *format, ...) const;
private:
AttribMap attribs;
};
!
! /* -------------------- GridObject -------------------- */
!
! /*! GridObject is the base class for everything that can only be
! placed on "The Grid", i.e., for floor tiles, items, and
! stones. */
!
class GridObject : public Object, public display::ModelCallback {
public:
***************
*** 212,222 ****
}
};
- }
! //
! // Floor
! //
! namespace world
! {
enum FloorFlags {
FLOOR_CanCrack = 0x01,
--- 222,229 ----
}
};
!
! /* -------------------- Floors -------------------- */
!
enum FloorFlags {
FLOOR_CanCrack = 0x01,
***************
*** 266,282 ****
FloorTraits traits;
};
- }
! //
! // Item
! //
! namespace world
! {
! // What may happen to an item _after_ it was activated?
enum ItemAction {
! ITEM_DROP, // drop it to the floor
! ITEM_DROP_AS_STONE, // drop to floor as stone (e.g.
Brake->BrakeStone)
! ITEM_KILL, // remove it from the inventory and dispose it
! ITEM_KEEP, // keep it in the inventory; do nothing
further
};
--- 273,286 ----
FloorTraits traits;
};
!
! /* -------------------- Items -------------------- */
!
! /*! What may happen to an item _after_ it was activated? */
enum ItemAction {
! ITEM_DROP, //< Drop it to the floor
! ITEM_DROP_AS_STONE, //< Drop to floor as stone (e.g.
Brake->BrakeStone)
! ITEM_KILL, //< Remove it from the inventory and dispose
it
! ITEM_KEEP, //< Keep it in the inventory; do nothing
further
};
***************
*** 289,331 ****
Item(const char *kind);
! //
! // Item interface
! //
virtual int get_id() const { return -1; }
! // Return true if item completely covers the floor. In this
! // case the floor's `actor_contact' method will not be called
! // automatically; this must be done from `Item::actor_hit' (if
! // at all).
virtual bool covers_floor() const { return false; }
virtual px::V2 get_force(Actor *a);
! // Called when item is dropped or picked up by actor A
virtual void on_drop(Actor *a);
virtual void on_pickup(Actor *a);
! // Called when stone above item changes
virtual void stone_change(Stone *st);
! // Called when item is ``hit'' by a moving stone.
virtual void on_stonehit(Stone *st);
! // Return true if the item should be picked up.
virtual bool actor_hit(Actor *a);
! // The model used for displaying this item in an inventory
virtual string get_inventory_model();
! // Item is activated by the player
virtual ItemAction activate(Actor* a, GridPos p);
};
- }
! //
! // Stone
! //
! namespace world
! {
struct StoneTraits {
const char *collision_sound;
--- 293,340 ----
Item(const char *kind);
! /* ---------- Item interface ---------- */
!
! /*! Return unique item type identifier. */
virtual int get_id() const { return -1; }
! /*! Return true if item completely covers the floor. In this
! case the floor's `actor_contact' method will not be called
! automatically; this must be done from `Item::actor_hit' (if
! at all). */
virtual bool covers_floor() const { return false; }
+ /*! Return the force an item exerts on actor `a'. This is
+ used by sloped and hills for force fields that are local to
+ the current field. For global force fields you have to
+ register a ForceField in the world. */
virtual px::V2 get_force(Actor *a);
! /*! Called when item is dropped by actor `a' */
virtual void on_drop(Actor *a);
+
+ /*! Called when item is picked up by actor `a' */
virtual void on_pickup(Actor *a);
! /*! Called when stone above item changes. */
virtual void stone_change(Stone *st);
! /*! Called when item is ``hit'' by a moving stone. */
virtual void on_stonehit(Stone *st);
! /*! Called when item is ``hit'' by an actor. Return true if
! the item should be picked up. */
virtual bool actor_hit(Actor *a);
! /*! The model used for displaying this item in an
! inventory. */
virtual string get_inventory_model();
! /* Called when item is activated by the owner of `a'. */
virtual ItemAction activate(Actor* a, GridPos p);
};
!
! /* -------------------- Stones -------------------- */
!
struct StoneTraits {
const char *collision_sound;
***************
*** 362,372 ****
static bool maybe_push_stone (const StoneContact &sc);
};
- }
! /*
! ** Actor
! */
! namespace world
! {
class Actor : public Object, public display::ModelCallback {
public:
--- 371,378 ----
static bool maybe_push_stone (const StoneContact &sc);
};
!
! /* -------------------- Actors -------------------- */
!
class Actor : public Object, public display::ModelCallback {
public:
***************
*** 432,436 ****
virtual void on_motion(px::V2 /*newpos*/) {}
! // Variables
world::ActorInfo actorinfo;
display::SpriteHandle m_sprite;
--- 438,443 ----
virtual void on_motion(px::V2 /*newpos*/) {}
! /* ---------- Variables ---------- */
!
world::ActorInfo actorinfo;
display::SpriteHandle m_sprite;
***************
*** 440,447 ****
bool spikes; // set by "it-pin"
};
- }
! namespace world
! {
Object *MakeObject (const char *kind);
Floor *MakeFloor (const char *kind);
--- 447,455 ----
bool spikes; // set by "it-pin"
};
!
!
! /* -------------------- Functions -------------------- */
!
Object *MakeObject (const char *kind);
Floor *MakeFloor (const char *kind);
***************
*** 452,457 ****
void DisposeObject(Object *o);
! void DefineSimpleStone(const string &kind, const string &sound, int
hollow, int glass);
! void DefineSimpleStoneMovable(const string &kind, const string &sound,
int glass);
void DefineSimpleFloor(const string &kind, double friction, double
mousefactor);
--- 460,469 ----
void DisposeObject(Object *o);
! void DefineSimpleStone (const string &kind, const string &sound,
! int hollow, int glass);
!
! void DefineSimpleStoneMovable (const string &kind, const string &sound,
! int glass);
!
void DefineSimpleFloor(const string &kind, double friction, double
mousefactor);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Enigma-cvs] enigma/src objects.hh,1.59,1.60,
Daniel Heck <address@hidden> <=