public override void TransformValue(StatRequest req, ref float val) { try { if (req.HasThing) { Pawn pawn = req.Thing as Pawn; if (pawn != null && pawn.equipment.Primary != null && pawn.equipment.Primary.def.weaponTags != null) { if (pawn.equipment.Primary.def.weaponTags.Contains("NegativeRecoil")) { CompBuffManager compBuffManager = pawn.equipment.Primary.GetComp <CompBuffManager>(); if (compBuffManager != null) { NegativeRecoilBuff buff = compBuffManager.FindWithTags(new List <string> { "NegativeRecoil", "Pawn" }) as NegativeRecoilBuff; if (buff != null) { float additionalVal = Mathf.Pow(buff.AdditionalAccuracy, buff.CurrentOverlapLevel); val += (additionalVal - 1); } } } } } } catch { if (req.HasThing) { Log.Error("StatPart_AdditionalPawnAccuracy.TransformValue() Fail from :" + req.Thing.ToString()); } } }
public override string ExplanationPart(StatRequest req) { try { if (req.HasThing) { Pawn pawn = req.Thing as Pawn; if (pawn != null && pawn.equipment.Primary != null && pawn.equipment.Primary.def.weaponTags != null) { if (pawn.equipment.Primary.def.weaponTags.Contains("NegativeRecoil")) { CompBuffManager compBuffManager = pawn.equipment.Primary.GetComp <CompBuffManager>(); if (compBuffManager != null) { NegativeRecoilBuff buff = compBuffManager.FindWithTags(new List <string> { "NegativeRecoil", "Pawn" }) as NegativeRecoilBuff; if (buff != null) { string text = "StatReport_AdditionalPawnAccuracy".Translate() + ": +" + (Mathf.Pow(buff.AdditionalAccuracy, buff.CurrentOverlapLevel) - 1).ToStringPercent(); return(text); } } } } } } catch { if (req.HasThing) { Log.Error(parentStat.defName + " - " + req.Thing.ToString() + " ExplanationPart"); } else { Log.Error(parentStat.defName + " - " + " ExplanationPart"); } } return(string.Empty); }
public override void TransformValue(StatRequest req, ref float val) { try { if (req.HasThing) { if (req.Thing.def.weaponTags != null) { if (req.Thing.def.weaponTags.Contains("NegativeRecoil")) { ThingWithComps weaponThing = req.Thing as ThingWithComps; if (weaponThing != null) { CompBuffManager buffComp = weaponThing.GetComp <CompBuffManager>(); if (buffComp != null) { NegativeRecoilBuff buff = buffComp.FindWithTags(new List <string> { "NegativeRecoil", "Weapon" }) as NegativeRecoilBuff; if (buff != null) { float additionalVal = Mathf.Pow(buff.AdditionalAccuracy, buff.CurrentOverlapLevel); val += (additionalVal - 1); } } } } } } } catch (Exception ee) { if (req.HasThing) { Log.Error("StatPart_AdditionalWeaponAccuracy.TransformValue() Fail from :" + req.Thing.ToString() + ": " + ee); } } }
public override string ExplanationPart(StatRequest req) { if (req.HasThing) { try { if (req.Thing.def.weaponTags != null) { if (req.Thing.def.weaponTags.Contains("NegativeRecoil")) { ThingWithComps weaponThing = req.Thing as ThingWithComps; if (weaponThing != null) { CompBuffManager buffComp = weaponThing.GetComp <CompBuffManager>(); if (buffComp != null) { NegativeRecoilBuff buff = buffComp.FindWithTags(new List <string> { "NegativeRecoil", "Weapon" }) as NegativeRecoilBuff; if (buff != null) { string text = "StatReport_AdditionalWeaponAccuracy".Translate() + ": +" + (Mathf.Pow(buff.AdditionalAccuracy, buff.CurrentOverlapLevel) - 1).ToStringPercent(); return(text); } } } } } } catch (Exception ee) { Log.Error(parentStat.defName + " - " + req.Thing.ToString() + " ExplanationPart :" + ee.ToString()); } } return(string.Empty); }