Code works more or less good
This commit is contained in:
1 parent
3495d28edf
commit
348aa632dd
17 files changed
+4180
-56
No files matched your search
@@ -354,6 +354,12 @@ namespace ZL {
|
||||
data.interactionRadius = item.value("interactionRadius", 0.0f);
|
||||
data.animationIdlePath = item.value("animationIdlePath", "");
|
||||
data.animationWalkPath = item.value("animationWalkPath", "");
|
||||
data.animationActionIdlePath = item.value("animationActionIdlePath", "");
|
||||
data.animationActionAttackPath = item.value("animationActionAttackPath", "");
|
||||
data.animationStandToActionPath = item.value("animationStandToActionPath", "");
|
||||
data.animationActionToStandPath = item.value("animationActionToStandPath", "");
|
||||
data.animationActionToDeathPath = item.value("animationActionToDeathPath", "");
|
||||
data.animationDeathIdlePath = item.value("animationDeathIdlePath", "");
|
||||
|
||||
data.positionX = item.value("positionX", 0.0f);
|
||||
data.positionY = item.value("positionY", 0.0f);
|
||||
@@ -370,6 +376,9 @@ namespace ZL {
|
||||
|
||||
data.facingAngle = item.value("facingAngle", 0.0f);
|
||||
|
||||
data.hp = item.value("hp", 100.0f);
|
||||
data.canAttack = item.value("canAttack", false);
|
||||
|
||||
// Load gift data if available
|
||||
if (item.contains("gift") && item["gift"].is_object()) {
|
||||
const auto& giftData = item["gift"];
|
||||
@@ -429,7 +438,7 @@ namespace ZL {
|
||||
{
|
||||
npc->loadAnimation(AnimationState::WALK, npcData.animationWalkPath, zipPath);
|
||||
}
|
||||
|
||||
|
||||
std::cout << " Loaded WALK animation: " << npcData.animationWalkPath << std::endl;
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
@@ -437,6 +446,30 @@ namespace ZL {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Optional combat/death slots — empty path means "skip this slot".
|
||||
auto loadOptionalAnim = [&](AnimationState state, const std::string& path, const char* label) {
|
||||
if (path.empty()) return;
|
||||
try {
|
||||
if (path.size() >= 5 && path.substr(path.size() - 5) == ".anim") {
|
||||
npc->loadBinaryAnimation(state, path, zipPath);
|
||||
}
|
||||
else {
|
||||
npc->loadAnimation(state, path, zipPath);
|
||||
}
|
||||
std::cout << " Loaded " << label << " animation: " << path << std::endl;
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "GameObjectLoader: Failed to load " << label
|
||||
<< " animation for '" << npcData.name << "': " << e.what() << std::endl;
|
||||
}
|
||||
};
|
||||
loadOptionalAnim(AnimationState::ACTION_IDLE, npcData.animationActionIdlePath, "ACTION_IDLE");
|
||||
loadOptionalAnim(AnimationState::ACTION_ATTACK, npcData.animationActionAttackPath, "ACTION_ATTACK");
|
||||
loadOptionalAnim(AnimationState::STAND_TO_ACTION, npcData.animationStandToActionPath, "STAND_TO_ACTION");
|
||||
loadOptionalAnim(AnimationState::ACTION_TO_STAND, npcData.animationActionToStandPath, "ACTION_TO_STAND");
|
||||
loadOptionalAnim(AnimationState::ACTION_TO_DEATH, npcData.animationActionToDeathPath, "ACTION_TO_DEATH");
|
||||
loadOptionalAnim(AnimationState::DEATH_IDLE, npcData.animationDeathIdlePath, "DEATH_IDLE");
|
||||
|
||||
// Load textures: per-mesh map takes precedence; fall back to single texturePath.
|
||||
try {
|
||||
if (!npcData.meshTextures.empty()) {
|
||||
@@ -474,6 +507,8 @@ namespace ZL {
|
||||
npc->modelScale = npcData.modelScale;
|
||||
npc->position = Eigen::Vector3f(npcData.positionX, npcData.positionY, npcData.positionZ);
|
||||
npc->facingAngle = npcData.facingAngle;
|
||||
npc->hp = npcData.hp;
|
||||
npc->canAttack = npcData.canAttack;
|
||||
npc->interactionRadius = npcData.interactionRadius;
|
||||
|
||||
// Set NPC metadata
|
||||
|
||||
@@ -51,6 +51,13 @@ namespace ZL {
|
||||
std::map<std::string, std::string> meshTextures;
|
||||
std::string animationIdlePath;
|
||||
std::string animationWalkPath;
|
||||
// Optional combat / death animations. Empty path = slot not loaded.
|
||||
std::string animationActionIdlePath;
|
||||
std::string animationActionAttackPath;
|
||||
std::string animationStandToActionPath;
|
||||
std::string animationActionToStandPath;
|
||||
std::string animationActionToDeathPath;
|
||||
std::string animationDeathIdlePath;
|
||||
float positionX = 0.0f;
|
||||
float positionY = 0.0f;
|
||||
float positionZ = 0.0f;
|
||||
@@ -61,6 +68,8 @@ namespace ZL {
|
||||
float modelCorrectionRotY = 0.0f;
|
||||
float modelCorrectionRotZ = 0.0f;
|
||||
float facingAngle = 0.0f;
|
||||
float hp = 100.0f;
|
||||
bool canAttack = false;
|
||||
GiftData gift;
|
||||
float interactionRadius = 0.0f;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user