Speed up weapon draw

This commit is contained in:
Vladislav Khorev committed 2026-11-17 19:12:53 +06:00
1 parent 53328484b8
commit 4e40a1825a
3 files changed
+88 -2

No files matched your search

+77
View File
@@ -1,6 +1,7 @@
#include "LocationGameState.h"
#include "game_server/InternalGameServer.h"
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <filesystem>
#include <fstream>
@@ -338,6 +339,82 @@ int main()
return fail("Enabled player acquired an autonomous attack target");
}
FRG::CharacterState drawAnimation;
drawAnimation.configureAsPlayer();
drawAnimation.enabled = true;
drawAnimation.setAnimationMetadata(
FRG::AnimationState::STAND_TO_ACTION, 0, 100);
drawAnimation.setAnimationMetadata(
FRG::AnimationState::ACTION_IDLE, 0, 100);
FRG::CharacterObservation attackTarget{
point(0.f, 0.f, 1.f), 100.f};
drawAnimation.update(100, {{"player1", &attackTarget}, nullptr});
if (drawAnimation.currentState != FRG::AnimationState::STAND_TO_ACTION ||
std::abs(drawAnimation.animationFrame - 8.333333f) > 0.001f ||
drawAnimation.showWeapon) {
return fail("Weapon draw animation did not advance at 2x speed");
}
drawAnimation.update(200, {{"player1", &attackTarget}, nullptr});
if (!drawAnimation.showWeapon) {
return fail("Weapon draw animation did not use its frame visibility threshold");
}
FRG::CharacterState sheathAnimation;
sheathAnimation.configureAsPlayer();
sheathAnimation.enabled = true;
sheathAnimation.currentState = FRG::AnimationState::ACTION_IDLE;
sheathAnimation.setAnimationMetadata(
FRG::AnimationState::ACTION_TO_STAND, 0, 100);
sheathAnimation.update(100, {{"player1", nullptr}, nullptr});
if (sheathAnimation.currentState != FRG::AnimationState::ACTION_TO_STAND ||
std::abs(sheathAnimation.animationFrame - 8.333333f) > 0.001f ||
!sheathAnimation.showWeapon) {
return fail("Weapon sheath animation did not advance at 2x speed");
}
sheathAnimation.update(300, {{"player1", nullptr}, nullptr});
if (sheathAnimation.showWeapon) {
return fail("Weapon sheath animation did not hide at its frame visibility threshold");
}
FRG::CharacterState ordinaryAnimation;
ordinaryAnimation.configureAsPlayer();
ordinaryAnimation.enabled = true;
ordinaryAnimation.currentState = FRG::AnimationState::STAND;
ordinaryAnimation.setAnimationMetadata(
FRG::AnimationState::STAND, 0, 100);
ordinaryAnimation.update(100, {{"player1", nullptr}, nullptr});
if (std::abs(ordinaryAnimation.animationFrame - 4.1666665f) > 0.001f) {
return fail("Ordinary animation playback rate changed unexpectedly");
}
FRG::CharacterState completedDrawAnimation;
completedDrawAnimation.configureAsPlayer();
completedDrawAnimation.enabled = true;
completedDrawAnimation.setAnimationMetadata(
FRG::AnimationState::STAND_TO_ACTION, 0, 30);
completedDrawAnimation.setAnimationMetadata(
FRG::AnimationState::ACTION_IDLE, 0, 30);
for (int i = 0; i < 4; ++i)
completedDrawAnimation.update(
100, {{"player1", &attackTarget}, nullptr});
if (completedDrawAnimation.currentState !=
FRG::AnimationState::ACTION_IDLE) {
return fail("Accelerated weapon draw animation did not complete");
}
FRG::CharacterState completedSheathAnimation;
completedSheathAnimation.configureAsPlayer();
completedSheathAnimation.enabled = true;
completedSheathAnimation.currentState = FRG::AnimationState::ACTION_IDLE;
completedSheathAnimation.setAnimationMetadata(
FRG::AnimationState::ACTION_TO_STAND, 0, 30);
for (int i = 0; i < 4; ++i)
completedSheathAnimation.update(
100, {{"player1", nullptr}, nullptr});
if (completedSheathAnimation.currentState != FRG::AnimationState::STAND) {
return fail("Accelerated weapon sheath animation did not complete");
}
FRG::CharacterState guardedMover;
nlohmann::json guardedJson;
guardedMover.velocity = {