454531aec92603abfc51d00cdaa25d38d630b88d
[oweals/minetest.git] / src / clientobject.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef CLIENTOBJECT_HEADER
21 #define CLIENTOBJECT_HEADER
22
23 #include "common_irrlicht.h"
24 #include "activeobject.h"
25
26 /*
27
28 Some planning
29 -------------
30
31 * Client receives a network packet with information of added objects
32   in it
33 * Client supplies the information to its ClientEnvironment
34 * The environment adds the specified objects to itself
35
36 */
37
38 class ClientActiveObject : public ActiveObject
39 {
40 public:
41         ClientActiveObject(u16 id);
42         virtual ~ClientActiveObject();
43
44         virtual void addToScene(scene::ISceneManager *smgr){}
45         virtual void removeFromScene(){}
46         // 0 <= light_at_pos <= LIGHT_SUN
47         virtual void updateLight(u8 light_at_pos){}
48         virtual v3s16 getLightPosition(){return v3s16(0,0,0);}
49         
50         // Step object in time
51         virtual void step(float dtime){}
52         
53         // Process a message sent by the server side object
54         virtual void processMessage(const std::string &data){}
55
56         static ClientActiveObject* create(u8 type);
57
58 protected:
59 };
60
61 class TestCAO : public ClientActiveObject
62 {
63 public:
64         TestCAO(u16 id);
65         virtual ~TestCAO();
66         
67         u8 getType() const
68         {
69                 return ACTIVEOBJECT_TYPE_TEST;
70         }
71         
72         void addToScene(scene::ISceneManager *smgr);
73         void removeFromScene();
74         void updateLight(u8 light_at_pos);
75         v3s16 getLightPosition();
76         void updateNodePos();
77
78         void step(float dtime);
79
80         void processMessage(const std::string &data);
81
82 private:
83         scene::IMeshSceneNode *m_node;
84         v3f m_position;
85 };
86
87 #endif
88