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 /* LuaEntitySAO-specific */
63 void setVelocity(v3f velocity);
65 void setAcceleration(v3f acceleration);
66 v3f getAcceleration();
67 void setYaw(float yaw);
69 void setTextureMod(const std::string &mod);
70 void setSprite(v2s16 p, int num_frames, float framelength,
71 bool select_horiz_by_yawpitch);
72 std::string getName();
73 void setArmorGroups(const ItemGroupList &armor_groups);
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);
140 Inventory* getInventory();
141 const Inventory* getInventory() const;
142 InventoryLocation getInventoryLocation() const;
143 void setInventoryModified();
144 std::string getWieldList() const;
145 int getWieldIndex() const;
146 void setWieldIndex(int i);
154 void createCreativeInventory();
160 u16 getPeerID() const
164 v3f getLastGoodPosition() const
166 return m_last_good_position;
168 float resetTimeFromLastPunch()
170 float r = m_time_from_last_punch;
171 m_time_from_last_punch = 0.0;
178 Inventory *m_inventory;
179 v3f m_last_good_position;
180 float m_last_good_position_age;
181 float m_time_from_last_punch;
183 bool m_position_not_sent;
186 // Some flags used by Server
188 bool m_inventory_not_sent;
190 bool m_wielded_item_not_sent;