Minifig editing

This commit is contained in:
Jett
2021-12-11 02:02:02 +00:00
parent 82a1c8a765
commit 6500b62c52
4 changed files with 183 additions and 52 deletions

View File

@@ -407,6 +407,50 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
stmt->execute();
delete stmt;
if (chatCommand == "setMinifig" && args.size() == 2 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_FORUM_MODERATOR) { // could break characters so only allow if GM > 0
int32_t minifigItemId;
if (!GeneralUtils::TryParse(args[1], minifigItemId)) {
ChatPackets::SendSystemMessage(sysAddr, u"Invalid Minifig Item Id ID.");
return;
}
EntityManager::Instance()->DestructEntity(entity, sysAddr);
auto* charComp = entity->GetComponent<CharacterComponent>();
std::string lowerName = args[0];
if (lowerName.empty()) return;
std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), ::tolower);
if (lowerName == "eyebrows") {
charComp->m_Character->SetEyebrows(minifigItemId);
} else if (lowerName == "eyes") {
charComp->m_Character->SetEyes(minifigItemId);
} else if (lowerName == "haircolor") {
charComp->m_Character->SetHairColor(minifigItemId);
} else if (lowerName == "hairstyle") {
charComp->m_Character->SetHairStyle(minifigItemId);
} else if (lowerName == "pants") {
charComp->m_Character->SetPantsColor(minifigItemId);
} else if (lowerName == "lefthand") {
charComp->m_Character->SetLeftHand(minifigItemId);
} else if (lowerName == "mouth") {
charComp->m_Character->SetMouth(minifigItemId);
} else if (lowerName == "righthand") {
charComp->m_Character->SetRightHand(minifigItemId);
} else if (lowerName == "shirt") {
charComp->m_Character->SetShirtColor(minifigItemId);
} else if (lowerName == "hands") {
charComp->m_Character->SetLeftHand(minifigItemId);
charComp->m_Character->SetRightHand(minifigItemId);
} else {
EntityManager::Instance()->ConstructEntity(entity);
ChatPackets::SendSystemMessage(sysAddr, u"Invalid Minifig item to change, try one of the following: Eyebrows, Eyes, HairColor, HairStyle, Pants, LeftHand, Mouth, RightHand, Shirt, Hands");
return;
}
EntityManager::Instance()->ConstructEntity(entity);
ChatPackets::SendSystemMessage(sysAddr, GeneralUtils::ASCIIToUTF16(lowerName) + u" set to " + (GeneralUtils::to_u16string(minifigItemId)));
GameMessages::SendToggleGMInvis(entity->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS); // need to retoggle because it gets reenabled on creation of new character
}
if (chatCommand == "list-spawns" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
for (const auto& pair : EntityManager::Instance()->GetSpawnPointEntities()) {
ChatPackets::SendSystemMessage(sysAddr, GeneralUtils::ASCIIToUTF16(pair.first));
@@ -429,6 +473,10 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
entity->GetCharacter()->UnlockEmote(emoteID);
}
if (chatCommand == "force-save" && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
entity->GetCharacter()->SaveXMLToDatabase();
}
if (chatCommand == "kill" && args.size() == 1 && entity->GetGMLevel() >= GAME_MASTER_LEVEL_DEVELOPER) {
ChatPackets::SendSystemMessage(sysAddr, u"Brutally murdering that player, if online on this server.");