diff --git a/assets/blender/scripts/settings.py b/assets/blender/scripts/settings.py index 1b76d3c..cf53b7a 100644 --- a/assets/blender/scripts/settings.py +++ b/assets/blender/scripts/settings.py @@ -54,7 +54,7 @@ class ExportMappingMale: self.files.append({"name": fobj}) class ExportMappingMaleEdited: - blend_path = "assets/blender/" + "edited-normal-male.blend" + blend_path = "assets/blender/characters/" + "edited-normal-male.blend" gltf_path = "characters/male/normal-male.gltf" ogre_scene = "characters/male/vroid-normal-male.scene" inner_path = "Object" @@ -68,7 +68,7 @@ class ExportMappingMaleEdited: self.files.append({"name": fobj}) class ExportMappingMaleClothedEdited: - blend_path = "assets/blender/" + "edited-normal-male.blend" + blend_path = "assets/blender/characters/" + "edited-normal-male.blend" gltf_path = "characters/male/normal-male.gltf" ogre_scene = "characters/male/vroid-normal-male.scene" inner_path = "Object" @@ -82,7 +82,7 @@ class ExportMappingMaleClothedEdited: self.files.append({"name": fobj}) class ExportMappingFemaleEdited: - blend_path = "assets/blender/" + "edited-normal-female.blend" + blend_path = "assets/blender/characters/" + "edited-normal-female.blend" gltf_path = "characters/female/normal-female.gltf" ogre_scene = "characters/female/vroid-normal-female.scene" inner_path = "Object" diff --git a/src/gamedata/CharacterAIModule.cpp b/src/gamedata/CharacterAIModule.cpp index f882edf..2b27c27 100644 --- a/src/gamedata/CharacterAIModule.cpp +++ b/src/gamedata/CharacterAIModule.cpp @@ -328,6 +328,15 @@ public: if (action == "sit") { jactionPrereq["is_seated"] = 0; jactionEffect["is_seated"] = 1; + } else if (action == "use") { + if (props["tags"].find("toilet") != + props["tags"].end()) { + std::cout << "toilet" << std::endl; + OgreAssert(false, "props: " + props.dump(4)); + } else + OgreAssert(false, "props: " + props.dump(4)); + } else { + OgreAssert(false, "props: " + props.dump(4)); } Blackboard actionPrereq({ jactionPrereq }); Blackboard actionEffect({ jactionEffect }); diff --git a/src/gamedata/CharacterModule.cpp b/src/gamedata/CharacterModule.cpp index 9fb4b56..2f16070 100644 --- a/src/gamedata/CharacterModule.cpp +++ b/src/gamedata/CharacterModule.cpp @@ -17,7 +17,14 @@ CharacterModule::CharacterModule(flecs::world &ecs) ecs.module(); ecs.component(); ecs.component(); - ecs.component(); + ecs.component().on_remove([this](flecs::entity e, + CharacterBase &ch) { + if (characterEntities.find(e) != characterEntities.end() || + characterNodes.find(e) != characterNodes.end()) { + characterEntities.erase(e); + characterNodes.erase(e); + } + }); ecs.component(); ecs.component(); ecs.component(); @@ -211,9 +218,21 @@ CharacterModule::CharacterModule(flecs::world &ecs) .each([&](flecs::entity e, const EngineData &eng, const CharacterLocation &loc, const CharacterConf &conf, CharacterBase &ch) { - ch.mBodyEnt = eng.mScnMgr->createEntity(conf.type); - ch.mBodyNode = eng.mScnMgr->getRootSceneNode() - ->createChildSceneNode(); + CharacterModule &module = + ECS::get().get_mut(); + if (module.characterNodes.find(e) == + module.characterNodes.end()) { + Ogre::SceneNode *bodyNode = + eng.mScnMgr->getRootSceneNode() + ->createChildSceneNode(); + Ogre::Entity *bodyEnt = + eng.mScnMgr->createEntity(conf.type); + module.characterNodes[e] = bodyNode; + module.characterEntities[e] = bodyEnt; + ECS::modified(); + } + ch.mBodyEnt = module.characterEntities[e]; + ch.mBodyNode = module.characterNodes[e]; ch.mBodyNode->setOrientation(loc.orientation); ch.mBodyNode->setPosition(loc.position); ch.mBodyNode->attachObject(ch.mBodyEnt); @@ -613,6 +632,8 @@ void CharacterModule::createCharacter(flecs::entity e, { if (e.has() || e.has()) return; + if (characterNodes.find(e) != characterNodes.end()) + return; e.set({ rotation, position }); e.set({ model }); e.add(); diff --git a/src/gamedata/CharacterModule.h b/src/gamedata/CharacterModule.h index ca9b0aa..8f23efe 100644 --- a/src/gamedata/CharacterModule.h +++ b/src/gamedata/CharacterModule.h @@ -19,12 +19,12 @@ struct Female {}; struct CharacterBase { Ogre::String type; float mTimer; - Ogre::SceneNode *mBodyNode; - Ogre::Entity *mBodyEnt; Ogre::Vector3 mBoneMotion; Ogre::Vector3 mBonePrevMotion; Ogre::Vector3 mGoalDirection; // actual intended direction in world-space - bool is_submerged; + Ogre::SceneNode *mBodyNode; + Ogre::Entity *mBodyEnt; + bool is_submerged; }; struct CharacterLocation { Ogre::Quaternion orientation; @@ -45,6 +45,8 @@ struct CharacterModule { void createCharacter(flecs::entity e, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::String model); + std::unordered_map characterNodes; + std::unordered_map characterEntities; }; } #endif