Much better narration/dialogue/action handling (and for lua too)

This commit is contained in:
2026-01-23 02:42:29 +03:00
parent cd91174f5d
commit 1d358d206e
7 changed files with 220 additions and 28 deletions

View File

@@ -12,21 +12,11 @@
namespace ECS
{
struct TownNPCs {
struct NPCData {
flecs::entity e;
nlohmann::json props;
Ogre::Vector3 position;
Ogre::Quaternion orientation;
Ogre::String model;
};
std::map<int, NPCData> npcs;
};
struct LivesIn {};
void createNPCActionNodes(flecs::entity town, flecs::entity e, int index)
{
NPCActionNodes &anodes = e.get_mut<NPCActionNodes>();
const TownNPCs &npcs = town.get<TownNPCs>();
nlohmann::json npcprops = npcs.npcs.at(index).props;
const CharacterBase &ch = e.get<CharacterBase>();
Ogre::Vector3 characterPos = ch.mBodyNode->_getDerivedPosition();
Ogre::Quaternion characterRot = ch.mBodyNode->_getDerivedOrientation();
@@ -66,6 +56,7 @@ void createNPCActionNodes(flecs::entity town, flecs::entity e, int index)
anode.props["height"] = anode.height;
anode.props["town"] = town.id();
anode.props["index"] = index;
anode.props["npc"] = npcprops;
anodes.anodes.push_back(anode);
}
{
@@ -86,6 +77,7 @@ void createNPCActionNodes(flecs::entity town, flecs::entity e, int index)
anode.props["height"] = anode.height;
anode.props["town"] = town.id();
anode.props["index"] = index;
anode.props["npc"] = npcprops;
anodes.anodes.push_back(anode);
}
e.modified<NPCActionNodes>();