Compare commits

...

3 Commits

5 changed files with 63 additions and 20 deletions
+53 -1
View File
@@ -26,7 +26,12 @@ void Export_Compatibility_API() {
return GMLIB_Player::getAllUuids(); return GMLIB_Player::getAllUuids();
}); });
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> { RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
return {6, 7, 8, 9, 10, 13, 16, 17, 18}; auto map = GMLIB_Level::getAllExperiments();
std::vector<int> result;
for (auto& key : map) {
result.push_back(key.first);
}
return result;
}); });
RemoteCall::exportAs("GMLIB_API", "getExperimentTranslatedName", [](int id) -> std::string { RemoteCall::exportAs("GMLIB_API", "getExperimentTranslatedName", [](int id) -> std::string {
auto map = GMLIB_Level::getAllExperimentsTranslateKeys(); auto map = GMLIB_Level::getAllExperimentsTranslateKeys();
@@ -35,4 +40,51 @@ void Export_Compatibility_API() {
} }
return ""; return "";
}); });
RemoteCall::exportAs("GMLIB_API", "createFloatingText", [](std::pair<Vec3, int> 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;
});
} }
+7 -5
View File
@@ -1,7 +1,6 @@
#include "Global.h" #include "Global.h"
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"}; std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
std::unordered_set<int> ExperimentsList = {6, 7, 8, 9, 10, 13, 16, 17, 18};
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string& key) { std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string& key) {
if (HardCodedKeys.count(key)) { if (HardCodedKeys.count(key)) {
@@ -155,7 +154,8 @@ void Export_Legacy_GMLib_ModAPI() {
}); });
// 实验性 // 实验性
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void { 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); GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
} else { } else {
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id); ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
@@ -166,7 +166,8 @@ void Export_Legacy_GMLib_ModAPI() {
if (!level) { if (!level) {
return; return;
} }
if (ExperimentsList.count(experiment_id)) { auto map = GMLIB_Level::getAllExperiments();
if (map.count(experiment_id)) {
GMLIB_Level::getLevel()->setExperimentEnabled(((AllExperiments)experiment_id), value); GMLIB_Level::getLevel()->setExperimentEnabled(((AllExperiments)experiment_id), value);
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id); } else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
}); });
@@ -175,7 +176,8 @@ void Export_Legacy_GMLib_ModAPI() {
if (!level) { if (!level) {
return false; 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)); return GMLIB_Level::getLevel()->getExperimentEnabled(((AllExperiments)experiment_id));
} else { } else {
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id); ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
-11
View File
@@ -7,17 +7,6 @@ void Export_Legacy_GMLib_ServerAPI() {
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void { RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
GMLIB_Level::forceEnableAbilityCommand(); GMLIB_Level::forceEnableAbilityCommand();
}); });
RemoteCall::exportAs(
"GMLib_ServerAPI",
"addFloatingTextPacket",
[](std::string text, std::pair<Vec3, int> 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 { RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
GMLIB_Level::setForceAchievementsEnabled(); GMLIB_Level::setForceAchievementsEnabled();
}); });
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
"format_version": 2, "format_version": 2,
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi", "tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
"version": "0.8.1", "version": "0.8.2",
"info": { "info": {
"name": "GMLIB-LegacyRemoteCallApi", "name": "GMLIB-LegacyRemoteCallApi",
"description": "Legacy RemoteCall API for GMLIB", "description": "Legacy RemoteCall API for GMLIB",
@@ -13,7 +13,7 @@
"Library" "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": { "dependencies": {
"github.com/GroupMountain/GMLIB": ">=0.8.1" "github.com/GroupMountain/GMLIB": ">=0.8.1"
}, },