コード例 #1
0
 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());
         }
     }
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        protected override bool TryCastShot()
        {
            bool result = base.TryCastShot();

            try
            {
                if (compBuffM == null)
                {
                    compBuffM  = EquipmentSource.GetComp <CompBuffManager>();
                    properties = (NegativeRecoilProperties)verbProps;
                }
                NegativeRecoilBuff nRWBuff = compBuffM.FindWithDef(properties.weaponBuffDef) as NegativeRecoilBuff;
                NegativeRecoilBuff nRPBuff = compBuffM.FindWithDef(properties.pawnBuffDef) as NegativeRecoilBuff;
                //네거티브 리코일 버프가 없다면
                if (nRWBuff == null)
                {
                    compBuffM.AddBuff(properties.weaponBuffDef, EquipmentSource);
                }
                else
                {
                    nRWBuff.AddOverlapLevel(1);
                }

                if (nRPBuff == null)
                {
                    compBuffM.AddBuff(properties.pawnBuffDef, EquipmentSource);
                }
                else
                {
                    nRPBuff.AddOverlapLevel(1);
                }
            }
            catch (Exception ee)
            {
                Log.Error("Error : " + ee.ToString());
            }

            return(result);
        }
コード例 #4
0
 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);
         }
     }
 }
コード例 #5
0
 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);
 }