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"
28 ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos,
29 const std::string itemstring);
32 LuaEntitySAO needs some internals exposed.
35 struct LuaEntityProperties;
37 class LuaEntitySAO : public ServerActiveObject
40 LuaEntitySAO(ServerEnvironment *env, v3f pos,
41 const std::string &name, const std::string &state);
44 {return ACTIVEOBJECT_TYPE_LUAENTITY;}
45 virtual void addedToEnvironment();
46 static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
47 const std::string &data);
48 void step(float dtime, bool send_recommended);
49 std::string getClientInitializationData();
50 std::string getStaticData();
52 const ToolCapabilities *toolcap=NULL,
53 ServerActiveObject *puncher=NULL,
54 float time_from_last_punch=1000000);
55 void rightClick(ServerActiveObject *clicker);
57 void moveTo(v3f pos, bool continuous);
58 float getMinimumSavedMovement();
59 std::string getDescription();
62 void setArmorGroups(const ItemGroupList &armor_groups);
63 /* LuaEntitySAO-specific */
64 void setVelocity(v3f velocity);
66 void setAcceleration(v3f acceleration);
67 v3f getAcceleration();
68 void setYaw(float yaw);
70 void setTextureMod(const std::string &mod);
71 void setSprite(v2s16 p, int num_frames, float framelength,
72 bool select_horiz_by_yawpitch);
73 std::string getName();
75 void sendPosition(bool do_interpolate, bool is_movement_end);
77 std::string m_init_name;
78 std::string m_init_state;
80 struct LuaEntityProperties *m_prop;
86 ItemGroupList m_armor_groups;
88 float m_last_sent_yaw;
89 v3f m_last_sent_position;
90 v3f m_last_sent_velocity;
91 float m_last_sent_position_timer;
92 float m_last_sent_move_precision;
93 bool m_armor_groups_sent;
97 PlayerSAO needs some internals exposed.
100 class PlayerSAO : public ServerActiveObject
103 PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_);
106 {return ACTIVEOBJECT_TYPE_PLAYER;}
107 std::string getDescription();
110 Active object <-> environment interface
113 void addedToEnvironment();
114 void removingFromEnvironment();
115 bool isStaticAllowed() const;
116 bool unlimitedTransferDistance() const;
117 std::string getClientInitializationData();
118 std::string getStaticData();
119 void step(float dtime, bool send_recommended);
120 void setBasePosition(const v3f &position);
121 void setPos(v3f pos);
122 void moveTo(v3f pos, bool continuous);
125 Interaction interface
129 const ToolCapabilities *toolcap,
130 ServerActiveObject *puncher,
131 float time_from_last_punch);
132 void rightClick(ServerActiveObject *clicker);
135 void setArmorGroups(const ItemGroupList &armor_groups);
141 Inventory* getInventory();
142 const Inventory* getInventory() const;
143 InventoryLocation getInventoryLocation() const;
144 void setInventoryModified();
145 std::string getWieldList() const;
146 int getWieldIndex() const;
147 void setWieldIndex(int i);
155 void createCreativeInventory();
161 u16 getPeerID() const
165 v3f getLastGoodPosition() const
167 return m_last_good_position;
169 float resetTimeFromLastPunch()
171 float r = m_time_from_last_punch;
172 m_time_from_last_punch = 0.0;
179 Inventory *m_inventory;
180 v3f m_last_good_position;
181 float m_last_good_position_age;
182 float m_time_from_last_punch;
184 bool m_position_not_sent;
185 ItemGroupList m_armor_groups;
186 bool m_armor_groups_sent;
189 // Some flags used by Server
191 bool m_inventory_not_sent;
193 bool m_wielded_item_not_sent;