2011-06-26 14:48:56 +02: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-06-26 14:48:56 +02: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-06-26 14:48:56 +02: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-06-26 14:48:56 +02:00
|
|
|
|
2012-06-05 16:56:56 +02:00
|
|
|
You should have received a copy of the GNU Lesser General Public License along
|
2011-06-26 14:48:56 +02: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-06-26 14:48:56 +02:00
|
|
|
|
2017-09-27 19:47:36 +02:00
|
|
|
#include "network/networkprotocol.h"
|
|
|
|
#include "util/numeric.h"
|
2020-04-10 21:25:42 +02:00
|
|
|
#include "server/unit_sao.h"
|
2012-03-04 20:08:03 +01:00
|
|
|
#include "itemgroup.h"
|
2017-06-16 11:25:52 +02:00
|
|
|
#include "constants.h"
|
2016-10-30 14:53:26 +01:00
|
|
|
|
2012-03-04 20:08:03 +01:00
|
|
|
/*
|
2012-03-19 03:04:16 +01:00
|
|
|
LuaEntitySAO needs some internals exposed.
|
2012-03-04 20:08:03 +01:00
|
|
|
*/
|
2011-10-15 01:28:57 +02:00
|
|
|
|
2016-10-30 14:53:26 +01:00
|
|
|
class LuaEntitySAO : public UnitSAO
|
2011-11-11 18:33:17 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
LuaEntitySAO(ServerEnvironment *env, v3f pos,
|
2019-02-21 00:36:17 +01:00
|
|
|
const std::string &name, const std::string &state);
|
2011-11-11 18:33:17 +01:00
|
|
|
~LuaEntitySAO();
|
2015-02-16 17:42:13 +01:00
|
|
|
ActiveObjectType getType() const
|
2012-03-29 16:46:21 +02:00
|
|
|
{ return ACTIVEOBJECT_TYPE_LUAENTITY; }
|
2015-02-16 17:42:13 +01:00
|
|
|
ActiveObjectType getSendType() const
|
2012-03-29 16:46:21 +02:00
|
|
|
{ return ACTIVEOBJECT_TYPE_GENERIC; }
|
2012-09-09 16:12:29 +02:00
|
|
|
virtual void addedToEnvironment(u32 dtime_s);
|
2011-11-11 18:33:17 +01:00
|
|
|
static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
|
2019-02-21 00:36:17 +01:00
|
|
|
const std::string &data);
|
2011-11-11 18:33:17 +01:00
|
|
|
void step(float dtime, bool send_recommended);
|
2012-11-26 23:47:03 +01:00
|
|
|
std::string getClientInitializationData(u16 protocol_version);
|
2017-09-28 17:11:51 +02:00
|
|
|
bool isStaticAllowed() const
|
|
|
|
{ return m_prop.static_save; }
|
2017-01-11 22:48:14 +01:00
|
|
|
void getStaticData(std::string *result) const;
|
2019-09-22 22:12:21 +02:00
|
|
|
u16 punch(v3f dir,
|
2019-02-21 00:36:17 +01:00
|
|
|
const ToolCapabilities *toolcap = nullptr,
|
|
|
|
ServerActiveObject *puncher = nullptr,
|
2019-09-22 22:12:21 +02:00
|
|
|
float time_from_last_punch = 1000000.0f);
|
2011-11-12 16:37:14 +01:00
|
|
|
void rightClick(ServerActiveObject *clicker);
|
2016-10-30 16:12:09 +01:00
|
|
|
void setPos(const v3f &pos);
|
2011-11-12 12:59:56 +01:00
|
|
|
void moveTo(v3f pos, bool continuous);
|
2011-11-12 14:14:24 +01:00
|
|
|
float getMinimumSavedMovement();
|
2012-03-04 20:08:03 +01:00
|
|
|
std::string getDescription();
|
2019-02-11 00:03:26 +01:00
|
|
|
void setHP(s32 hp, const PlayerHPChangeReason &reason);
|
|
|
|
u16 getHP() const;
|
2019-02-21 00:36:17 +01:00
|
|
|
|
2011-11-26 11:35:30 +01:00
|
|
|
/* LuaEntitySAO-specific */
|
2011-11-21 10:15:15 +01:00
|
|
|
void setVelocity(v3f velocity);
|
2018-03-31 14:48:38 +02:00
|
|
|
void addVelocity(v3f velocity)
|
|
|
|
{
|
|
|
|
m_velocity += velocity;
|
|
|
|
}
|
2012-01-02 15:19:52 +01:00
|
|
|
v3f getVelocity();
|
2011-11-21 10:15:15 +01:00
|
|
|
void setAcceleration(v3f acceleration);
|
2011-11-27 03:31:05 +01:00
|
|
|
v3f getAcceleration();
|
2016-10-30 14:53:26 +01:00
|
|
|
|
2011-11-26 11:35:30 +01:00
|
|
|
void setTextureMod(const std::string &mod);
|
2017-01-14 19:32:10 +01:00
|
|
|
std::string getTextureMod() const;
|
2011-11-27 03:31:05 +01:00
|
|
|
void setSprite(v2s16 p, int num_frames, float framelength,
|
|
|
|
bool select_horiz_by_yawpitch);
|
2012-01-02 12:12:56 +01:00
|
|
|
std::string getName();
|
2017-01-09 20:39:45 +01:00
|
|
|
bool getCollisionBox(aabb3f *toset) const;
|
2016-07-23 21:11:20 +02:00
|
|
|
bool getSelectionBox(aabb3f *toset) const;
|
2017-01-09 20:39:45 +01:00
|
|
|
bool collideWithObjects() const;
|
2011-11-11 18:33:17 +01:00
|
|
|
private:
|
2012-03-29 16:46:21 +02:00
|
|
|
std::string getPropertyPacket();
|
2011-11-12 12:14:44 +01:00
|
|
|
void sendPosition(bool do_interpolate, bool is_movement_end);
|
2020-04-10 19:49:20 +02:00
|
|
|
std::string generateSetTextureModCommand() const;
|
|
|
|
static std::string generateSetSpriteCommand(v2s16 p, u16 num_frames, f32 framelength,
|
|
|
|
bool select_horiz_by_yawpitch);
|
2011-11-12 10:59:56 +01:00
|
|
|
|
2011-11-11 18:33:17 +01:00
|
|
|
std::string m_init_name;
|
|
|
|
std::string m_init_state;
|
2017-06-16 11:25:52 +02:00
|
|
|
bool m_registered = false;
|
2015-11-20 23:46:33 +01:00
|
|
|
|
2011-11-21 10:15:15 +01:00
|
|
|
v3f m_velocity;
|
|
|
|
v3f m_acceleration;
|
2016-10-30 14:53:26 +01:00
|
|
|
|
2011-11-12 10:59:56 +01:00
|
|
|
v3f m_last_sent_position;
|
2011-11-21 13:36:21 +01:00
|
|
|
v3f m_last_sent_velocity;
|
2018-11-28 09:38:50 +01:00
|
|
|
v3f m_last_sent_rotation;
|
2017-06-16 11:25:52 +02:00
|
|
|
float m_last_sent_position_timer = 0.0f;
|
|
|
|
float m_last_sent_move_precision = 0.0f;
|
|
|
|
std::string m_current_texture_modifier = "";
|
2011-11-11 18:33:17 +01:00
|
|
|
};
|
|
|
|
|