/// <summary> /// Restores this character from a pre-death backup. /// </summary> public void Resurrect() { if (this.preDeathBackup == null) { return; } if (!File.Exists(this.preDeathBackup)) { this.preDeathBackup = null; return; } this.watcher.EnableRaisingEvents = false; CharacterBackups.PauseMonitoring(); if (File.Exists(this.mainFile)) { File.Delete(this.mainFile); } File.Move(this.preDeathBackup, this.mainFile); this.preDeathBackup = null; this.watcher.EnableRaisingEvents = true; CharacterBackups.ResumeMonitoring(); this.Backup(this, new FileSystemEventArgs(WatcherChangeTypes.Created, CharacterBackups.GamePath, this.FileName)); }
/// <summary> /// Restores an archived character into the active one. /// </summary> public void Unpack() { var nameNoExt = FindViableName("game", CharacterBackups.CharacterFileExtension); this.watcher.EnableRaisingEvents = false; CharacterBackups.PauseMonitoring(); this.RenameFiles(nameNoExt, CharacterBackups.CharacterFileExtension, CharacterBackups.ArchivedFileExtension); this.watcher.EnableRaisingEvents = true; CharacterBackups.ResumeMonitoring(); this.archived = false; this.OnChanged(); }
/// <summary> /// Restores the character from a specified backup. /// </summary> /// <param name="backupIndex">Zero-based index of the backup to choose for restoration.</param> public void Restore(int backupIndex) { this.watcher.EnableRaisingEvents = false; CharacterBackups.PauseMonitoring(); // Check just in case. if (File.Exists(this.mainFile)) { File.Delete(this.mainFile); } File.Move(this.backups[backupIndex], this.mainFile); this.watcher.EnableRaisingEvents = true; CharacterBackups.ResumeMonitoring(); this.Backup(this, new FileSystemEventArgs(WatcherChangeTypes.Changed, CharacterBackups.GamePath, Path.GetFileName(this.mainFile))); }