mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 13:37:22 +00:00
better tests for advancing waypoint
This commit is contained in:
parent
e31b6ca54b
commit
e6fe2edfae
@ -38,7 +38,7 @@ PlatformSubComponent::PlatformSubComponent(MovingPlatformComponent* parentCompon
|
||||
void PlatformSubComponent::AdvanceToNextWaypoint() {
|
||||
uint32_t numWaypoints = m_Path->pathWaypoints.size();
|
||||
m_CurrentWaypointIndex = m_NextWaypointIndex;
|
||||
uint32_t nextWaypointIndex = m_CurrentWaypointIndex;
|
||||
uint32_t nextWaypointIndex = m_CurrentWaypointIndex + 1;
|
||||
if (numWaypoints <= nextWaypointIndex) {
|
||||
PathBehavior behavior = m_Path->pathBehavior;
|
||||
if (behavior == PathBehavior::Once) {
|
||||
@ -56,7 +56,7 @@ void PlatformSubComponent::AdvanceToNextWaypoint() {
|
||||
void PlatformSubComponent::AdvanceToNextReverseWaypoint() {
|
||||
uint32_t numWaypoints = m_Path->pathWaypoints.size();
|
||||
m_CurrentWaypointIndex = m_NextWaypointIndex;
|
||||
int32_t nextWaypointIndex = m_CurrentWaypointIndex;
|
||||
int32_t nextWaypointIndex = m_CurrentWaypointIndex - 1;
|
||||
if (nextWaypointIndex < 0) {
|
||||
PathBehavior behavior = m_Path->pathBehavior;
|
||||
if (behavior == PathBehavior::Once) {
|
||||
|
@ -25,11 +25,16 @@ protected:
|
||||
waypointStart.position = NiPoint3(1, 2, 3);
|
||||
waypointStart.rotation = NiQuaternion(4, 5, 6, 7);
|
||||
|
||||
PathWaypoint waypointMiddle;
|
||||
waypointMiddle.position = NiPoint3(4, 5, 6);
|
||||
waypointMiddle.rotation = NiQuaternion(7, 8, 9, 10);
|
||||
|
||||
PathWaypoint waypointEnd;
|
||||
waypointEnd.position = NiPoint3(4, 5, 6);
|
||||
waypointEnd.rotation = NiQuaternion(7, 8, 9, 10);
|
||||
|
||||
path.pathWaypoints.push_back(waypointStart);
|
||||
path.pathWaypoints.push_back(waypointMiddle);
|
||||
path.pathWaypoints.push_back(waypointEnd);
|
||||
|
||||
baseEntity = std::make_unique<Entity>(15, GameDependenciesTest::info);
|
||||
@ -304,15 +309,14 @@ TEST_F(MovingPlatformComponentTests, MovingPlatformSubComponentPathAdvanceForwar
|
||||
moverPlatformSubComponent.m_InReverse = false;
|
||||
moverPlatformSubComponent.AdvanceToNextWaypoint();
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_CurrentWaypointIndex, 1);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_NextWaypointIndex, 0);
|
||||
ASSERT_FALSE(moverPlatformSubComponent.m_InReverse);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_NextWaypointIndex, 2);
|
||||
moverPlatformSubComponent.AdvanceToNextWaypoint();
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_CurrentWaypointIndex, 1);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_NextWaypointIndex, 0);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_CurrentWaypointIndex, 2);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_NextWaypointIndex, 2);
|
||||
ASSERT_FALSE(moverPlatformSubComponent.m_InReverse);
|
||||
path.pathBehavior = PathBehavior::Bounce;
|
||||
moverPlatformSubComponent.AdvanceToNextWaypoint();
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_CurrentWaypointIndex, 0);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_CurrentWaypointIndex, 2);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_NextWaypointIndex, 1);
|
||||
ASSERT_TRUE(moverPlatformSubComponent.m_InReverse);
|
||||
}
|
||||
@ -320,23 +324,50 @@ TEST_F(MovingPlatformComponentTests, MovingPlatformSubComponentPathAdvanceForwar
|
||||
TEST_F(MovingPlatformComponentTests, MovingPlatformSubComponentPathAdvanceReverseTest) {
|
||||
MoverPlatformSubComponent moverPlatformSubComponent(nullptr);
|
||||
moverPlatformSubComponent._SetPath(&path);
|
||||
moverPlatformSubComponent.m_CurrentWaypointIndex = 1;
|
||||
moverPlatformSubComponent.m_NextWaypointIndex = 0;
|
||||
moverPlatformSubComponent.m_CurrentWaypointIndex = 2;
|
||||
moverPlatformSubComponent.m_NextWaypointIndex = 1;
|
||||
moverPlatformSubComponent.m_InReverse = true;
|
||||
moverPlatformSubComponent.AdvanceToNextReverseWaypoint();
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_CurrentWaypointIndex, 1);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_NextWaypointIndex, 0);
|
||||
ASSERT_TRUE(moverPlatformSubComponent.m_InReverse);
|
||||
moverPlatformSubComponent.AdvanceToNextReverseWaypoint();
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_CurrentWaypointIndex, 0);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_NextWaypointIndex, 0);
|
||||
ASSERT_TRUE(moverPlatformSubComponent.m_InReverse);
|
||||
path.pathBehavior = PathBehavior::Bounce;
|
||||
moverPlatformSubComponent.m_CurrentWaypointIndex = 1;
|
||||
moverPlatformSubComponent.m_NextWaypointIndex = 0;
|
||||
moverPlatformSubComponent.AdvanceToNextReverseWaypoint();
|
||||
moverPlatformSubComponent.AdvanceToNextWaypoint();
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_CurrentWaypointIndex, 0);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_NextWaypointIndex, 1);
|
||||
ASSERT_TRUE(moverPlatformSubComponent.m_InReverse);
|
||||
}
|
||||
|
||||
TEST_F(MovingPlatformComponentTests, MovingPlatformSubComponentPathAdvanceTest) {
|
||||
MoverPlatformSubComponent moverPlatformSubComponent(nullptr);
|
||||
moverPlatformSubComponent._SetPath(&path);
|
||||
path.pathBehavior = PathBehavior::Bounce;
|
||||
moverPlatformSubComponent.m_CurrentWaypointIndex = 0;
|
||||
moverPlatformSubComponent.m_NextWaypointIndex = 1;
|
||||
moverPlatformSubComponent.m_InReverse = false;
|
||||
moverPlatformSubComponent.AdvanceToNextWaypoint();
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_CurrentWaypointIndex, 1);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_NextWaypointIndex, 2);
|
||||
ASSERT_FALSE(moverPlatformSubComponent.m_InReverse);
|
||||
moverPlatformSubComponent.AdvanceToNextWaypoint();
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_CurrentWaypointIndex, 2);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_NextWaypointIndex, 1);
|
||||
ASSERT_TRUE(moverPlatformSubComponent.m_InReverse);
|
||||
moverPlatformSubComponent.AdvanceToNextReverseWaypoint();
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_CurrentWaypointIndex, 1);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_NextWaypointIndex, 0);
|
||||
ASSERT_TRUE(moverPlatformSubComponent.m_InReverse);
|
||||
moverPlatformSubComponent.AdvanceToNextReverseWaypoint();
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_CurrentWaypointIndex, 0);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_NextWaypointIndex, 1);
|
||||
ASSERT_FALSE(moverPlatformSubComponent.m_InReverse);
|
||||
moverPlatformSubComponent.AdvanceToNextWaypoint();
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_CurrentWaypointIndex, 1);
|
||||
ASSERT_EQ(moverPlatformSubComponent.m_NextWaypointIndex, 2);
|
||||
ASSERT_FALSE(moverPlatformSubComponent.m_InReverse);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user