private World CreateFreshWorld() { PersistedWorldData pWorldData = new PersistedWorldData { BaseData = BaseData.From(new List <BasePiece>(), new List <BasePiece>()), EntityData = EntityData.From(new List <Entity>()), PlayerData = PlayerData.From(new List <Player>()), WorldData = new WorldData() { EscapePodData = EscapePodData.From(new List <EscapePodModel>()), GameData = new GameData { PDAState = new PDAStateData(), StoryGoals = new StoryGoalData(), StoryTiming = new StoryTimingData() }, InventoryData = InventoryData.From(new List <ItemData>(), new List <ItemData>(), new List <EquippedItemData>()), VehicleData = VehicleData.From(new List <VehicleModel>()), ParsedBatchCells = new List <NitroxInt3>(), ServerStartTime = DateTime.Now #if DEBUG , Seed = "TCCBIBZXAB" #endif } }; return(CreateWorld(pWorldData, config.GameMode)); }
public void Save(World world) { try { PersistedWorldData persistedData = new PersistedWorldData(); persistedData.WorldData.ParsedBatchCells = world.BatchEntitySpawner.SerializableParsedBatches; persistedData.WorldData.ServerStartTime = world.TimeKeeper.ServerStartTime; persistedData.WorldData.EntityData = EntityData.From(world.EntityManager.GetAllEntities()); persistedData.BaseData = BaseData.From(world.BaseManager.GetPartiallyConstructedPieces(), world.BaseManager.GetCompletedBasePieceHistory()); persistedData.WorldData.VehicleData = VehicleData.From(world.VehicleManager.GetVehicles()); persistedData.WorldData.InventoryData = InventoryData.From(world.InventoryManager.GetAllInventoryItems(), world.InventoryManager.GetAllStorageSlotItems()); persistedData.PlayerData = PlayerData.From(world.PlayerManager.GetAllPlayers()); persistedData.WorldData.GameData = world.GameData; persistedData.WorldData.StoryTimingData = StoryTimingData.From(world.EventTriggerer); persistedData.WorldData.EscapePodData = EscapePodData.From(world.EscapePodManager.GetEscapePods()); if (!Directory.Exists(config.SaveName)) { Directory.CreateDirectory(config.SaveName); } using (Stream stream = File.OpenWrite(Path.Combine(config.SaveName, "BaseData.nitrox"))) { serializer.Serialize(stream, new SaveVersion(BaseData.VERSION)); serializer.Serialize(stream, persistedData.BaseData); } using (Stream stream = File.OpenWrite(Path.Combine(config.SaveName, "PlayerData.nitrox"))) { serializer.Serialize(stream, new SaveVersion(PlayerData.VERSION)); serializer.Serialize(stream, persistedData.PlayerData); } using (Stream stream = File.OpenWrite(Path.Combine(config.SaveName, "WorldData.nitrox"))) { serializer.Serialize(stream, new SaveVersion(WorldData.VERSION)); serializer.Serialize(stream, persistedData.WorldData); } Log.Info("World state saved."); } catch (Exception ex) { Log.Info("Could not save world: " + ex); } }
public static PersistedWorldData From(World world) { return(new PersistedWorldData { BaseData = BaseData.From(world.BaseManager.GetPartiallyConstructedPieces(), world.BaseManager.GetCompletedBasePieceHistory()), PlayerData = PlayerData.From(world.PlayerManager.GetAllPlayers()), EntityData = EntityData.From(world.EntityManager.GetAllEntities()), WorldData = { ParsedBatchCells = world.BatchEntitySpawner.SerializableParsedBatches, ServerStartTime = world.TimeKeeper.ServerStartTime, VehicleData = VehicleData.From(world.VehicleManager.GetVehicles()), InventoryData = InventoryData.From(world.InventoryManager.GetAllInventoryItems(),world.InventoryManager.GetAllStorageSlotItems()), GameData = world.GameData, EscapePodData = EscapePodData.From(world.EscapePodManager.GetEscapePods()) } }); }
public static PersistedWorldData From(World world) { return(new PersistedWorldData { BaseData = BaseData.From(world.BaseManager.GetPartiallyConstructedPieces(), world.BaseManager.GetCompletedBasePieceHistory()), PlayerData = PlayerData.From(world.PlayerManager.GetAllPlayers()), EntityData = EntityData.From(world.EntityManager.GetAllEntities()), WorldData = { ParsedBatchCells = world.BatchEntitySpawner.SerializableParsedBatches, VehicleData = VehicleData.From(world.VehicleManager.GetVehicles()), InventoryData = InventoryData.From(world.InventoryManager.GetAllInventoryItems(),world.InventoryManager.GetAllStorageSlotItems(),world.InventoryManager.GetAllModules()), GameData = GameData.From(world.GameData.PDAState, world.GameData.StoryGoals, world.ScheduleKeeper, world.EventTriggerer), EscapePodData = EscapePodData.From(world.EscapePodManager.GetEscapePods()), Seed = world.Seed } }); }
public void Save(World world, string saveDir) { try { PersistedWorldData persistedData = new PersistedWorldData { BaseData = BaseData.From(world.BaseManager.GetPartiallyConstructedPieces(), world.BaseManager.GetCompletedBasePieceHistory()), PlayerData = PlayerData.From(world.PlayerManager.GetAllPlayers()), EntityData = EntityData.From(world.EntityManager.GetAllEntities()), WorldData = { ParsedBatchCells = world.BatchEntitySpawner.SerializableParsedBatches, ServerStartTime = world.TimeKeeper.ServerStartTime, VehicleData = VehicleData.From(world.VehicleManager.GetVehicles()), InventoryData = InventoryData.From(world.InventoryManager.GetAllInventoryItems(), world.InventoryManager.GetAllStorageSlotItems()), GameData = world.GameData, StoryTimingData = StoryTimingData.From(world.EventTriggerer), EscapePodData = EscapePodData.From(world.EscapePodManager.GetEscapePods()) } }; if (!Directory.Exists(saveDir)) { Directory.CreateDirectory(saveDir); } saveDataSerializer.Serialize(Path.Combine(saveDir, "Version" + fileEnding), new SaveFileVersions()); saveDataSerializer.Serialize(Path.Combine(saveDir, "BaseData" + fileEnding), persistedData.BaseData); saveDataSerializer.Serialize(Path.Combine(saveDir, "PlayerData" + fileEnding), persistedData.PlayerData); saveDataSerializer.Serialize(Path.Combine(saveDir, "WorldData" + fileEnding), persistedData.WorldData); saveDataSerializer.Serialize(Path.Combine(saveDir, "EntityData" + fileEnding), persistedData.EntityData); Log.Info("World state saved."); } catch (Exception ex) { Log.Info("Could not save world: " + ex); } }