public SimulationJob(WorldDataAccess worldDataAccess, WorldSimulationState worldSimulationState, WorldSimulationStateService worldSimulationStateService, string persistentDataPath) { _worldSimulationState = worldSimulationState; _worldSimulationStateService = worldSimulationStateService; _worldDataAccess = worldDataAccess; _persistentDataPath = persistentDataPath; }
public SimulateAreaJob(WorldDataAccess worldDataAccess, TokenRequest tokenRequest, WorldSimulationState state, string persistentDataPath, Action onComplete) { _tokenRequest = tokenRequest; _state = state; _worldDataAccess = worldDataAccess; _persistentDataPath = persistentDataPath; _onComplete = onComplete; }
public WorldSimulationState GenerateSimulationState(WorldIndex worldIndex) { WorldSimulationState state = new WorldSimulationState(); state.Dimensions = Dimemsions; state.WorldDimensions = worldIndex.Dimensions; state.Radius = Radius; state.SimulationDevisions = SimulationDevisions; return(state); }
protected override void ThreadFunction() { string filepath = _request.Filepath; if (File.Exists(filepath)) { FileStream fileStream = File.Open(filepath, FileMode.Open); using (var stream = fileStream) { Output = _serializer.Deserialize(stream) as WorldSimulationState; } } }
public void SaveState(WorldSimulationState state, string persistentDataPath) { SharpSerializer serializer = new SharpSerializer(); string filePath = String.Join(DataConfig.DirectoryDelimiter, new string[] { _worldPersistanceService.IndexGenerator.RootPath(persistentDataPath), SimulationConfiguration.IndexFilename }); FileStream fileStream = File.Open(filePath, FileMode.OpenOrCreate); using (var stream = fileStream) { serializer.Serialize(state, fileStream); } }
public SaveSimulationStateJobRequest(string filepath, WorldSimulationState state) { _filepath = filepath; _state = state; }
private void OnSimulationStateLoaded(WorldSimulationState simulationState) { _state = simulationState; _worldDataAccessService.RequestAccess(OnDataAccessRequested, () => { }); }