mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
Proper Rocket Holding
Sanity checks on Prop and LUP launchpads to not open if no valid rocket Add serialization for sending item configs so that rockets show for other players
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "PossessorComponent.h"
|
||||
#include "VehiclePhysicsComponent.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Item.h"
|
||||
|
||||
CharacterComponent::CharacterComponent(Entity* parent, Character* character) : Component(parent) {
|
||||
m_Character = character;
|
||||
@@ -448,6 +449,56 @@ void CharacterComponent::SetLastRocketConfig(std::u16string config) {
|
||||
m_LastRocketConfig = config;
|
||||
}
|
||||
|
||||
Item* CharacterComponent::GetRocket(Entity* player) {
|
||||
Item* rocket = nullptr;
|
||||
|
||||
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||
|
||||
if (!inventoryComponent) return rocket;
|
||||
|
||||
// Select the rocket
|
||||
if (!rocket){
|
||||
rocket = inventoryComponent->FindItemById(GetLastRocketItemID());
|
||||
}
|
||||
|
||||
if (!rocket) {
|
||||
rocket = inventoryComponent->FindItemByLot(6416);
|
||||
}
|
||||
|
||||
if (!rocket) {
|
||||
Game::logger->Log("CharacterComponent", "Unable to find rocket to equip!\n");
|
||||
return rocket;
|
||||
}
|
||||
return rocket;
|
||||
}
|
||||
|
||||
Item* CharacterComponent::RocketEquip(Entity* player) {
|
||||
Item* rocket = GetRocket(player);
|
||||
if (!rocket) return rocket;
|
||||
|
||||
// build and define the rocket config
|
||||
for (LDFBaseData* data : rocket->GetConfig()) {
|
||||
if (data->GetKey() == u"assemblyPartLOTs") {
|
||||
std::string newRocketStr = data->GetValueAsString() + ";";
|
||||
GeneralUtils::ReplaceInString(newRocketStr, "+", ";");
|
||||
SetLastRocketConfig(GeneralUtils::ASCIIToUTF16(newRocketStr));
|
||||
}
|
||||
}
|
||||
|
||||
// Store the last used rocket item's ID
|
||||
SetLastRocketItemID(rocket->GetId());
|
||||
// carry the rocket
|
||||
rocket->Equip(true);
|
||||
return rocket;
|
||||
}
|
||||
|
||||
void CharacterComponent::RocketUnEquip(Entity* player) {
|
||||
Item* rocket = GetRocket(player);
|
||||
if (!rocket) return;
|
||||
// We don't want to carry it anymore
|
||||
rocket->UnEquip();
|
||||
}
|
||||
|
||||
void CharacterComponent::TrackMissionCompletion(bool isAchievement) {
|
||||
UpdatePlayerStatistic(MissionsCompleted);
|
||||
|
||||
|
Reference in New Issue
Block a user