Merge branch 'upstream/master'
[oweals/minetest.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
26 class TestSAO : public ServerActiveObject
27 {
28 public:
29         TestSAO(ServerEnvironment *env, u16 id, v3f pos);
30         u8 getType() const
31                 {return ACTIVEOBJECT_TYPE_TEST;}
32         static ServerActiveObject* create(ServerEnvironment *env, u16 id, v3f pos,
33                         const std::string &data);
34         void step(float dtime, bool send_recommended);
35 private:
36         float m_timer1;
37         float m_age;
38 };
39
40 class ItemSAO : public ServerActiveObject
41 {
42 public:
43         ItemSAO(ServerEnvironment *env, u16 id, v3f pos,
44                         const std::string inventorystring);
45         u8 getType() const
46                 {return ACTIVEOBJECT_TYPE_ITEM;}
47         static ServerActiveObject* create(ServerEnvironment *env, u16 id, v3f pos,
48                         const std::string &data);
49         void step(float dtime, bool send_recommended);
50         std::string getClientInitializationData();
51         std::string getStaticData();
52         InventoryItem* createInventoryItem();
53         InventoryItem* createPickedUpItem(){return createInventoryItem();}
54 private:
55         std::string m_inventorystring;
56         v3f m_speed_f;
57         v3f m_last_sent_position;
58         IntervalLimiter m_move_interval;
59 };
60
61 class RatSAO : public ServerActiveObject
62 {
63 public:
64         RatSAO(ServerEnvironment *env, u16 id, v3f pos);
65         u8 getType() const
66                 {return ACTIVEOBJECT_TYPE_RAT;}
67         static ServerActiveObject* create(ServerEnvironment *env, u16 id, v3f pos,
68                         const std::string &data);
69         void step(float dtime, bool send_recommended);
70         std::string getClientInitializationData();
71         std::string getStaticData();
72         InventoryItem* createPickedUpItem();
73 private:
74         bool m_is_active;
75         IntervalLimiter m_inactive_interval;
76         v3f m_speed_f;
77         v3f m_oldpos;
78         v3f m_last_sent_position;
79         float m_yaw;
80         float m_counter1;
81         float m_counter2;
82         float m_age;
83         bool m_touching_ground;
84 };
85
86 class Oerkki1SAO : public ServerActiveObject
87 {
88 public:
89         Oerkki1SAO(ServerEnvironment *env, u16 id, v3f pos);
90         u8 getType() const
91                 {return ACTIVEOBJECT_TYPE_OERKKI1;}
92         static ServerActiveObject* create(ServerEnvironment *env, u16 id, v3f pos,
93                         const std::string &data);
94         void step(float dtime, bool send_recommended);
95         std::string getClientInitializationData();
96         std::string getStaticData();
97         InventoryItem* createPickedUpItem(){return NULL;}
98         u16 punch(const std::string &toolname, v3f dir);
99 private:
100         void doDamage(u16 d);
101
102         bool m_is_active;
103         IntervalLimiter m_inactive_interval;
104         v3f m_speed_f;
105         v3f m_oldpos;
106         v3f m_last_sent_position;
107         float m_yaw;
108         float m_counter1;
109         float m_counter2;
110         float m_age;
111         bool m_touching_ground;
112         u8 m_hp;
113         float m_after_jump_timer;
114 };
115
116 class FireflySAO : public ServerActiveObject
117 {
118 public:
119         FireflySAO(ServerEnvironment *env, u16 id, v3f pos);
120         u8 getType() const
121                 {return ACTIVEOBJECT_TYPE_FIREFLY;}
122         static ServerActiveObject* create(ServerEnvironment *env, u16 id, v3f pos,
123                         const std::string &data);
124         void step(float dtime, bool send_recommended);
125         std::string getClientInitializationData();
126         std::string getStaticData();
127         InventoryItem* createPickedUpItem();
128 private:
129         bool m_is_active;
130         IntervalLimiter m_inactive_interval;
131         v3f m_speed_f;
132         v3f m_oldpos;
133         v3f m_last_sent_position;
134         float m_yaw;
135         float m_counter1;
136         float m_counter2;
137         float m_age;
138         bool m_touching_ground;
139 };
140
141 #endif
142