]> git.lizzy.rs Git - dragonfireclient.git/blob - src/activeobject.h
HTTP API: Allow binary downloads and headers (#8573)
[dragonfireclient.git] / src / activeobject.h
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 #pragma once
21
22 #include "irr_aabb3d.h"
23 #include <string>
24
25 enum ActiveObjectType {
26         ACTIVEOBJECT_TYPE_INVALID = 0,
27         ACTIVEOBJECT_TYPE_TEST = 1,
28 // Deprecated stuff
29         ACTIVEOBJECT_TYPE_ITEM = 2,
30 //      ACTIVEOBJECT_TYPE_RAT = 3,
31 //      ACTIVEOBJECT_TYPE_OERKKI1 = 4,
32 //      ACTIVEOBJECT_TYPE_FIREFLY = 5,
33         ACTIVEOBJECT_TYPE_MOBV2 = 6,
34 // End deprecated stuff
35         ACTIVEOBJECT_TYPE_LUAENTITY = 7,
36 // Special type, not stored as a static object
37         ACTIVEOBJECT_TYPE_PLAYER = 100,
38 // Special type, only exists as CAO
39         ACTIVEOBJECT_TYPE_GENERIC = 101,
40 };
41 // Other types are defined in content_object.h
42
43 struct ActiveObjectMessage
44 {
45         ActiveObjectMessage(u16 id_, bool reliable_=true, const std::string &data_ = "") :
46                 id(id_),
47                 reliable(reliable_),
48                 datastring(data_)
49         {}
50
51         u16 id;
52         bool reliable;
53         std::string datastring;
54 };
55
56 /*
57         Parent class for ServerActiveObject and ClientActiveObject
58 */
59 class ActiveObject
60 {
61 public:
62         ActiveObject(u16 id):
63                 m_id(id)
64         {
65         }
66
67         u16 getId() const
68         {
69                 return m_id;
70         }
71
72         void setId(u16 id)
73         {
74                 m_id = id;
75         }
76
77         virtual ActiveObjectType getType() const = 0;
78
79
80         /*!
81          * Returns the collision box of the object.
82          * This box is translated by the object's
83          * location.
84          * The box's coordinates are world coordinates.
85          * @returns true if the object has a collision box.
86          */
87         virtual bool getCollisionBox(aabb3f *toset) const = 0;
88
89
90         /*!
91          * Returns the selection box of the object.
92          * This box is not translated when the
93          * object moves.
94          * The box's coordinates are world coordinates.
95          * @returns true if the object has a selection box.
96          */
97         virtual bool getSelectionBox(aabb3f *toset) const = 0;
98
99
100         virtual bool collideWithObjects() const = 0;
101 protected:
102         u16 m_id; // 0 is invalid, "no id"
103 };