mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-30 01:41:40 +00:00
fix(platforms): rotate_while_idle chooses the subcomponent when all types are set false
As the client: a rotater when true, else a mover. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -118,6 +118,10 @@ std::vector<eMoverSubComponentType> ChooseSubComponentTypes(const int32_t compon
|
||||
if (setMover && entity.GetVar<bool>(u"platformIsMover")) types.push_back(eMoverSubComponentType::mover);
|
||||
if (setSimpleMover && entity.GetVar<bool>(u"platformIsSimpleMover")) types.push_back(eMoverSubComponentType::simpleMover);
|
||||
if (setRotater && entity.GetVar<bool>(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<bool>(u"rotate_while_idle") ? eMoverSubComponentType::rotater : eMoverSubComponentType::mover);
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<bool>(u"rotate_while_idle", true);
|
||||
Entity idleRotater(288300744895900107, info);
|
||||
EXPECT_EQ(ChooseMoverSubComponentType(41, idleRotater), eMoverSubComponentType::rotater);
|
||||
info.settings.values.clear();
|
||||
info.settings.Insert<bool>(u"platformIsRotater", false);
|
||||
info.settings.Insert<bool>(u"rotate_while_idle", false);
|
||||
Entity idleMover(288300744895900108, info);
|
||||
EXPECT_EQ(ChooseMoverSubComponentType(41, idleMover), eMoverSubComponentType::mover);
|
||||
info.settings.values.clear();
|
||||
info.settings.Insert<bool>(u"rotate_while_idle", true);
|
||||
Entity idleOnly(288300744895900111, info);
|
||||
EXPECT_EQ(ChooseMoverSubComponentType(41, idleOnly), eMoverSubComponentType::simpleMover);
|
||||
info.settings.values.clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user