using System.Collections.Generic; using System.Globalization; using System.Xml.Linq; public class CanIncreaseGeneticPerkRebirth : TargetedCompareRequirementBase { public override bool IsValid(MinEventParams _params) { if (!this.ParamsValid(_params)) { return false; } bool flag = false; if (this.invert) { return !flag; } EntityPlayer primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer(); float hasShades = 0; float lvlGenetics = 0; float lvlPerk = 0; hasShades = 0; if (RebirthUtilities.HasEquippedItem(primaryPlayer as EntityPlayerLocal, shadeName)) { hasShades = 1; } lvlGenetics = RebirthVariables.localConstants["$varFuriousRamsay" + geneticName + "Lvl"]; ProgressionValue perkProgressionValue = primaryPlayer.Progression.GetProgressionValue(perkName); lvlPerk = perkProgressionValue.Level; /*Log.Out("CanIncreaseGeneticPerkRebirth-IsValid hasShades: " + hasShades); Log.Out("CanIncreaseGeneticPerkRebirth-IsValid lvlGenetics: " + lvlGenetics); Log.Out("CanIncreaseGeneticPerkRebirth-IsValid lvlPerk: " + lvlPerk); Log.Out("CanIncreaseGeneticPerkRebirth-IsValid perkIncrement: " + perkIncrement);*/ int maxLevel = perkProgressionValue.ProgressionClass.MaxLevel; if (maxLevel < 10 || (perkName == "perkMeleeDamage" || perkName == "perkDodge")) { maxLevel = maxLevel - 1; } if (maxLevel == 10 && (perkName != "perkMeleeDamage" && perkName != "perkDodge")) { maxLevel = maxLevel - 2; } if (perkProgressionValue.Level >= maxLevel) { GameManager.ShowTooltip(primaryPlayer as EntityPlayerLocal, Localization.Get("ttMaxLevelReached").Replace("{perkName}", Localization.Get(perkName + "Name")), string.Empty, "ui_denied", null); return false; } if (hasShades > 0) { //Log.Out("CanIncreaseGeneticPerkRebirth-IsValid 1"); if (lvlGenetics >= (lvlPerk * perkIncrement) + perkIncrement) { //Log.Out("CanIncreaseGeneticPerkRebirth-IsValid 2"); flag = true; } else { //Log.Out("CanIncreaseGeneticPerkRebirth-IsValid 3"); GameManager.ShowTooltip(primaryPlayer as EntityPlayerLocal, Localization.Get("tt" + geneticName + "Low"), string.Empty, "ui_denied", null); } } else { //Log.Out("CanIncreaseGeneticPerkRebirth-IsValid 4"); if (lvlGenetics >= (lvlPerk * perkIncrement) + perkIncrement) { //Log.Out("CanIncreaseGeneticPerkRebirth-IsValid 5"); flag = true; } else { //Log.Out("CanIncreaseGeneticPerkRebirth-IsValid 6"); GameManager.ShowTooltip(primaryPlayer as EntityPlayerLocal, Localization.Get("tt" + geneticName + "Low"), string.Empty, "ui_denied", null); } } return flag; } public override void GetInfoStrings(ref List list) { list.Add(string.Format("cvar.{0} {1} {2}", this.cvarName, this.operation.ToStringCached(), this.value.ToCultureInvariantString())); } public override bool ParseXAttribute(XAttribute _attribute) { string localName = _attribute.Name.LocalName; if (localName == "operation") { this.operation = EnumUtils.Parse(_attribute.Value, true); return true; } else if (localName == "value") { if (_attribute.Value.StartsWith("@")) { this.useCVar = true; this.refCvarName = _attribute.Value.Substring(1); } else { this.value = StringParsers.ParseFloat(_attribute.Value, 0, -1, NumberStyles.Any); } fullValue = _attribute.Value; return true; } else if (localName == "invert") { this.invert = StringParsers.ParseBool(_attribute.Value, 0, -1, true); return true; } else if (localName == "target") { this.targetType = EnumUtils.Parse(_attribute.Value, true); return true; } else if (localName == "cvar") { cvarName = _attribute.Value; cvarNameHash = cvarName.GetHashCode(); return true; } else if (localName == "perkColor") { perkColor = _attribute.Value; return true; } else if (localName == "perkName") { perkName = _attribute.Value; return true; } else if (localName == "geneticName") { geneticName = _attribute.Value; return true; } else if (localName == "shadeName") { shadeName = _attribute.Value; return true; } else if (localName == "perkIncrement") { perkIncrement = int.Parse(_attribute.Value); return true; } else { return false; } } protected string geneticName; protected string perkName; protected string cvarName; protected string perkColor; protected string shadeName; protected int cvarNameHash; protected int perkIncrement; protected string fullValue; }