diff --git a/dGame/dComponents/MovingPlatformComponent.cpp b/dGame/dComponents/MovingPlatformComponent.cpp index 932ba91f6..e2ebb47c2 100644 --- a/dGame/dComponents/MovingPlatformComponent.cpp +++ b/dGame/dComponents/MovingPlatformComponent.cpp @@ -118,6 +118,10 @@ std::vector ChooseSubComponentTypes(const int32_t compon if (setMover && entity.GetVar(u"platformIsMover")) types.push_back(eMoverSubComponentType::mover); if (setSimpleMover && entity.GetVar(u"platformIsSimpleMover")) types.push_back(eMoverSubComponentType::simpleMover); if (setRotater && entity.GetVar(u"platformIsRotater")) types.push_back(eMoverSubComponentType::rotater); + // All set false: rotate_while_idle makes it a rotater, or a mover when false + if (types.empty() && entity.HasVar(u"rotate_while_idle")) { + types.push_back(entity.GetVar(u"rotate_while_idle") ? eMoverSubComponentType::rotater : eMoverSubComponentType::mover); + } return types; } diff --git a/tests/dGameTests/dComponentsTests/MovingPlatformComponentTests.cpp b/tests/dGameTests/dComponentsTests/MovingPlatformComponentTests.cpp index c9e5032ee..40b01fa21 100644 --- a/tests/dGameTests/dComponentsTests/MovingPlatformComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/MovingPlatformComponentTests.cpp @@ -95,6 +95,20 @@ TEST_F(MovingPlatformComponentTest, SubcomponentTypeFromLevelConfig) { Entity none(288300744895900106, info); EXPECT_EQ(ChooseMoverSubComponentType(41, none), eMoverSubComponentType::none); + // All false with rotate_while_idle: a rotater when it is true, else a mover; without the type settings it does + // nothing + info.settings.Insert(u"rotate_while_idle", true); + Entity idleRotater(288300744895900107, info); + EXPECT_EQ(ChooseMoverSubComponentType(41, idleRotater), eMoverSubComponentType::rotater); + info.settings.values.clear(); + info.settings.Insert(u"platformIsRotater", false); + info.settings.Insert(u"rotate_while_idle", false); + Entity idleMover(288300744895900108, info); + EXPECT_EQ(ChooseMoverSubComponentType(41, idleMover), eMoverSubComponentType::mover); + info.settings.values.clear(); + info.settings.Insert(u"rotate_while_idle", true); + Entity idleOnly(288300744895900111, info); + EXPECT_EQ(ChooseMoverSubComponentType(41, idleOnly), eMoverSubComponentType::simpleMover); info.settings.values.clear(); }