1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-12 16:58:39 +00:00

LuaEntity armor groups

This commit is contained in:
Perttu Ahola 2012-03-09 20:46:56 +02:00
parent 8c01ad8a9d
commit 8db89b8136
7 changed files with 67 additions and 6 deletions

View file

@ -354,7 +354,8 @@ LuaEntitySAO::LuaEntitySAO(ServerEnvironment *env, v3f pos,
m_last_sent_position(0,0,0),
m_last_sent_velocity(0,0,0),
m_last_sent_position_timer(0),
m_last_sent_move_precision(0)
m_last_sent_move_precision(0),
m_armor_groups_sent(false)
{
// Only register type if no environment supplied
if(env == NULL){
@ -475,6 +476,21 @@ void LuaEntitySAO::step(float dtime, bool send_recommended)
fabs(m_yaw - m_last_sent_yaw) > 1.0){
sendPosition(true, false);
}
if(m_armor_groups_sent == false){
m_armor_groups_sent = true;
std::ostringstream os(std::ios::binary);
writeU8(os, LUAENTITY_CMD_UPDATE_ARMOR_GROUPS);
writeU16(os, m_armor_groups.size());
for(ItemGroupList::const_iterator i = m_armor_groups.begin();
i != m_armor_groups.end(); i++){
os<<serializeString(i->first);
writeS16(os, i->second);
}
// create message and add to list
ActiveObjectMessage aom(getId(), true, os.str());
m_messages_out.push_back(aom);
}
}
std::string LuaEntitySAO::getClientInitializationData()
@ -685,6 +701,12 @@ std::string LuaEntitySAO::getName()
return m_init_name;
}
void LuaEntitySAO::setArmorGroups(const ItemGroupList &armor_groups)
{
m_armor_groups = armor_groups;
m_armor_groups_sent = false;
}
void LuaEntitySAO::sendPosition(bool do_interpolate, bool is_movement_end)
{
m_last_sent_move_precision = m_base_position.getDistanceFrom(