summaryrefslogtreecommitdiff
path: root/src/clientobject.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-04-08 00:47:14 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-04-08 00:47:14 +0300
commit4b54b291ae2ba5a5f214cadad74f0bed29376f84 (patch)
treef386ca435350867508333d95f3e9f5537fbd28a1 /src/clientobject.h
parent2dba606e1217ffb236e19aa38157a945e919d76b (diff)
downloadminetest-4b54b291ae2ba5a5f214cadad74f0bed29376f84.tar.gz
minetest-4b54b291ae2ba5a5f214cadad74f0bed29376f84.tar.bz2
minetest-4b54b291ae2ba5a5f214cadad74f0bed29376f84.zip
Some progress on transitioning from MapBlockObject to ActiveObject.
Diffstat (limited to 'src/clientobject.h')
-rw-r--r--src/clientobject.h77
1 files changed, 74 insertions, 3 deletions
diff --git a/src/clientobject.h b/src/clientobject.h
index 226d2f337..ebdcb948e 100644
--- a/src/clientobject.h
+++ b/src/clientobject.h
@@ -46,6 +46,9 @@ public:
// 0 <= light_at_pos <= LIGHT_SUN
virtual void updateLight(u8 light_at_pos){}
virtual v3s16 getLightPosition(){return v3s16(0,0,0);}
+ virtual core::aabbox3d<f32>* getSelectionBox(){return NULL;}
+ virtual core::aabbox3d<f32>* getCollisionBox(){return NULL;}
+ virtual v3f getPosition(){return v3f(0,0,0);}
// Step object in time
virtual void step(float dtime){}
@@ -54,8 +57,8 @@ public:
virtual void processMessage(const std::string &data){}
/*
- This takes the return value of getClientInitializationData
- TODO: Usage of this
+ This takes the return value of
+ ServerActiveObject::getClientInitializationData
*/
virtual void initialize(const std::string &data){}
@@ -63,12 +66,37 @@ public:
static ClientActiveObject* create(u8 type);
protected:
+ typedef ClientActiveObject* (*Factory)();
+ static void registerType(u16 type, Factory f);
+private:
+ static core::map<u16, Factory> m_types;
};
+struct DistanceSortedActiveObject
+{
+ ClientActiveObject *obj;
+ f32 d;
+
+ DistanceSortedActiveObject(ClientActiveObject *a_obj, f32 a_d)
+ {
+ obj = a_obj;
+ d = a_d;
+ }
+
+ bool operator < (DistanceSortedActiveObject &other)
+ {
+ return d < other.d;
+ }
+};
+
+/*
+ TestCAO
+*/
+
class TestCAO : public ClientActiveObject
{
public:
- TestCAO(u16 id);
+ TestCAO();
virtual ~TestCAO();
u8 getType() const
@@ -76,6 +104,40 @@ public:
return ACTIVEOBJECT_TYPE_TEST;
}
+ static ClientActiveObject* create();
+
+ void addToScene(scene::ISceneManager *smgr);
+ void removeFromScene();
+ void updateLight(u8 light_at_pos);
+ v3s16 getLightPosition();
+ void updateNodePos();
+
+ void step(float dtime);
+
+ void processMessage(const std::string &data);
+
+private:
+ scene::IMeshSceneNode *m_node;
+ v3f m_position;
+};
+
+/*
+ ItemCAO
+*/
+
+class ItemCAO : public ClientActiveObject
+{
+public:
+ ItemCAO();
+ virtual ~ItemCAO();
+
+ u8 getType() const
+ {
+ return ACTIVEOBJECT_TYPE_ITEM;
+ }
+
+ static ClientActiveObject* create();
+
void addToScene(scene::ISceneManager *smgr);
void removeFromScene();
void updateLight(u8 light_at_pos);
@@ -86,9 +148,18 @@ public:
void processMessage(const std::string &data);
+ void initialize(const std::string &data);
+
+ core::aabbox3d<f32>* getSelectionBox()
+ {return &m_selection_box;}
+ v3f getPosition()
+ {return m_position;}
+
private:
+ core::aabbox3d<f32> m_selection_box;
scene::IMeshSceneNode *m_node;
v3f m_position;
+ std::string m_inventorystring;
};
#endif