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"
25 #include "itemgroup.h"
27 #include "object_properties.h"
29 ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos,
30 const std::string itemstring);
33 LuaEntitySAO needs some internals exposed.
36 class LuaEntitySAO : public ServerActiveObject
39 LuaEntitySAO(ServerEnvironment *env, v3f pos,
40 const std::string &name, const std::string &state);
43 { return ACTIVEOBJECT_TYPE_LUAENTITY; }
44 u8 getSendType() const
45 { return ACTIVEOBJECT_TYPE_GENERIC; }
46 virtual void addedToEnvironment();
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();
53 const ToolCapabilities *toolcap=NULL,
54 ServerActiveObject *puncher=NULL,
55 float time_from_last_punch=1000000);
56 void rightClick(ServerActiveObject *clicker);
58 void moveTo(v3f pos, bool continuous);
59 float getMinimumSavedMovement();
60 std::string getDescription();
63 void setArmorGroups(const ItemGroupList &armor_groups);
64 /* LuaEntitySAO-specific */
65 void setVelocity(v3f velocity);
67 void setAcceleration(v3f acceleration);
68 v3f getAcceleration();
69 void setYaw(float yaw);
71 void setTextureMod(const std::string &mod);
72 void setSprite(v2s16 p, int num_frames, float framelength,
73 bool select_horiz_by_yawpitch);
74 std::string getName();
76 std::string getPropertyPacket();
77 void sendPosition(bool do_interpolate, bool is_movement_end);
79 std::string m_init_name;
80 std::string m_init_state;
82 struct ObjectProperties m_prop;
88 ItemGroupList m_armor_groups;
90 bool m_properties_sent;
91 float m_last_sent_yaw;
92 v3f m_last_sent_position;
93 v3f m_last_sent_velocity;
94 float m_last_sent_position_timer;
95 float m_last_sent_move_precision;
96 bool m_armor_groups_sent;
100 PlayerSAO needs some internals exposed.
103 class PlayerSAO : public ServerActiveObject
106 PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_);
109 { return ACTIVEOBJECT_TYPE_PLAYER; }
110 u8 getSendType() const
111 { return ACTIVEOBJECT_TYPE_GENERIC; }
112 std::string getDescription();
115 Active object <-> environment interface
118 void addedToEnvironment();
119 void removingFromEnvironment();
120 bool isStaticAllowed() const;
121 bool unlimitedTransferDistance() const;
122 std::string getClientInitializationData();
123 std::string getStaticData();
124 void step(float dtime, bool send_recommended);
125 void setBasePosition(const v3f &position);
126 void setPos(v3f pos);
127 void moveTo(v3f pos, bool continuous);
130 Interaction interface
134 const ToolCapabilities *toolcap,
135 ServerActiveObject *puncher,
136 float time_from_last_punch);
137 void rightClick(ServerActiveObject *clicker);
140 void setArmorGroups(const ItemGroupList &armor_groups);
146 Inventory* getInventory();
147 const Inventory* getInventory() const;
148 InventoryLocation getInventoryLocation() const;
149 void setInventoryModified();
150 std::string getWieldList() const;
151 int getWieldIndex() const;
152 void setWieldIndex(int i);
160 void createCreativeInventory();
166 u16 getPeerID() const
170 v3f getLastGoodPosition() const
172 return m_last_good_position;
174 float resetTimeFromLastPunch()
176 float r = m_time_from_last_punch;
177 m_time_from_last_punch = 0.0;
182 std::string getPropertyPacket();
186 Inventory *m_inventory;
187 v3f m_last_good_position;
188 float m_last_good_position_age;
189 float m_time_from_last_punch;
191 bool m_position_not_sent;
192 ItemGroupList m_armor_groups;
193 bool m_armor_groups_sent;
194 bool m_properties_sent;
195 struct ObjectProperties m_prop;
198 // Some flags used by Server
200 bool m_inventory_not_sent;
202 bool m_wielded_item_not_sent;