Пример #1
0
        public override void TransformValue(StatRequest req, ref float val)
        {
            if (req.HasThing && req.Thing.TryGetComp <CompWeapon_GunSpecialRules>() != null)
            {
                CompWeapon_GunSpecialRules gun = req.Thing.TryGetComp <CompWeapon_GunSpecialRules>();
                string reliabilityString;
                float  jamsOn;
                GetReliability(gun, out reliabilityString, out jamsOn);
                this.parentStat.formatString = reliabilityString;
                switch (reliabilityString)
                {
                case "Unreliable":
                    this.parentStat.description = "This gun is unreliable in combat and can fail easily.";
                    break;

                case "Standard":
                    this.parentStat.description = "This gun is reliable in combat but can occationally fail.";
                    break;

                case "Very Reliable":
                    this.parentStat.description = "This gun is very reliable in combat and tends not to fail.";
                    break;

                case "Extremely Reliable":
                    this.parentStat.description = "This gun is extremely reliable in combat and tends not to fail.";
                    break;

                default:
                    return;
                }
                val *= jamsOn;
            }
        }
Пример #2
0
        /// <summary>
        /// Calculates the chance that the gun will jam
        /// </summary>
        /// <param name="gun">The gun object</param>
        /// <returns>floating point number representing the jam chance</returns>
        public static float JamChance(CompWeapon_GunSpecialRules gun)
        {
            float result = 0f;

            switch (gun.reliability)
            {
            case Reliability.UR:
                result = 50f;
                break;

            case Reliability.ST:
                result = 30f;
                break;

            case Reliability.VR:
                result = 10f;
                break;

            default:
                return(0);
            }
            //    Log.Message(string.Format("result {0}", result));
            result += GetQualityFactor(gun.parent);
            //    Log.Message(string.Format("result {0}", result));
            result = result * 100 / gun.parent.HitPoints / 100;
            //    Log.Message(string.Format("result {0}", result));
            result = (float)(Math.Truncate((double)result * 100.0) / 100.0);
            //    Log.Message(string.Format("result {0}", result));
            return(result);
        }
Пример #3
0
        public override void ExposeData()
        {
            base.ExposeData();
            Scribe_Values.Look <int>(ref beamColorIndex, "beamColorIndex", -1, false);
            if (GetComp <CompWeapon_GunSpecialRules>() != null)
            {
                CompWeapon_GunSpecialRules specialRules = GetComp <CompWeapon_GunSpecialRules>();
                if (specialRules.GetsHot || specialRules.Jams)
                {
                    string reliabilityString;
                    float  jamsOn;
                    StatPart_Reliability.GetReliability(GetComp <CompWeapon_GunSpecialRules>(), out reliabilityString, out jamsOn);

                    Scribe_Values.Look <string>(ref reliabilityString, "reliability", "NA", false);
                }
            }
            if (GetComp <CompWeapon_GunSpecialRules>() != null)
            {
                CompWeapon_GunSpecialRules specialRules = GetComp <CompWeapon_GunSpecialRules>();
                if (specialRules.GetsHot || specialRules.Jams)
                {
                    string reliabilityString;
                    float  jamsOn;
                    StatPart_Reliability.GetReliability(GetComp <CompWeapon_GunSpecialRules>(), out reliabilityString, out jamsOn);

                    Scribe_Values.Look <string>(ref reliabilityString, "reliability", "NA", false);
                }
            }
        }
Пример #4
0
        /*
         * public override void Tick()
         * {
         *  base.Tick();
         *  CompWargearWeaponSecondry comp = base.GetComp<CompWargearWeaponSecondry>();
         *  if (comp != null)
         *  {
         *      comp.CompTick();
         *  }
         * }
         */
        public override string GetInspectString()
        {
            string result = base.GetInspectString();

            if (GetComp <CompWeapon_GunSpecialRules>() != null)
            {
                CompWeapon_GunSpecialRules specialRules = GetComp <CompWeapon_GunSpecialRules>();
                if (specialRules.GetsHot || specialRules.Jams)
                {
                    string reliabilityString;
                    float  jamsOn;
                    StatPart_Reliability.GetReliability(GetComp <CompWeapon_GunSpecialRules>(), out reliabilityString, out jamsOn);
                    string cause  = specialRules.GetsHot ? "Overheat" : "Jam";
                    float  chance = specialRules.GetsHot ? jamsOn / 10 : jamsOn / 100;
                    result += string.Format("\r\nReliability: {0}\r\n" + cause + " chance: {1}", reliabilityString, chance.ToStringPercent());
                }
            }
            return(result);
        }
Пример #5
0
 public static void GetReliability(CompWeapon_GunSpecialRules gun, out string rel, out float jamsOn)
 {
     rel    = string.Empty;
     jamsOn = JamChance(gun);
     if (jamsOn < 0.25)
     {
         rel = "Extremely Reliable";
     }
     else if (jamsOn < 0.5)
     {
         rel = "Very Reliable";
     }
     else if (jamsOn < 1)
     {
         rel = "Standard";
     }
     else
     {
         rel = "Unreliable";
     }
 }