mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-29 22:55:19 +01:00
Add Lua methods 'set_rotation()' and 'get_rotation()' (#7395)
* Adds Lua methods 'set_rotation()' and 'get_rotation'. Also changed some method names to be more clear. Instead of an f32 being sent over network for yaw, now a v3f is sent for rotation on xyz axes. Perserved Lua method set_yaw/setyaw so that old mods still work, other wise to set yaw they would need to switch to set_rotation(0, yaw, 0).
This commit is contained in:
committed by
Loïc Blot
parent
9519d57017
commit
faa358e797
@@ -32,11 +32,12 @@ public:
|
||||
UnitSAO(ServerEnvironment *env, v3f pos);
|
||||
virtual ~UnitSAO() = default;
|
||||
|
||||
virtual void setYaw(const float yaw) { m_yaw = yaw; }
|
||||
float getYaw() const { return m_yaw; };
|
||||
f32 getRadYaw() const { return m_yaw * core::DEGTORAD; }
|
||||
void setRotation(v3f rotation) { m_rotation = rotation; }
|
||||
const v3f &getRotation() const { return m_rotation; }
|
||||
v3f getRadRotation() { return m_rotation * core::DEGTORAD; }
|
||||
|
||||
// Deprecated
|
||||
f32 getRadYawDep() const { return (m_yaw + 90.) * core::DEGTORAD; }
|
||||
f32 getRadYawDep() const { return (m_rotation.Y + 90.) * core::DEGTORAD; }
|
||||
|
||||
s16 getHP() const { return m_hp; }
|
||||
// Use a function, if isDead can be defined by other conditions
|
||||
@@ -64,7 +65,8 @@ public:
|
||||
void notifyObjectPropertiesModified();
|
||||
protected:
|
||||
s16 m_hp = -1;
|
||||
float m_yaw = 0.0f;
|
||||
|
||||
v3f m_rotation;
|
||||
|
||||
bool m_properties_sent = true;
|
||||
ObjectProperties m_prop;
|
||||
@@ -156,9 +158,9 @@ private:
|
||||
v3f m_velocity;
|
||||
v3f m_acceleration;
|
||||
|
||||
float m_last_sent_yaw = 0.0f;
|
||||
v3f m_last_sent_position;
|
||||
v3f m_last_sent_velocity;
|
||||
v3f m_last_sent_rotation;
|
||||
float m_last_sent_position_timer = 0.0f;
|
||||
float m_last_sent_move_precision = 0.0f;
|
||||
std::string m_current_texture_modifier = "";
|
||||
@@ -232,16 +234,16 @@ public:
|
||||
void setBasePosition(const v3f &position);
|
||||
void setPos(const v3f &pos);
|
||||
void moveTo(v3f pos, bool continuous);
|
||||
void setYaw(const float yaw);
|
||||
void setPlayerYaw(const float yaw);
|
||||
// Data should not be sent at player initialization
|
||||
void setYawAndSend(const float yaw);
|
||||
void setPitch(const float pitch);
|
||||
void setPlayerYawAndSend(const float yaw);
|
||||
void setLookPitch(const float pitch);
|
||||
// Data should not be sent at player initialization
|
||||
void setPitchAndSend(const float pitch);
|
||||
f32 getPitch() const { return m_pitch; }
|
||||
f32 getRadPitch() const { return m_pitch * core::DEGTORAD; }
|
||||
void setLookPitchAndSend(const float pitch);
|
||||
f32 getLookPitch() const { return m_pitch; }
|
||||
f32 getRadLookPitch() const { return m_pitch * core::DEGTORAD; }
|
||||
// Deprecated
|
||||
f32 getRadPitchDep() const { return -1.0 * m_pitch * core::DEGTORAD; }
|
||||
f32 getRadLookPitchDep() const { return -1.0 * m_pitch * core::DEGTORAD; }
|
||||
void setFov(const float pitch);
|
||||
f32 getFov() const { return m_fov; }
|
||||
void setWantedRange(const s16 range);
|
||||
|
||||
Reference in New Issue
Block a user