]> git.lizzy.rs Git - dragonfireclient.git/blob - src/activeobject.h
Make Lint Happy
[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 "irr_v3d.h"
24 #include <string>
25
26 enum ActiveObjectType
27 {
28         ACTIVEOBJECT_TYPE_INVALID = 0,
29         ACTIVEOBJECT_TYPE_TEST = 1,
30         // Obsolete stuff
31         ACTIVEOBJECT_TYPE_ITEM = 2,
32         //      ACTIVEOBJECT_TYPE_RAT = 3,
33         //      ACTIVEOBJECT_TYPE_OERKKI1 = 4,
34         //      ACTIVEOBJECT_TYPE_FIREFLY = 5,
35         ACTIVEOBJECT_TYPE_MOBV2 = 6,
36         // End obsolete stuff
37         ACTIVEOBJECT_TYPE_LUAENTITY = 7,
38         // Special type, not stored as a static object
39         ACTIVEOBJECT_TYPE_PLAYER = 100,
40         // Special type, only exists as CAO
41         ACTIVEOBJECT_TYPE_GENERIC = 101,
42 };
43 // Other types are defined in content_object.h
44
45 struct ActiveObjectMessage
46 {
47         ActiveObjectMessage(
48                         u16 id_, bool reliable_ = true, const std::string &data_ = "") :
49                         id(id_),
50                         reliable(reliable_), datastring(data_)
51         {
52         }
53
54         u16 id;
55         bool reliable;
56         std::string datastring;
57 };
58
59 enum ActiveObjectCommand
60 {
61         AO_CMD_SET_PROPERTIES,
62         AO_CMD_UPDATE_POSITION,
63         AO_CMD_SET_TEXTURE_MOD,
64         AO_CMD_SET_SPRITE,
65         AO_CMD_PUNCHED,
66         AO_CMD_UPDATE_ARMOR_GROUPS,
67         AO_CMD_SET_ANIMATION,
68         AO_CMD_SET_BONE_POSITION,
69         AO_CMD_ATTACH_TO,
70         AO_CMD_SET_PHYSICS_OVERRIDE,
71         AO_CMD_OBSOLETE1,
72         // ^ UPDATE_NAMETAG_ATTRIBUTES deprecated since 0.4.14, removed in 5.3.0
73         AO_CMD_SPAWN_INFANT,
74         AO_CMD_SET_ANIMATION_SPEED
75 };
76
77 /*
78         Parent class for ServerActiveObject and ClientActiveObject
79 */
80 class ActiveObject
81 {
82 public:
83         ActiveObject(u16 id) : m_id(id) {}
84
85         u16 getId() const { return m_id; }
86
87         void setId(u16 id) { m_id = id; }
88
89         virtual ActiveObjectType getType() const = 0;
90
91         /*!
92          * Returns the collision box of the object.
93          * This box is translated by the object's
94          * location.
95          * The box's coordinates are world coordinates.
96          * @returns true if the object has a collision box.
97          */
98         virtual bool getCollisionBox(aabb3f *toset) const = 0;
99
100         /*!
101          * Returns the selection box of the object.
102          * This box is not translated when the
103          * object moves.
104          * The box's coordinates are world coordinates.
105          * @returns true if the object has a selection box.
106          */
107         virtual bool getSelectionBox(aabb3f *toset) const = 0;
108
109         virtual bool collideWithObjects() const = 0;
110
111         virtual void setAttachment(int parent_id, const std::string &bone, v3f position,
112                         v3f rotation)
113         {
114         }
115         virtual void getAttachment(int *parent_id, std::string *bone, v3f *position,
116                         v3f *rotation) const
117         {
118         }
119         virtual void clearChildAttachments() {}
120         virtual void clearParentAttachment() {}
121         virtual void addAttachmentChild(int child_id) {}
122         virtual void removeAttachmentChild(int child_id) {}
123
124 protected:
125         u16 m_id; // 0 is invalid, "no id"
126 };