Don't remove furnace if something is inside it.
[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         void rightClick(Player *player);
55 private:
56         std::string m_inventorystring;
57         v3f m_speed_f;
58         v3f m_last_sent_position;
59         IntervalLimiter m_move_interval;
60 };
61
62 class RatSAO : public ServerActiveObject
63 {
64 public:
65         RatSAO(ServerEnvironment *env, u16 id, v3f pos);
66         u8 getType() const
67                 {return ACTIVEOBJECT_TYPE_RAT;}
68         static ServerActiveObject* create(ServerEnvironment *env, u16 id, v3f pos,
69                         const std::string &data);
70         void step(float dtime, bool send_recommended);
71         std::string getClientInitializationData();
72         std::string getStaticData();
73         InventoryItem* createPickedUpItem();
74 private:
75         bool m_is_active;
76         IntervalLimiter m_inactive_interval;
77         v3f m_speed_f;
78         v3f m_oldpos;
79         v3f m_last_sent_position;
80         float m_yaw;
81         float m_counter1;
82         float m_counter2;
83         float m_age;
84         bool m_touching_ground;
85 };
86
87 class Oerkki1SAO : public ServerActiveObject
88 {
89 public:
90         Oerkki1SAO(ServerEnvironment *env, u16 id, v3f pos);
91         u8 getType() const
92                 {return ACTIVEOBJECT_TYPE_OERKKI1;}
93         static ServerActiveObject* create(ServerEnvironment *env, u16 id, v3f pos,
94                         const std::string &data);
95         void step(float dtime, bool send_recommended);
96         std::string getClientInitializationData();
97         std::string getStaticData();
98         InventoryItem* createPickedUpItem(){return NULL;}
99         u16 punch(const std::string &toolname, v3f dir);
100 private:
101         void doDamage(u16 d);
102
103         bool m_is_active;
104         IntervalLimiter m_inactive_interval;
105         v3f m_speed_f;
106         v3f m_oldpos;
107         v3f m_last_sent_position;
108         float m_yaw;
109         float m_counter1;
110         float m_counter2;
111         float m_age;
112         bool m_touching_ground;
113         u8 m_hp;
114         float m_after_jump_timer;
115 };
116
117 class FireflySAO : public ServerActiveObject
118 {
119 public:
120         FireflySAO(ServerEnvironment *env, u16 id, v3f pos);
121         u8 getType() const
122                 {return ACTIVEOBJECT_TYPE_FIREFLY;}
123         static ServerActiveObject* create(ServerEnvironment *env, u16 id, v3f pos,
124                         const std::string &data);
125         void step(float dtime, bool send_recommended);
126         std::string getClientInitializationData();
127         std::string getStaticData();
128         InventoryItem* createPickedUpItem();
129 private:
130         bool m_is_active;
131         IntervalLimiter m_inactive_interval;
132         v3f m_speed_f;
133         v3f m_oldpos;
134         v3f m_last_sent_position;
135         float m_yaw;
136         float m_counter1;
137         float m_counter2;
138         float m_age;
139         bool m_touching_ground;
140 };
141
142 #endif
143