3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
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.
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.
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.
20 #ifndef CLIENTOBJECT_HEADER
21 #define CLIENTOBJECT_HEADER
23 #include "common_irrlicht.h"
24 #include "activeobject.h"
31 * Client receives a network packet with information of added objects
33 * Client supplies the information to its ClientEnvironment
34 * The environment adds the specified objects to itself
38 class ClientEnvironment;
42 class ClientActiveObject : public ActiveObject
45 ClientActiveObject(u16 id, IGameDef *gamedef);
46 virtual ~ClientActiveObject();
48 virtual void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc){}
49 virtual void removeFromScene(){}
50 // 0 <= light_at_pos <= LIGHT_SUN
51 virtual void updateLight(u8 light_at_pos){}
52 virtual v3s16 getLightPosition(){return v3s16(0,0,0);}
53 virtual core::aabbox3d<f32>* getSelectionBox(){return NULL;}
54 virtual core::aabbox3d<f32>* getCollisionBox(){return NULL;}
55 virtual v3f getPosition(){return v3f(0,0,0);}
56 virtual bool doShowSelectionBox(){return true;}
58 // Step object in time
59 virtual void step(float dtime, ClientEnvironment *env){}
61 // Process a message sent by the server side object
62 virtual void processMessage(const std::string &data){}
64 virtual std::string infoText() {return "";}
67 This takes the return value of
68 ServerActiveObject::getClientInitializationData
70 virtual void initialize(const std::string &data){}
72 // Create a certain type of ClientActiveObject
73 static ClientActiveObject* create(u8 type, IGameDef *gamedef);
75 // If returns true, punch will not be sent to the server
76 virtual bool directReportPunch(const std::string &toolname, v3f dir)
80 // Used for creating objects based on type
81 typedef ClientActiveObject* (*Factory)(IGameDef *gamedef);
82 static void registerType(u16 type, Factory f);
85 // Used for creating objects based on type
86 static core::map<u16, Factory> m_types;
89 struct DistanceSortedActiveObject
91 ClientActiveObject *obj;
94 DistanceSortedActiveObject(ClientActiveObject *a_obj, f32 a_d)
100 bool operator < (DistanceSortedActiveObject &other)