public override void LoadPawnToSav(PawnData pawn, XElement xElement, SavSlot savSlot) { int i = 0; foreach (XElement childElement in xElement.Elements()) { if (i >= Keys.Count) { throw new XmlException(string.Format( "An array in the save config is missing a key " + "for the following element: {0}\n" + "Array's first key is: {1}", childElement.ToString(), Keys.Count > 0 ? Keys[0] : "")); } if (Keys[i].Length > 0) { PawnParameter pawnParameter = pawn.GetParameter(Keys[i]); if (pawnParameter != null) { LoadParameterToSav(pawnParameter, childElement); } } ++i; } }
public override void LoadPawnToSav(PawnData pawn, XElement xElement, SavSlot savSlot) { if (isName) { LoadPawnNameToSav(pawn, xElement); return; } PawnParameter pawnParameter = pawn.GetParameter(Key); if (pawnParameter != null) { LoadParameterToSav(pawnParameter, xElement); } }
private void LoadPawnNameToSav(PawnData pawn, XElement xElement) { string name = pawn.GetParameter(Key).Value as string; int letterIndex = 0; foreach (XElement letterElement in xElement.Elements()) { XAttribute letterAttribute = letterElement.GetValueAttribute(); if (letterIndex < name.Length) { letterAttribute.Value = ((int)name[letterIndex]).ToString(); ++letterIndex; } else if (letterAttribute.Value == "0") { break; } else { letterAttribute.Value = "0"; } } }