]> git.lizzy.rs Git - dragonfireclient.git/blob - src/content_sao.h
Entity damage system WIP; Remove C++ mobs
[dragonfireclient.git] / src / content_sao.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
4
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.
9
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.
14
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.
18 */
19
20 #ifndef CONTENT_SAO_HEADER
21 #define CONTENT_SAO_HEADER
22
23 #include "serverobject.h"
24 #include "content_object.h"
25 #include "itemgroup.h"
26
27 ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos,
28                 const std::string itemstring);
29
30 /*
31         LuaEntitySAO
32         
33         This is the only SAO that needs to have a bunch of it's internals exposed.
34 */
35
36 struct LuaEntityProperties;
37
38 class LuaEntitySAO : public ServerActiveObject
39 {
40 public:
41         LuaEntitySAO(ServerEnvironment *env, v3f pos,
42                         const std::string &name, const std::string &state);
43         ~LuaEntitySAO();
44         u8 getType() const
45                 {return ACTIVEOBJECT_TYPE_LUAENTITY;}
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();
52         int punch(v3f dir,
53                         const ToolCapabilities *toolcap=NULL,
54                         ServerActiveObject *puncher=NULL,
55                         float time_from_last_punch=1000000);
56         void rightClick(ServerActiveObject *clicker);
57         void setPos(v3f pos);
58         void moveTo(v3f pos, bool continuous);
59         float getMinimumSavedMovement();
60         std::string getDescription();
61         void setHP(s16 hp);
62         s16 getHP();
63         /* LuaEntitySAO-specific */
64         void setVelocity(v3f velocity);
65         v3f getVelocity();
66         void setAcceleration(v3f acceleration);
67         v3f getAcceleration();
68         void setYaw(float yaw);
69         float getYaw();
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();
74 private:
75         void sendPosition(bool do_interpolate, bool is_movement_end);
76
77         std::string m_init_name;
78         std::string m_init_state;
79         bool m_registered;
80         struct LuaEntityProperties *m_prop;
81         
82         s16 m_hp;
83         v3f m_velocity;
84         v3f m_acceleration;
85         float m_yaw;
86         ItemGroupList m_armor_groups;
87
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 };
94
95 #endif
96