public void ReplaceCabinName() { var uniqueName = $"Cabin{Guid.NewGuid()}"; Element.Element("indoors").Element("uniqueName").Value = uniqueName; Farmhand.Element("homeLocation").Value = uniqueName; }
public void RemoveFarmhandFromStorage(Farmhand farmhand) { if (farmhand.InStorage) { farmhand.Cabin.Element.Remove(); } }
public void ReplaceMultiplayerId() { byte[] buffer = new byte[8]; random.NextBytes(buffer); var uniqueMultiplayerId = BitConverter.ToInt64(buffer, 0); Farmhand .Element("UniqueMultiplayerID") .Value = uniqueMultiplayerId.ToString(); }
public void StoreFarmhand(Farmhand farmhand) { var element = _farmhands.FirstOrDefault(x => x.Element("name")?.Value == farmhand.Name); if (element == null) { _doc.Element("Farmhands").Add(farmhand.Cabin.Element); } else { element.ReplaceAll(farmhand.Cabin.Element.Nodes()); } }
public void RemoveCabin(XElement cabin) { var farmhand = new Farmhand(cabin, true, isCabin: true); if (farmhand.Name == null) { cabin.Remove(); } else { var farmhands = new Farmhands(this); farmhands.StoreFarmhand(farmhand); Console.WriteLine("Storing backup of farmhand..."); } }
public bool AddFarmhand(Farmhand farmhand) { var cabin = _game.FindEmptyCabin(); if (cabin == null) { cabin = _game.CreateNewCabin(farmhand.Cabin); if (cabin == null) { return(false); } } cabin.SwitchCabin(farmhand.Cabin); farmhand.Cabin = cabin; RemoveFarmhandFromStorage(farmhand); return(true); }
public void RemoveFarmhandFromCabin(Farmhand farmhand, bool storeFarmhand = true, bool removeCabin = false) { if (farmhand.InGame) { if (storeFarmhand) { StoreFarmhand(farmhand); } if (!removeCabin) { var newFarmhand = CreateBlankFarmhandElement(); farmhand.Cabin.SwitchFarmhand(newFarmhand); } else { farmhand.Cabin.Element.Remove(); } } }
public void SwitchFarmhand(XElement farmhand) { Farmhand.ReplaceAll(farmhand.Nodes()); }
public void UpdateFarmhand(XElement host) { Farmhand.Element("farmName").Value = host.Element("farmName").Value; Farmhand.Element("money").Value = host.Element("money").Value; Farmhand.Element("slotCanHost").Value = "true"; }