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 ObjectProperties* accessObjectProperties();
65 void notifyObjectPropertiesModified();
66 /* LuaEntitySAO-specific */
67 void setVelocity(v3f velocity);
69 void setAcceleration(v3f acceleration);
70 v3f getAcceleration();
71 void setYaw(float yaw);
73 void setTextureMod(const std::string &mod);
74 void setSprite(v2s16 p, int num_frames, float framelength,
75 bool select_horiz_by_yawpitch);
76 std::string getName();
78 std::string getPropertyPacket();
79 void sendPosition(bool do_interpolate, bool is_movement_end);
81 std::string m_init_name;
82 std::string m_init_state;
84 struct ObjectProperties m_prop;
90 ItemGroupList m_armor_groups;
92 bool m_properties_sent;
93 float m_last_sent_yaw;
94 v3f m_last_sent_position;
95 v3f m_last_sent_velocity;
96 float m_last_sent_position_timer;
97 float m_last_sent_move_precision;
98 bool m_armor_groups_sent;
102 PlayerSAO needs some internals exposed.
105 class PlayerSAO : public ServerActiveObject
108 PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_);
111 { return ACTIVEOBJECT_TYPE_PLAYER; }
112 u8 getSendType() const
113 { return ACTIVEOBJECT_TYPE_GENERIC; }
114 std::string getDescription();
117 Active object <-> environment interface
120 void addedToEnvironment();
121 void removingFromEnvironment();
122 bool isStaticAllowed() const;
123 bool unlimitedTransferDistance() const;
124 std::string getClientInitializationData();
125 std::string getStaticData();
126 void step(float dtime, bool send_recommended);
127 void setBasePosition(const v3f &position);
128 void setPos(v3f pos);
129 void moveTo(v3f pos, bool continuous);
132 Interaction interface
136 const ToolCapabilities *toolcap,
137 ServerActiveObject *puncher,
138 float time_from_last_punch);
139 void rightClick(ServerActiveObject *clicker);
143 void setArmorGroups(const ItemGroupList &armor_groups);
144 ObjectProperties* accessObjectProperties();
145 void notifyObjectPropertiesModified();
151 Inventory* getInventory();
152 const Inventory* getInventory() const;
153 InventoryLocation getInventoryLocation() const;
154 void setInventoryModified();
155 std::string getWieldList() const;
156 int getWieldIndex() const;
157 void setWieldIndex(int i);
165 void createCreativeInventory();
171 u16 getPeerID() const
175 v3f getLastGoodPosition() const
177 return m_last_good_position;
179 float resetTimeFromLastPunch()
181 float r = m_time_from_last_punch;
182 m_time_from_last_punch = 0.0;
187 std::string getPropertyPacket();
191 Inventory *m_inventory;
192 v3f m_last_good_position;
193 float m_last_good_position_age;
194 float m_time_from_last_punch;
196 bool m_position_not_sent;
197 ItemGroupList m_armor_groups;
198 bool m_armor_groups_sent;
199 bool m_properties_sent;
200 struct ObjectProperties m_prop;
203 // Some flags used by Server
205 bool m_inventory_not_sent;
207 bool m_wielded_item_not_sent;