nlist: make selected list accessible globally
[waspsaliva.git] / src / server / luaentity_sao.h
blobe060aa06d7143fba036a988834c7f106b8729d4a
1 /*
2 Minetest
3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2013-2020 Minetest core developers & community
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #pragma once
23 #include "unit_sao.h"
25 class LuaEntitySAO : public UnitSAO
27 public:
28 LuaEntitySAO() = delete;
29 // Used by the environment to load SAO
30 LuaEntitySAO(ServerEnvironment *env, v3f pos, const std::string &data);
31 // Used by the Lua API
32 LuaEntitySAO(ServerEnvironment *env, v3f pos, const std::string &name,
33 const std::string &state) :
34 UnitSAO(env, pos),
35 m_init_name(name), m_init_state(state)
38 ~LuaEntitySAO();
39 ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_LUAENTITY; }
40 ActiveObjectType getSendType() const { return ACTIVEOBJECT_TYPE_GENERIC; }
41 virtual void addedToEnvironment(u32 dtime_s);
42 void step(float dtime, bool send_recommended);
43 std::string getClientInitializationData(u16 protocol_version);
44 bool isStaticAllowed() const { return m_prop.static_save; }
45 bool shouldUnload() const { return true; }
46 void getStaticData(std::string *result) const;
47 u16 punch(v3f dir, const ToolCapabilities *toolcap = nullptr,
48 ServerActiveObject *puncher = nullptr,
49 float time_from_last_punch = 1000000.0f);
50 void rightClick(ServerActiveObject *clicker);
51 void setPos(const v3f &pos);
52 void moveTo(v3f pos, bool continuous);
53 float getMinimumSavedMovement();
54 std::string getDescription();
55 void setHP(s32 hp, const PlayerHPChangeReason &reason);
56 u16 getHP() const;
58 /* LuaEntitySAO-specific */
59 void setVelocity(v3f velocity);
60 void addVelocity(v3f velocity) { m_velocity += velocity; }
61 v3f getVelocity();
62 void setAcceleration(v3f acceleration);
63 v3f getAcceleration();
65 void setTextureMod(const std::string &mod);
66 std::string getTextureMod() const;
67 void setSprite(v2s16 p, int num_frames, float framelength,
68 bool select_horiz_by_yawpitch);
69 std::string getName();
70 bool getCollisionBox(aabb3f *toset) const;
71 bool getSelectionBox(aabb3f *toset) const;
72 bool collideWithObjects() const;
74 private:
75 std::string getPropertyPacket();
76 void sendPosition(bool do_interpolate, bool is_movement_end);
77 std::string generateSetTextureModCommand() const;
78 static std::string generateSetSpriteCommand(v2s16 p, u16 num_frames,
79 f32 framelength, bool select_horiz_by_yawpitch);
81 std::string m_init_name;
82 std::string m_init_state;
83 bool m_registered = false;
85 v3f m_velocity;
86 v3f m_acceleration;
88 v3f m_last_sent_position;
89 v3f m_last_sent_velocity;
90 v3f m_last_sent_rotation;
91 float m_last_sent_position_timer = 0.0f;
92 float m_last_sent_move_precision = 0.0f;
93 std::string m_current_texture_modifier = "";