Line data Source code
1 : /*
2 : Minetest
3 : Copyright (C) 2010-2013 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 Lesser General Public License as published by
7 : the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
14 :
15 : You should have received a copy of the GNU Lesser 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 ACTIVEOBJECT_HEADER
21 : #define ACTIVEOBJECT_HEADER
22 :
23 : #include "irr_aabb3d.h"
24 : #include <string>
25 :
26 : enum ActiveObjectType {
27 : ACTIVEOBJECT_TYPE_INVALID = 0,
28 : ACTIVEOBJECT_TYPE_TEST = 1,
29 : // Deprecated stuff
30 : ACTIVEOBJECT_TYPE_ITEM = 2,
31 : ACTIVEOBJECT_TYPE_RAT = 3,
32 : ACTIVEOBJECT_TYPE_OERKKI1 = 4,
33 : ACTIVEOBJECT_TYPE_FIREFLY = 5,
34 : ACTIVEOBJECT_TYPE_MOBV2 = 6,
35 : // End deprecated stuff
36 : ACTIVEOBJECT_TYPE_LUAENTITY = 7,
37 : // Special type, not stored as a static object
38 : ACTIVEOBJECT_TYPE_PLAYER = 100,
39 : // Special type, only exists as CAO
40 : ACTIVEOBJECT_TYPE_GENERIC = 101,
41 : };
42 : // Other types are defined in content_object.h
43 :
44 0 : struct ActiveObjectMessage
45 : {
46 0 : ActiveObjectMessage(u16 id_, bool reliable_=true, std::string data_=""):
47 : id(id_),
48 : reliable(reliable_),
49 0 : datastring(data_)
50 0 : {}
51 :
52 : u16 id;
53 : bool reliable;
54 : std::string datastring;
55 : };
56 :
57 : /*
58 : Parent class for ServerActiveObject and ClientActiveObject
59 : */
60 : class ActiveObject
61 : {
62 : public:
63 49 : ActiveObject(u16 id):
64 49 : m_id(id)
65 : {
66 49 : }
67 :
68 402611 : u16 getId()
69 : {
70 402611 : return m_id;
71 : }
72 :
73 44 : void setId(u16 id)
74 : {
75 44 : m_id = id;
76 44 : }
77 :
78 : virtual ActiveObjectType getType() const = 0;
79 : virtual bool getCollisionBox(aabb3f *toset) = 0;
80 : virtual bool collideWithObjects() = 0;
81 : protected:
82 : u16 m_id; // 0 is invalid, "no id"
83 : };
84 :
85 : #endif
86 :
|