mirror of
https://github.com/moparisthebest/minetest
synced 2024-12-22 07:38:48 -05:00
Detach the player from entities on death. (#5077)
This commit is contained in:
parent
0eede97af2
commit
72535d3328
@ -203,6 +203,16 @@ void UnitSAO::getAttachment(int *parent_id, std::string *bone, v3f *position,
|
|||||||
*rotation = m_attachment_rotation;
|
*rotation = m_attachment_rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnitSAO::detachFromParent()
|
||||||
|
{
|
||||||
|
ServerActiveObject *parent = NULL;
|
||||||
|
if (m_attachment_parent_id)
|
||||||
|
parent = m_env->getActiveObject(m_attachment_parent_id);
|
||||||
|
setAttachment(NULL, "", v3f(0, 0, 0), v3f(0, 0, 0));
|
||||||
|
if (parent != NULL)
|
||||||
|
parent->removeAttachmentChild(m_id);
|
||||||
|
}
|
||||||
|
|
||||||
void UnitSAO::addAttachmentChild(int child_id)
|
void UnitSAO::addAttachmentChild(int child_id)
|
||||||
{
|
{
|
||||||
m_attachment_child_ids.insert(child_id);
|
m_attachment_child_ids.insert(child_id);
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
void setBonePosition(const std::string &bone, v3f position, v3f rotation);
|
void setBonePosition(const std::string &bone, v3f position, v3f rotation);
|
||||||
void getBonePosition(const std::string &bone, v3f *position, v3f *rotation);
|
void getBonePosition(const std::string &bone, v3f *position, v3f *rotation);
|
||||||
void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation);
|
void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation);
|
||||||
|
void detachFromParent();
|
||||||
void getAttachment(int *parent_id, std::string *bone, v3f *position, v3f *rotation);
|
void getAttachment(int *parent_id, std::string *bone, v3f *position, v3f *rotation);
|
||||||
void addAttachmentChild(int child_id);
|
void addAttachmentChild(int child_id);
|
||||||
void removeAttachmentChild(int child_id);
|
void removeAttachmentChild(int child_id);
|
||||||
|
@ -710,20 +710,7 @@ int ObjectRef::l_set_detach(lua_State *L)
|
|||||||
ServerActiveObject *co = getobject(ref);
|
ServerActiveObject *co = getobject(ref);
|
||||||
if (co == NULL)
|
if (co == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
co->detachFromParent();
|
||||||
int parent_id = 0;
|
|
||||||
std::string bone = "";
|
|
||||||
v3f position;
|
|
||||||
v3f rotation;
|
|
||||||
co->getAttachment(&parent_id, &bone, &position, &rotation);
|
|
||||||
ServerActiveObject *parent = NULL;
|
|
||||||
if (parent_id)
|
|
||||||
parent = env->getActiveObject(parent_id);
|
|
||||||
|
|
||||||
// Do it
|
|
||||||
co->setAttachment(0, "", v3f(0,0,0), v3f(0,0,0));
|
|
||||||
if (parent != NULL)
|
|
||||||
parent->removeAttachmentChild(co->getId());
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2560,6 +2560,8 @@ void Server::DiePlayer(u16 peer_id)
|
|||||||
if (!playersao)
|
if (!playersao)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
playersao->detachFromParent();
|
||||||
|
|
||||||
infostream << "Server::DiePlayer(): Player "
|
infostream << "Server::DiePlayer(): Player "
|
||||||
<< playersao->getPlayer()->getName()
|
<< playersao->getPlayer()->getName()
|
||||||
<< " dies" << std::endl;
|
<< " dies" << std::endl;
|
||||||
|
@ -166,6 +166,8 @@ public:
|
|||||||
{}
|
{}
|
||||||
virtual void removeAttachmentChild(int child_id)
|
virtual void removeAttachmentChild(int child_id)
|
||||||
{}
|
{}
|
||||||
|
virtual void detachFromParent()
|
||||||
|
{}
|
||||||
virtual const UNORDERED_SET<int> &getAttachmentChildIds()
|
virtual const UNORDERED_SET<int> &getAttachmentChildIds()
|
||||||
{ static const UNORDERED_SET<int> rv; return rv; }
|
{ static const UNORDERED_SET<int> rv; return rv; }
|
||||||
virtual ObjectProperties* accessObjectProperties()
|
virtual ObjectProperties* accessObjectProperties()
|
||||||
|
Loading…
Reference in New Issue
Block a user