TSharedRef<FJsonObject> UFlareSaveWriter::SaveFactory(FFlareFactorySave* Data) { TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject()); JsonObject->SetBoolField("Active", Data->Active); JsonObject->SetStringField("CostReserved", FormatInt32(Data->CostReserved)); JsonObject->SetStringField("ProductedDuration", FormatInt64(Data->ProductedDuration)); JsonObject->SetBoolField("InfiniteCycle", Data->InfiniteCycle); JsonObject->SetStringField("CycleCount", FormatInt32(Data->CycleCount)); JsonObject->SetStringField("TargetShipClass", Data->TargetShipClass.ToString()); JsonObject->SetStringField("TargetShipCompany", Data->TargetShipCompany.ToString()); JsonObject->SetStringField("OrderShipClass", Data->OrderShipClass.ToString()); JsonObject->SetStringField("OrderShipCompany", Data->OrderShipCompany.ToString()); JsonObject->SetStringField("OrderShipAdvancePayment", FormatInt32(Data->OrderShipAdvancePayment)); TArray< TSharedPtr<FJsonValue> > ResourceReserved; for(int i = 0; i < Data->ResourceReserved.Num(); i++) { ResourceReserved.Add(MakeShareable(new FJsonValueObject(SaveCargo(&Data->ResourceReserved[i])))); } JsonObject->SetArrayField("ResourceReserved", ResourceReserved); TArray< TSharedPtr<FJsonValue> > OutputCargoLimit; for(int i = 0; i < Data->OutputCargoLimit.Num(); i++) { OutputCargoLimit.Add(MakeShareable(new FJsonValueObject(SaveCargo(&Data->OutputCargoLimit[i])))); } JsonObject->SetArrayField("OutputCargoLimit", OutputCargoLimit); return JsonObject; }
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::SaveTradeRouteSector(FFlareTradeRouteSectorSave* Data) { TSharedRef<FJsonObject> JsonObject = MakeShareable(new FJsonObject()); JsonObject->SetStringField("SectorIdentifier", Data->SectorIdentifier.ToString()); TArray< TSharedPtr<FJsonValue> > ResourcesToLoad; for(int i = 0; i < Data->ResourcesToLoad.Num(); i++) { ResourcesToLoad.Add(MakeShareable(new FJsonValueObject(SaveCargo(&Data->ResourcesToLoad[i])))); } JsonObject->SetArrayField("ResourcesToLoad", ResourcesToLoad); TArray< TSharedPtr<FJsonValue> > ResourcesToUnload; for(int i = 0; i < Data->ResourcesToUnload.Num(); i++) { ResourcesToUnload.Add(MakeShareable(new FJsonValueObject(SaveCargo(&Data->ResourcesToUnload[i])))); } JsonObject->SetArrayField("ResourcesToUnload", ResourcesToUnload); return JsonObject; }