TSharedRef<FJsonObject> UFlareSaveWriter::SaveSpacecraft(FFlareSpacecraftSave* Data) { TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject()); JsonObject->SetStringField("Immatriculation", Data->Immatriculation.ToString()); JsonObject->SetStringField("NickName", Data->NickName.ToString()); JsonObject->SetStringField("Identifier", Data->Identifier.ToString()); JsonObject->SetStringField("CompanyIdentifier", Data->CompanyIdentifier.ToString()); JsonObject->SetStringField("Location", FormatVector(Data->Location)); JsonObject->SetStringField("Rotation", FormatRotator(Data->Rotation)); JsonObject->SetStringField("SpawnMode", FormatEnum<EFlareSpawnMode::Type>("EFlareSpawnMode",Data->SpawnMode)); JsonObject->SetStringField("LinearVelocity", FormatVector(Data->LinearVelocity)); JsonObject->SetStringField("AngularVelocity", FormatVector(Data->AngularVelocity)); JsonObject->SetStringField("DockedTo", Data->DockedTo.ToString()); JsonObject->SetStringField("DockedAt", FormatInt32(Data->DockedAt)); SaveFloat(JsonObject,"Heat", Data->Heat); SaveFloat(JsonObject,"PowerOutageDelay", Data->PowerOutageDelay); SaveFloat(JsonObject,"PowerOutageAcculumator", Data->PowerOutageAcculumator); JsonObject->SetStringField("DynamicComponentStateIdentifier", Data->DynamicComponentStateIdentifier.ToString()); SaveFloat(JsonObject,"DynamicComponentStateProgress", Data->DynamicComponentStateProgress); JsonObject->SetStringField("Level", FormatInt32(Data->Level)); JsonObject->SetBoolField("IsTrading", Data->IsTrading); JsonObject->SetObjectField("Pilot", SavePilot(&Data->Pilot)); JsonObject->SetObjectField("Asteroid", SaveAsteroid(&Data->AsteroidData)); TArray< TSharedPtr<FJsonValue> > Components; for(int i = 0; i < Data->Components.Num(); i++) { Components.Add(MakeShareable(new FJsonValueObject(SaveSpacecraftComponent(&Data->Components[i])))); } JsonObject->SetArrayField("Components", Components); TArray< TSharedPtr<FJsonValue> > Cargo; for(int i = 0; i < Data->Cargo.Num(); i++) { Cargo.Add(MakeShareable(new FJsonValueObject(SaveCargo(&Data->Cargo[i])))); } JsonObject->SetArrayField("Cargo", Cargo); TArray< TSharedPtr<FJsonValue> > FactoryStates; for(int i = 0; i < Data->FactoryStates.Num(); i++) { FactoryStates.Add(MakeShareable(new FJsonValueObject(SaveFactory(&Data->FactoryStates[i])))); } JsonObject->SetArrayField("FactoryStates", FactoryStates); TArray< TSharedPtr<FJsonValue> > SalesExcludedResources; for(int i = 0; i < Data->SalesExcludedResources.Num(); i++) { SalesExcludedResources.Add(MakeShareable(new FJsonValueString(Data->SalesExcludedResources[i].ToString()))); } JsonObject->SetArrayField("SalesExcludedResources", SalesExcludedResources); return JsonObject; }
TSharedRef<FJsonObject> UFlareSaveWriter::SaveAsteroid(FFlareAsteroidSave* Data) { TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject()); JsonObject->SetStringField("Identifier", Data->Identifier.ToString()); JsonObject->SetStringField("Location", FormatVector(Data->Location)); JsonObject->SetStringField("Rotation", FormatRotator(Data->Rotation)); JsonObject->SetStringField("LinearVelocity", FormatVector(Data->LinearVelocity)); JsonObject->SetStringField("AngularVelocity", FormatVector(Data->AngularVelocity)); JsonObject->SetStringField("Scale", FormatVector(Data->Scale)); JsonObject->SetStringField("AsteroidMeshID", FormatInt32(Data->AsteroidMeshID)); return JsonObject; }
TSharedRef<FJsonObject> UFlareSaveWriter::SaveBomb(FFlareBombSave* Data) { TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject()); JsonObject->SetStringField("Location", FormatVector(Data->Location)); JsonObject->SetStringField("Rotation", FormatRotator(Data->Rotation)); JsonObject->SetStringField("LinearVelocity", FormatVector(Data->LinearVelocity)); JsonObject->SetStringField("AngularVelocity", FormatVector(Data->AngularVelocity)); JsonObject->SetStringField("WeaponSlotIdentifier", Data->WeaponSlotIdentifier.ToString()); JsonObject->SetStringField("ParentSpacecraft", Data->ParentSpacecraft.ToString()); JsonObject->SetBoolField("Activated", Data->Activated); JsonObject->SetBoolField("Dropped", Data->Dropped); SaveFloat(JsonObject,"DropParentDistance", Data->DropParentDistance); SaveFloat(JsonObject,"LifeTime", Data->LifeTime); return JsonObject; }