public CharacterCampaignData(Client client, bool giveRespawnPenaltyAffliction = false) { Name = client.Name; InitProjSpecific(client); healthData = new XElement("health"); client.Character?.CharacterHealth?.Save(healthData); if (giveRespawnPenaltyAffliction) { var respawnPenaltyAffliction = RespawnManager.GetRespawnPenaltyAffliction(); healthData.Add(new XElement("Affliction", new XAttribute("identifier", respawnPenaltyAffliction.Identifier), new XAttribute("strength", respawnPenaltyAffliction.Strength.ToString("G", CultureInfo.InvariantCulture)))); } if (client.Character?.Inventory != null) { itemData = new XElement("inventory"); Character.SaveInventory(client.Character.Inventory, itemData); } OrderData = new XElement("orders"); if (client.Character != null) { CharacterInfo.SaveOrderData(client.Character.Info, OrderData); } }
public void Refresh(Character character) { healthData = new XElement("health"); character.CharacterHealth.Save(healthData); if (character.Inventory != null) { itemData = new XElement("inventory"); character.SaveInventory(character.Inventory, itemData); } }
public CharacterCampaignData(Client client) { Name = client.Name; InitProjSpecific(client); healthData = new XElement("health"); client.Character.CharacterHealth.Save(healthData); if (client.Character.Inventory != null) { itemData = new XElement("inventory"); Character.SaveInventory(client.Character.Inventory, itemData); } OrderData = new XElement("orders"); CharacterInfo.SaveOrderData(client.Character.Info, OrderData); }
public static void SavePets(XElement petsElement) { foreach (Character c in Character.CharacterList) { if (!c.IsPet || c.IsDead) { continue; } if (c.Submarine == null) { continue; } var petBehavior = (c.AIController as EnemyAIController)?.PetBehavior; if (petBehavior == null) { continue; } XElement petElement = new XElement("pet", new XAttribute("speciesname", c.SpeciesName), new XAttribute("ownerhash", petBehavior.Owner?.Info?.GetIdentifier() ?? 0), new XAttribute("seed", c.Seed)); var petBehaviorElement = new XElement("petbehavior", new XAttribute("hunger", petBehavior.Hunger.ToString("G", CultureInfo.InvariantCulture)), new XAttribute("happiness", petBehavior.Happiness.ToString("G", CultureInfo.InvariantCulture))); petElement.Add(petBehaviorElement); var healthElement = new XElement("health"); c.CharacterHealth.Save(healthElement); petElement.Add(healthElement); if (c.Inventory != null) { var inventoryElement = new XElement("inventory"); Character.SaveInventory(c.Inventory, inventoryElement); petElement.Add(inventoryElement); } petsElement.Add(petElement); } }