private void AddAction() { var stat = Constants.LastEndActionClickedName.Substring(Helper.CharacterAfterString(Constants.LastEndActionClickedName, "Add")); int statId = (int)Soul.GetFieldValue(stat + "_Id"); int statLevel = (int)Soul.GetFieldValue(stat + "_Level"); int statMax = (int)Soul.GetFieldValue(stat + "_Max"); int statAdd = (int)Soul.GetFieldValue(stat + "_Add"); int statPrice = (int)Soul.GetFieldValue(stat + "_Price"); string statName = Soul.SoulStatsNames[statId]; string statDescription = Soul.SoulStatsDescriptions[statId]; string statUnit = Soul.SoulStatsUnit[statId]; var fullTitle = statName + (statLevel > 0 ? " " + statLevel.ToString() : string.Empty); var currentDescription = statDescription + MakeContent("Current:", " +" + (statAdd * statLevel) + " " + statUnit); var currentPrice = statPrice * (statLevel + 1); var negative = "Cancel"; var positive = "<material=\"LongOrange\">" + currentPrice.ToString() + "</material>"; if (statLevel == statMax || Soul.Xp < currentPrice) { negative = null; positive = "Back"; } var nextDescription = string.Empty; if (statLevel != statMax) { nextDescription += MakeContent("Next:", " +" + (statAdd * (statLevel + 1)) + " " + statUnit); } //Plural if (statUnit.Length > 3 && statUnit[0] != '<') //Check '<' because of custom materials { if (statAdd * statLevel > 1) { currentDescription += "s"; } if (statAdd * (statLevel + 1) > 1 && nextDescription != string.Empty) { nextDescription += "s"; } } Instantiator.NewPopupYesNo(fullTitle, currentDescription + nextDescription, negative, positive, AfterAddAction); object AfterAddAction(bool result) { if (result == false || statLevel == statMax || Soul.Xp < currentPrice) { return(result); } Soul.Xp -= currentPrice; var levelFieldInfo = Soul.GetType().GetField(stat + "_Level"); levelFieldInfo.SetValue(Soul, statLevel + 1); UpdateTreeDisplay(); return(result); } }