Adapt for web, make CharacterState class
This commit is contained in:
1 parent
c891161d69
commit
0eb9d0be25
88 files changed
+810
-102277
No files matched your search
+24
-24
@@ -63,7 +63,7 @@ namespace ZL {
|
||||
}
|
||||
};
|
||||
}
|
||||
npcs[index]->homePosition = Eigen::Vector3f(x, 0.f, z);
|
||||
npcs[index]->state.homePosition = Eigen::Vector3f(x, 0.f, z);
|
||||
npcs[index]->setTarget(Eigen::Vector3f(x, y, z), std::move(cb));
|
||||
});
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace ZL {
|
||||
|
||||
const float rad = angle * static_cast<float>(M_PI) / 180.f;
|
||||
std::cout << "[script] npc_rotate_to: index " << index << " angle " << angle << " degrees (" << rad << " radians)" << std::endl;
|
||||
npcs[index]->targetFacingAngle = rad;
|
||||
npcs[index]->state.targetFacingAngle = rad;
|
||||
});
|
||||
|
||||
api.set_function("player_walk_to",
|
||||
@@ -96,7 +96,7 @@ namespace ZL {
|
||||
}
|
||||
};
|
||||
}
|
||||
loc->player->homePosition = Eigen::Vector3f(x, 0.f, z);
|
||||
loc->player->state.homePosition = Eigen::Vector3f(x, 0.f, z);
|
||||
loc->player->setTarget(Eigen::Vector3f(x, y, z), std::move(cb));
|
||||
});
|
||||
|
||||
@@ -327,11 +327,11 @@ namespace ZL {
|
||||
|
||||
api.set_function("get_player_x",
|
||||
[loc]() -> float {
|
||||
return loc->player ? loc->player->position.x() : 0.0f;
|
||||
return loc->player ? loc->player->state.position.x() : 0.0f;
|
||||
});
|
||||
api.set_function("get_player_z",
|
||||
[loc]() -> float {
|
||||
return loc->player ? loc->player->position.z() : 0.0f;
|
||||
return loc->player ? loc->player->state.position.z() : 0.0f;
|
||||
});
|
||||
|
||||
// set_player_hp(value) — sets the player's current HP directly.
|
||||
@@ -339,11 +339,11 @@ namespace ZL {
|
||||
[loc](float value) {
|
||||
if (loc->player)
|
||||
{
|
||||
loc->player->setHp(value);
|
||||
if (loc->player->currentState == AnimationState::ACTION_TO_DEATH || loc->player->currentState == AnimationState::DEATH_IDLE)
|
||||
loc->player->state.setHp(value);
|
||||
if (loc->player->state.currentState == AnimationState::ACTION_TO_DEATH || loc->player->state.currentState == AnimationState::DEATH_IDLE)
|
||||
{
|
||||
loc->player->currentState = AnimationState::STAND;
|
||||
loc->player->resetAnim = true;
|
||||
loc->player->state.currentState = AnimationState::STAND;
|
||||
loc->player->state.resetAnim = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -480,8 +480,8 @@ namespace ZL {
|
||||
return;
|
||||
}
|
||||
Eigen::Vector3f pos(x, y, z);
|
||||
npcs[index]->position = pos;
|
||||
npcs[index]->homePosition = pos;
|
||||
npcs[index]->state.position = pos;
|
||||
npcs[index]->state.homePosition = pos;
|
||||
npcs[index]->setTarget(pos);
|
||||
});
|
||||
|
||||
@@ -494,8 +494,8 @@ namespace ZL {
|
||||
return;
|
||||
}
|
||||
const float rad = angle * static_cast<float>(M_PI) / 180.f;
|
||||
npcs[index]->facingAngle = rad;
|
||||
npcs[index]->targetFacingAngle = rad;
|
||||
npcs[index]->state.facingAngle = rad;
|
||||
npcs[index]->state.targetFacingAngle = rad;
|
||||
});
|
||||
|
||||
// set_npc_enabled(index, enabled)
|
||||
@@ -506,30 +506,30 @@ namespace ZL {
|
||||
std::cerr << "[script] set_npc_enabled: index " << index << " out of range\n";
|
||||
return;
|
||||
}
|
||||
npcs[index]->enabled = value;
|
||||
npcs[index]->attack = 0;
|
||||
npcs[index]->attack_cooldown = 0;
|
||||
npcs[index]->currentState = AnimationState::STAND;
|
||||
if (npcs[index]->canAttack)
|
||||
npcs[index]->state.enabled = value;
|
||||
npcs[index]->state.attack = 0;
|
||||
npcs[index]->state.attack_cooldown = 0;
|
||||
npcs[index]->state.currentState = AnimationState::STAND;
|
||||
if (npcs[index]->state.canAttack)
|
||||
{
|
||||
npcs[index]->attackTarget = loc->player.get();
|
||||
npcs[index]->state.attackTargetIndex = CharacterState::kPlayerIndex;
|
||||
}
|
||||
npcs[index]->battle_state = 0;
|
||||
npcs[index]->state.battle_state = 0;
|
||||
});
|
||||
|
||||
api.set_function("player_set_position",
|
||||
[loc](float x, float y, float z) {
|
||||
Eigen::Vector3f pos(x, y, z);
|
||||
loc->player->position = pos;
|
||||
loc->player->homePosition = pos;
|
||||
loc->player->state.position = pos;
|
||||
loc->player->state.homePosition = pos;
|
||||
loc->player->setTarget(pos);
|
||||
});
|
||||
|
||||
api.set_function("player_set_rotation",
|
||||
[loc](float angle) {
|
||||
const float rad = angle * static_cast<float>(M_PI) / 180.f;
|
||||
loc->player->facingAngle = rad;
|
||||
loc->player->targetFacingAngle = rad;
|
||||
loc->player->state.facingAngle = rad;
|
||||
loc->player->state.targetFacingAngle = rad;
|
||||
});
|
||||
|
||||
// move_object(name, x, y, z, duration_sec [, on_complete])
|
||||
|
||||
Reference in new issue
Block a user