diff --git a/SDK-GMLIB b/SDK-GMLIB index 72e596a..945cea5 160000 --- a/SDK-GMLIB +++ b/SDK-GMLIB @@ -1 +1 @@ -Subproject commit 72e596afb1fcca9c7bf0bdedc88535704bfb19a8 +Subproject commit 945cea5caee03d9f911e0d0fb60f9bb601f869ad diff --git a/src/CompatibilityApi.cpp b/src/CompatibilityApi.cpp index c5dde29..124b8fa 100644 --- a/src/CompatibilityApi.cpp +++ b/src/CompatibilityApi.cpp @@ -26,7 +26,12 @@ void Export_Compatibility_API() { return GMLIB_Player::getAllUuids(); }); RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector { - return {6, 7, 8, 9, 10, 13, 16, 17, 18}; + auto map = GMLIB_Level::getAllExperiments(); + std::vector result; + for (auto& key : map) { + result.push_back(key.first); + } + return result; }); RemoteCall::exportAs("GMLIB_API", "getExperimentTranslatedName", [](int id) -> std::string { auto map = GMLIB_Level::getAllExperimentsTranslateKeys(); @@ -35,4 +40,51 @@ void Export_Compatibility_API() { } return ""; }); + RemoteCall::exportAs("GMLIB_API", "createFloatingText", [](std::pair pos, std::string text) -> int { + auto ft = new GMLIB::Server::FloatingText(text, pos.first, pos.second); + return ft->getRuntimeID(); + }); + RemoteCall::exportAs("GMLIB_API", "setFloatingTextData", [](int id, std::string text) -> bool { + auto ft = GMLIB::Server::FloatingText::getFloatingText(id); + if (ft) { + ft->setText(text); + return true; + } + return false; + }); + RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool { + return GMLIB::Server::FloatingText::deleteFloatingText(id); + }); + RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, Player* pl) -> bool { + auto ft = GMLIB::Server::FloatingText::getFloatingText(id); + if (ft) { + ft->sendToClient(pl); + return true; + } + return false; + }); + RemoteCall::exportAs("GMLIB_API", "sendFloatingText", [](int id) -> bool { + auto ft = GMLIB::Server::FloatingText::getFloatingText(id); + if (ft) { + ft->sendToAllClients(); + return true; + } + return false; + }); + RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, Player* pl) -> bool { + auto ft = GMLIB::Server::FloatingText::getFloatingText(id); + if (ft) { + ft->removeFromClient(pl); + return true; + } + return false; + }); + RemoteCall::exportAs("GMLIB_API", "removeFloatingText", [](int id) -> bool { + auto ft = GMLIB::Server::FloatingText::getFloatingText(id); + if (ft) { + ft->removeFromAllClients(); + return true; + } + return false; + }); } \ No newline at end of file diff --git a/src/LegacyModApi.cpp b/src/LegacyModApi.cpp index 19e4381..51a4eb0 100644 --- a/src/LegacyModApi.cpp +++ b/src/LegacyModApi.cpp @@ -1,7 +1,6 @@ #include "Global.h" -std::unordered_set HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"}; -std::unordered_set ExperimentsList = {6, 7, 8, 9, 10, 13, 16, 17, 18}; +std::unordered_set HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"}; std::variant> makeRecipeUnlockingKey(std::string& key) { if (HardCodedKeys.count(key)) { @@ -155,7 +154,8 @@ void Export_Legacy_GMLib_ModAPI() { }); // 实验性 RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void { - if (ExperimentsList.count(experiment_id)) { + auto map = GMLIB_Level::getAllExperiments(); + if (map.count(experiment_id)) { GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id); } else { ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id); @@ -166,7 +166,8 @@ void Export_Legacy_GMLib_ModAPI() { if (!level) { return; } - if (ExperimentsList.count(experiment_id)) { + auto map = GMLIB_Level::getAllExperiments(); + if (map.count(experiment_id)) { GMLIB_Level::getLevel()->setExperimentEnabled(((AllExperiments)experiment_id), value); } else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id); }); @@ -175,7 +176,8 @@ void Export_Legacy_GMLib_ModAPI() { if (!level) { return false; } - if (ExperimentsList.count(experiment_id)) { + auto map = GMLIB_Level::getAllExperiments(); + if (map.count(experiment_id)) { return GMLIB_Level::getLevel()->getExperimentEnabled(((AllExperiments)experiment_id)); } else { ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id); diff --git a/src/LegacyServerApi.cpp b/src/LegacyServerApi.cpp index 2904824..c56d633 100644 --- a/src/LegacyServerApi.cpp +++ b/src/LegacyServerApi.cpp @@ -7,17 +7,6 @@ void Export_Legacy_GMLib_ServerAPI() { RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void { GMLIB_Level::forceEnableAbilityCommand(); }); - RemoteCall::exportAs( - "GMLib_ServerAPI", - "addFloatingTextPacket", - [](std::string text, std::pair pos, int dimid) -> int { - auto ft = new GMLIB::Server::FloatingText(text, pos.first, pos.second); - return ft->getRuntimeID(); - } - ); - RemoteCall::exportAs("GMLib_ServerAPI", "deleteFloatingTextPacket", [](int id) -> void { - GMLIB::Server::FloatingText::deleteFloatingText(id); - }); RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void { GMLIB_Level::setForceAchievementsEnabled(); }); diff --git a/tooth.json b/tooth.json index eeb7a6b..2096ebd 100644 --- a/tooth.json +++ b/tooth.json @@ -1,7 +1,7 @@ { "format_version": 2, "tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi", - "version": "0.8.1", + "version": "0.8.2", "info": { "name": "GMLIB-LegacyRemoteCallApi", "description": "Legacy RemoteCall API for GMLIB", @@ -13,7 +13,7 @@ "Library" ] }, - "asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.8.1/GMLIB-LegacyRemoteCallApi-windows-x64.zip", + "asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.8.2/GMLIB-LegacyRemoteCallApi-windows-x64.zip", "dependencies": { "github.com/GroupMountain/GMLIB": ">=0.8.1" },