Browse Source

Add support for entities to automatic face movement direction

nephele-craftmethods
sapier 9 years ago committed by PilzAdam
parent
commit
fc571ad46d
  1. 1
      doc/lua_api.txt
  2. 1
      src/clientserver.h
  3. 5
      src/content_cao.cpp
  4. 5
      src/content_sao.cpp
  5. 5
      src/object_properties.cpp
  6. 1
      src/object_properties.h
  7. 1
      src/script/common/c_content.cpp

1
doc/lua_api.txt

@ -1863,6 +1863,7 @@ Object Properties @@ -1863,6 +1863,7 @@ Object Properties
makes_footstep_sound = false,
automatic_rotate = false,
stepheight = 0,
automatic_face_movement_dir = false,
}
Entity definition (register_entity)

1
src/clientserver.h

@ -102,6 +102,7 @@ SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time, float time_speed); @@ -102,6 +102,7 @@ SharedBuffer<u8> makePacket_TOCLIENT_TIME_OF_DAY(u16 time, float time_speed);
drowning, leveled and liquid_range added to ContentFeatures
stepheight and collideWithObjects added to object properties
version, heat and humidity transfer in MapBock
added new property to entities automatic_face_movement_dir
*/
#define LATEST_PROTOCOL_VERSION 21

5
src/content_cao.cpp

@ -1210,6 +1210,11 @@ public: @@ -1210,6 +1210,11 @@ public:
m_yaw += dtime * m_prop.automatic_rotate * 180 / M_PI;
updateNodePos();
}
if (getParent() == NULL && m_prop.automatic_face_movement_dir){
m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI;
updateNodePos();
}
}
void updateTexturePos()

5
src/content_sao.cpp

@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc., @@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "cpp_api/scriptapi.h"
#include "genericobject.h"
#include "util/serialize.h"
#include "util/mathconstants.h"
std::map<u16, ServerActiveObject::Factory> ServerActiveObject::m_types;
@ -522,6 +523,10 @@ void LuaEntitySAO::step(float dtime, bool send_recommended) @@ -522,6 +523,10 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
* dtime * m_acceleration;
m_velocity += dtime * m_acceleration;
}
if(m_prop.automatic_face_movement_dir){
m_yaw = atan2(m_velocity.Z,m_velocity.X) * 180 / M_PI;
}
}
if(m_registered){

5
src/object_properties.cpp

@ -40,7 +40,8 @@ ObjectProperties::ObjectProperties(): @@ -40,7 +40,8 @@ ObjectProperties::ObjectProperties():
is_visible(true),
makes_footstep_sound(false),
automatic_rotate(0),
stepheight(0)
stepheight(0),
automatic_face_movement_dir(false)
{
textures.push_back("unknown_object.png");
colors.push_back(video::SColor(255,255,255,255));
@ -102,6 +103,7 @@ void ObjectProperties::serialize(std::ostream &os) const @@ -102,6 +103,7 @@ void ObjectProperties::serialize(std::ostream &os) const
}
writeU8(os, collideWithObjects);
writeF1000(os,stepheight);
writeU8(os, automatic_face_movement_dir);
// Add stuff only at the bottom.
// Never remove anything, because we don't want new versions of this
}
@ -136,6 +138,7 @@ void ObjectProperties::deSerialize(std::istream &is) @@ -136,6 +138,7 @@ void ObjectProperties::deSerialize(std::istream &is)
}
collideWithObjects = readU8(is);
stepheight = readF1000(is);
automatic_face_movement_dir = readU8(is);
}catch(SerializationError &e){}
}
else

1
src/object_properties.h

@ -45,6 +45,7 @@ struct ObjectProperties @@ -45,6 +45,7 @@ struct ObjectProperties
bool makes_footstep_sound;
float automatic_rotate;
f32 stepheight;
bool automatic_face_movement_dir;
ObjectProperties();

1
src/script/common/c_content.cpp

@ -190,6 +190,7 @@ void read_object_properties(lua_State *L, int index, @@ -190,6 +190,7 @@ void read_object_properties(lua_State *L, int index,
getfloatfield(L, -1, "automatic_rotate", prop->automatic_rotate);
getfloatfield(L, -1, "stepheight", prop->stepheight);
prop->stepheight*=BS;
getboolfield(L, -1, "automatic_face_movement_dir", prop->automatic_face_movement_dir);
}
/******************************************************************************/

Loading…
Cancel
Save