diff --git a/include/ientity.h b/include/ientity.h index a37e55159c..1199affde7 100644 --- a/include/ientity.h +++ b/include/ientity.h @@ -245,6 +245,9 @@ class Entity /// Vector offset where the attached entity should appear Vector3 offset; + + /// Optional model joint to use as origin + std::string joint; }; /// A functor which can receive Attachment objects diff --git a/radiantcore/entity/AttachmentData.h b/radiantcore/entity/AttachmentData.h index c737402a98..39e79166e0 100644 --- a/radiantcore/entity/AttachmentData.h +++ b/radiantcore/entity/AttachmentData.h @@ -107,9 +107,16 @@ class AttachmentData { for (auto i = _objects.begin(); i != _objects.end(); ++i) { + // Locate attachment position + const AttachPos& pos = _positions.at(i->second.posName); + + // Construct the functor argument Entity::Attachment a; a.eclass = i->second.className; - a.offset = _positions.at(i->second.posName).origin; + a.offset = pos.origin; + a.joint = pos.joint; + + // Invoke the functor func(a); } } diff --git a/test/Entity.cpp b/test/Entity.cpp index 264b0a5ebc..0eceabd51f 100644 --- a/test/Entity.cpp +++ b/test/Entity.cpp @@ -680,6 +680,9 @@ TEST_F(EntityTest, CreateAIEntity) // Guard should have a hammer attachment auto attachments = getAttachments(guard); EXPECT_EQ(attachments.size(), 1); + EXPECT_EQ(attachments.front().eclass, "atdm:moveable_warhammer"); + EXPECT_EQ(attachments.front().offset, Vector3(14, -6, -6)); + EXPECT_EQ(attachments.front().joint, "Spine2"); } } \ No newline at end of file