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 CONTENT_SAO_HEADER
21 #define CONTENT_SAO_HEADER
23 #include "serverobject.h"
24 #include "content_object.h"
26 class TestSAO : public ServerActiveObject
29 TestSAO(ServerEnvironment *env, v3f pos);
31 {return ACTIVEOBJECT_TYPE_TEST;}
32 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
33 const std::string &data);
34 void step(float dtime, bool send_recommended);
40 class ItemSAO : public ServerActiveObject
43 ItemSAO(ServerEnvironment *env, v3f pos,
44 const std::string inventorystring);
46 {return ACTIVEOBJECT_TYPE_ITEM;}
47 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
48 const std::string &data);
49 void step(float dtime, bool send_recommended);
50 std::string getClientInitializationData();
51 std::string getStaticData();
52 InventoryItem* createInventoryItem();
53 InventoryItem* createPickedUpItem(){return createInventoryItem();}
54 void rightClick(Player *player);
56 float getMinimumSavedMovement(){ return 0.1*BS; }
58 std::string m_inventorystring;
60 v3f m_last_sent_position;
61 IntervalLimiter m_move_interval;
64 class RatSAO : public ServerActiveObject
67 RatSAO(ServerEnvironment *env, v3f pos);
69 {return ACTIVEOBJECT_TYPE_RAT;}
70 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
71 const std::string &data);
72 void step(float dtime, bool send_recommended);
73 std::string getClientInitializationData();
74 std::string getStaticData();
75 InventoryItem* createPickedUpItem();
78 IntervalLimiter m_inactive_interval;
81 v3f m_last_sent_position;
86 bool m_touching_ground;
89 class Oerkki1SAO : public ServerActiveObject
92 Oerkki1SAO(ServerEnvironment *env, v3f pos);
94 {return ACTIVEOBJECT_TYPE_OERKKI1;}
95 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
96 const std::string &data);
97 void step(float dtime, bool send_recommended);
98 std::string getClientInitializationData();
99 std::string getStaticData();
100 InventoryItem* createPickedUpItem(){return NULL;}
101 u16 punch(const std::string &toolname, v3f dir,
102 const std::string &playername);
103 bool isPeaceful(){return false;}
105 void doDamage(u16 d);
108 IntervalLimiter m_inactive_interval;
111 v3f m_last_sent_position;
116 bool m_touching_ground;
118 float m_after_jump_timer;
121 class FireflySAO : public ServerActiveObject
124 FireflySAO(ServerEnvironment *env, v3f pos);
126 {return ACTIVEOBJECT_TYPE_FIREFLY;}
127 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
128 const std::string &data);
129 void step(float dtime, bool send_recommended);
130 std::string getClientInitializationData();
131 std::string getStaticData();
132 InventoryItem* createPickedUpItem();
135 IntervalLimiter m_inactive_interval;
138 v3f m_last_sent_position;
143 bool m_touching_ground;
148 class MobV2SAO : public ServerActiveObject
151 MobV2SAO(ServerEnvironment *env, v3f pos,
152 Settings *init_properties);
155 {return ACTIVEOBJECT_TYPE_MOBV2;}
156 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
157 const std::string &data);
158 std::string getStaticData();
159 std::string getClientInitializationData();
160 void step(float dtime, bool send_recommended);
161 InventoryItem* createPickedUpItem(){return NULL;}
162 u16 punch(const std::string &toolname, v3f dir,
163 const std::string &playername);
167 void setPropertyDefaults();
168 void readProperties();
169 void updateProperties();
170 void doDamage(u16 d);
172 std::string m_move_type;
174 v3f m_last_sent_position;
180 bool m_touching_ground;
183 float m_walk_around_timer;
184 bool m_next_pos_exists;
186 float m_shoot_reload_timer;
188 float m_shooting_timer;
192 float m_disturb_timer;
193 std::string m_disturbing_player;
194 float m_random_disturb_timer;
197 Settings *m_properties;
200 struct LuaEntityProperties;
202 class LuaEntitySAO : public ServerActiveObject
205 LuaEntitySAO(ServerEnvironment *env, v3f pos,
206 const std::string &name, const std::string &state);
209 {return ACTIVEOBJECT_TYPE_LUAENTITY;}
210 virtual void addedToEnvironment(u16 id);
211 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
212 const std::string &data);
213 void step(float dtime, bool send_recommended);
214 std::string getClientInitializationData();
215 std::string getStaticData();
216 InventoryItem* createPickedUpItem();
217 u16 punch(const std::string &toolname, v3f dir,
218 const std::string &playername);
219 void rightClick(Player *player);
221 void setPos(v3f pos);
222 void moveTo(v3f pos, bool continuous);
223 float getMinimumSavedMovement();
225 void sendPosition(bool do_interpolate, bool is_movement_end);
227 std::string m_init_name;
228 std::string m_init_state;
230 struct LuaEntityProperties *m_prop;
233 float m_last_sent_yaw;
234 v3f m_last_sent_position;
235 float m_last_sent_position_timer;
236 float m_last_sent_move_precision;