/// <summary> /// Writes one player out (and only one character) and their inventory to Current and archives whatever used to be Current /// </summary> /// <param name="dir">Directory to write to</param> /// <param name="entity">The player to write</param> private void WritePlayer(DirectoryInfo dir, IPlayer entity) { var entityFileName = GetPlayerFilename(entity); if (string.IsNullOrWhiteSpace(entityFileName)) return; var fullFileName = dir.FullName + entityFileName; try { WriteToFile(fullFileName, entity.ToBytes()); var liveDataWrapper = new LiveData(); //We also need to write out all the inventory foreach (var obj in entity.Inventory.EntitiesContained()) { var baseTypeName = "Inventory"; DirectoryInfo entityDirectory; //Is there a directory for this entity type? If not, then create it if (!Directory.Exists(dir.FullName + baseTypeName)) entityDirectory = Directory.CreateDirectory(dir.FullName + baseTypeName); else entityDirectory = new DirectoryInfo(dir.FullName + baseTypeName); liveDataWrapper.WriteSpecificEntity(entityDirectory, obj); } } catch (Exception ex) { LoggingUtility.LogError(ex); } }