2014-10-11 15:46:16 +02:00
|
|
|
/************************************************************************
|
|
|
|
* Minetest-c55
|
|
|
|
* Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|
|
|
*
|
|
|
|
* activeobject.h
|
|
|
|
* voxelands - 3d voxel world sandbox game
|
|
|
|
* Copyright (C) Lisa 'darkrose' Milne 2013-2014 <lisa@ltmnet.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (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 GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
* License updated from GPLv2 or later to GPLv3 or later by Lisa Milne
|
|
|
|
* for Voxelands.
|
|
|
|
************************************************************************/
|
2013-04-15 14:42:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef ACTIVEOBJECT_HEADER
|
|
|
|
#define ACTIVEOBJECT_HEADER
|
|
|
|
|
|
|
|
#include "common_irrlicht.h"
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#define ACTIVEOBJECT_TYPE_INVALID 0
|
|
|
|
// Other types are defined in content_object.h
|
|
|
|
|
|
|
|
struct ActiveObjectMessage
|
|
|
|
{
|
|
|
|
ActiveObjectMessage(u16 id_, bool reliable_=true, std::string data_=""):
|
|
|
|
id(id_),
|
|
|
|
reliable(reliable_),
|
|
|
|
datastring(data_)
|
|
|
|
{}
|
|
|
|
|
|
|
|
u16 id;
|
|
|
|
bool reliable;
|
|
|
|
std::string datastring;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Parent class for ServerActiveObject and ClientActiveObject
|
|
|
|
*/
|
|
|
|
class ActiveObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ActiveObject(u16 id):
|
|
|
|
m_id(id)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
u16 getId()
|
|
|
|
{
|
|
|
|
return m_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setId(u16 id)
|
|
|
|
{
|
|
|
|
m_id = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual u8 getType() const = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
u16 m_id; // 0 is invalid, "no id"
|
|
|
|
};
|
|
|
|
|
2014-12-07 09:27:58 +01:00
|
|
|
struct DistanceSortedActiveObject
|
|
|
|
{
|
|
|
|
ActiveObject *obj;
|
|
|
|
f32 d;
|
|
|
|
|
|
|
|
DistanceSortedActiveObject(ActiveObject *a_obj, f32 a_d)
|
|
|
|
{
|
|
|
|
obj = a_obj;
|
|
|
|
d = a_d;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator < (DistanceSortedActiveObject &other)
|
|
|
|
{
|
|
|
|
return d < other.d;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-04-15 14:42:24 +02:00
|
|
|
#endif
|
|
|
|
|