2011-02-20 23:45:14 +01:00
|
|
|
/*
|
2013-02-24 18:40:43 +01:00
|
|
|
Minetest
|
2013-02-24 19:38:45 +01:00
|
|
|
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
2011-02-20 23:45:14 +01:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
2012-06-05 16:56:56 +02:00
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
2011-02-20 23:45:14 +01:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2012-06-05 16:56:56 +02:00
|
|
|
GNU Lesser General Public License for more details.
|
2011-02-20 23:45:14 +01:00
|
|
|
|
2012-06-05 16:56:56 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public License along
|
2011-02-20 23:45:14 +01:00
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2011-02-20 23:45:14 +01:00
|
|
|
|
2013-08-11 04:09:45 +02:00
|
|
|
#include "irr_aabb3d.h"
|
2019-07-29 19:14:07 +02:00
|
|
|
#include "irr_v3d.h"
|
2011-02-20 23:45:14 +01:00
|
|
|
#include <string>
|
|
|
|
|
2019-07-29 19:14:07 +02:00
|
|
|
|
2015-02-16 17:42:13 +01:00
|
|
|
enum ActiveObjectType {
|
|
|
|
ACTIVEOBJECT_TYPE_INVALID = 0,
|
|
|
|
ACTIVEOBJECT_TYPE_TEST = 1,
|
2019-10-29 19:23:12 +01:00
|
|
|
// Obsolete stuff
|
2015-02-16 17:42:13 +01:00
|
|
|
ACTIVEOBJECT_TYPE_ITEM = 2,
|
2017-05-20 08:15:56 +02:00
|
|
|
// ACTIVEOBJECT_TYPE_RAT = 3,
|
|
|
|
// ACTIVEOBJECT_TYPE_OERKKI1 = 4,
|
|
|
|
// ACTIVEOBJECT_TYPE_FIREFLY = 5,
|
2015-02-17 11:37:55 +01:00
|
|
|
ACTIVEOBJECT_TYPE_MOBV2 = 6,
|
2019-10-29 19:23:12 +01:00
|
|
|
// End obsolete stuff
|
2015-02-16 17:42:13 +01:00
|
|
|
ACTIVEOBJECT_TYPE_LUAENTITY = 7,
|
|
|
|
// Special type, not stored as a static object
|
|
|
|
ACTIVEOBJECT_TYPE_PLAYER = 100,
|
|
|
|
// Special type, only exists as CAO
|
|
|
|
ACTIVEOBJECT_TYPE_GENERIC = 101,
|
|
|
|
};
|
2011-06-26 14:48:56 +02:00
|
|
|
// Other types are defined in content_object.h
|
|
|
|
|
2011-02-20 23:45:14 +01:00
|
|
|
struct ActiveObjectMessage
|
|
|
|
{
|
2017-04-19 00:36:30 +02:00
|
|
|
ActiveObjectMessage(u16 id_, bool reliable_=true, const std::string &data_ = "") :
|
2011-02-20 23:45:14 +01:00
|
|
|
id(id_),
|
|
|
|
reliable(reliable_),
|
|
|
|
datastring(data_)
|
|
|
|
{}
|
|
|
|
|
|
|
|
u16 id;
|
|
|
|
bool reliable;
|
|
|
|
std::string datastring;
|
|
|
|
};
|
|
|
|
|
2020-04-10 19:49:20 +02:00
|
|
|
enum ActiveObjectCommand {
|
|
|
|
AO_CMD_SET_PROPERTIES,
|
|
|
|
AO_CMD_UPDATE_POSITION,
|
|
|
|
AO_CMD_SET_TEXTURE_MOD,
|
|
|
|
AO_CMD_SET_SPRITE,
|
|
|
|
AO_CMD_PUNCHED,
|
|
|
|
AO_CMD_UPDATE_ARMOR_GROUPS,
|
|
|
|
AO_CMD_SET_ANIMATION,
|
|
|
|
AO_CMD_SET_BONE_POSITION,
|
|
|
|
AO_CMD_ATTACH_TO,
|
|
|
|
AO_CMD_SET_PHYSICS_OVERRIDE,
|
|
|
|
AO_CMD_UPDATE_NAMETAG_ATTRIBUTES,
|
|
|
|
AO_CMD_SPAWN_INFANT,
|
|
|
|
AO_CMD_SET_ANIMATION_SPEED
|
|
|
|
};
|
|
|
|
|
2011-02-20 23:45:14 +01:00
|
|
|
/*
|
|
|
|
Parent class for ServerActiveObject and ClientActiveObject
|
|
|
|
*/
|
|
|
|
class ActiveObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ActiveObject(u16 id):
|
|
|
|
m_id(id)
|
|
|
|
{
|
|
|
|
}
|
2017-01-09 20:39:45 +01:00
|
|
|
|
2016-07-23 21:11:20 +02:00
|
|
|
u16 getId() const
|
2011-02-20 23:45:14 +01:00
|
|
|
{
|
|
|
|
return m_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setId(u16 id)
|
|
|
|
{
|
|
|
|
m_id = id;
|
|
|
|
}
|
|
|
|
|
2015-02-16 17:42:13 +01:00
|
|
|
virtual ActiveObjectType getType() const = 0;
|
2016-07-23 21:11:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Returns the collision box of the object.
|
|
|
|
* This box is translated by the object's
|
|
|
|
* location.
|
|
|
|
* The box's coordinates are world coordinates.
|
|
|
|
* @returns true if the object has a collision box.
|
|
|
|
*/
|
2017-01-09 20:39:45 +01:00
|
|
|
virtual bool getCollisionBox(aabb3f *toset) const = 0;
|
2016-07-23 21:11:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Returns the selection box of the object.
|
|
|
|
* This box is not translated when the
|
|
|
|
* object moves.
|
|
|
|
* The box's coordinates are world coordinates.
|
|
|
|
* @returns true if the object has a selection box.
|
|
|
|
*/
|
|
|
|
virtual bool getSelectionBox(aabb3f *toset) const = 0;
|
|
|
|
|
|
|
|
|
2017-01-09 20:39:45 +01:00
|
|
|
virtual bool collideWithObjects() const = 0;
|
2019-07-29 19:14:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
virtual void setAttachment(int parent_id, const std::string &bone, v3f position,
|
|
|
|
v3f rotation) {}
|
|
|
|
virtual void getAttachment(int *parent_id, std::string *bone, v3f *position,
|
|
|
|
v3f *rotation) const {}
|
|
|
|
virtual void clearChildAttachments() {}
|
|
|
|
virtual void clearParentAttachment() {}
|
|
|
|
virtual void addAttachmentChild(int child_id) {}
|
|
|
|
virtual void removeAttachmentChild(int child_id) {}
|
2011-02-20 23:45:14 +01:00
|
|
|
protected:
|
|
|
|
u16 m_id; // 0 is invalid, "no id"
|
|
|
|
};
|