[Small Addition] added respawnInWorld Command
This commit is contained in:
parent
06b865fb84
commit
98a395721e
@ -10,6 +10,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"openSbCommands": {
|
"openSbCommands": {
|
||||||
"swap": "Usage /swap <name>. Swaps the current character, case-insensitive, only substring required."
|
"swap": "Usage /swap <name>. Swaps the current character, case-insensitive, only substring required.",
|
||||||
|
"respawninworld": "Usage /respawnInWorld. Sets the respawn flag for the current world until you teleport away."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,8 @@ ClientCommandProcessor::ClientCommandProcessor(UniverseClientPtr universeClient,
|
|||||||
{"maketechavailable", bind(&ClientCommandProcessor::makeTechAvailable, this, _1)},
|
{"maketechavailable", bind(&ClientCommandProcessor::makeTechAvailable, this, _1)},
|
||||||
{"enabletech", bind(&ClientCommandProcessor::enableTech, this, _1)},
|
{"enabletech", bind(&ClientCommandProcessor::enableTech, this, _1)},
|
||||||
{"upgradeship", bind(&ClientCommandProcessor::upgradeShip, this, _1)},
|
{"upgradeship", bind(&ClientCommandProcessor::upgradeShip, this, _1)},
|
||||||
{"swap", bind(&ClientCommandProcessor::swap, this, _1)}
|
{"swap", bind(&ClientCommandProcessor::swap, this, _1)},
|
||||||
|
{"respawnInWorld", bind(&ClientCommandProcessor::respawnInWorld, this)}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,4 +428,25 @@ String ClientCommandProcessor::swap(String const& argumentsString) {
|
|||||||
return "Failed to swap player";
|
return "Failed to swap player";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String ClientCommandProcessor::respawnInWorld() {
|
||||||
|
WorldClientPtr worldClient = m_universeClient->worldClient();
|
||||||
|
|
||||||
|
// Make sure we got the worldClient
|
||||||
|
if (!worldClient) {
|
||||||
|
return "Error: Unable to access world client.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (worldClient->toggleRespawnInWorld()) {
|
||||||
|
// Convert boolean to string for the response
|
||||||
|
const std::string result = worldClient->respawnInWorld() ? "true" : "false";
|
||||||
|
|
||||||
|
return "Successfully switched respawn in this world to " + result;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return "Failed to switch respawn in this world!";
|
||||||
|
|
||||||
|
// This should never trigger, but its better to have it than not :3
|
||||||
|
return "Something unforseen happend!";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -58,6 +58,7 @@ private:
|
|||||||
String enableTech(String const& argumentsString);
|
String enableTech(String const& argumentsString);
|
||||||
String upgradeShip(String const& argumentsString);
|
String upgradeShip(String const& argumentsString);
|
||||||
String swap(String const& argumentsString);
|
String swap(String const& argumentsString);
|
||||||
|
String respawnInWorld();
|
||||||
|
|
||||||
UniverseClientPtr m_universeClient;
|
UniverseClientPtr m_universeClient;
|
||||||
CinematicPtr m_cinematicOverlay;
|
CinematicPtr m_cinematicOverlay;
|
||||||
|
@ -2421,4 +2421,16 @@ void WorldClient::setupForceRegions() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WorldClient::toggleRespawnInWorld() {
|
||||||
|
// Setting oldValue to check if m_respawnInWorld triggered correctly later
|
||||||
|
const bool oldValue = respawnInWorld();
|
||||||
|
|
||||||
|
m_respawnInWorld ^= true;
|
||||||
|
|
||||||
|
if (respawnInWorld() != oldValue) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -175,6 +175,9 @@ public:
|
|||||||
|
|
||||||
typedef std::function<bool(PlayerPtr, StringView)> BroadcastCallback;
|
typedef std::function<bool(PlayerPtr, StringView)> BroadcastCallback;
|
||||||
BroadcastCallback& broadcastCallback();
|
BroadcastCallback& broadcastCallback();
|
||||||
|
|
||||||
|
bool toggleRespawnInWorld();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const float DropDist;
|
static const float DropDist;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user