private void ChooseMeleeVerb()
        {
            List <VerbEntry> updatedAvailableVerbsList = this.GetUpdatedAvailableVerbsList();

            if (updatedAvailableVerbsList.Count == 0)
            {
                Log.ErrorOnce(string.Format("{0} has no available melee attack", this.pawn), 1664289);
                this.SetCurMeleeVerb(null);
            }
            else
            {
                VerbEntry verbEntry = updatedAvailableVerbsList.RandomElementByWeight((VerbEntry ve) => ve.SelectionWeight);
                this.SetCurMeleeVerb(verbEntry.verb);
            }
        }
        private float GetArmorPenetration(StatRequest req, bool applyPostProcess = true)
        {
            Pawn pawn = req.Thing as Pawn;

            if (pawn == null)
            {
                return(0f);
            }
            List <VerbEntry> updatedAvailableVerbsList = pawn.meleeVerbs.GetUpdatedAvailableVerbsList(terrainTools: false);

            if (updatedAvailableVerbsList.Count == 0)
            {
                return(0f);
            }
            float num = 0f;

            for (int i = 0; i < updatedAvailableVerbsList.Count; i++)
            {
                if (updatedAvailableVerbsList[i].IsMeleeAttack)
                {
                    num += updatedAvailableVerbsList[i].GetSelectionWeight(null);
                }
            }
            if (num == 0f)
            {
                return(0f);
            }
            float num2 = 0f;

            for (int j = 0; j < updatedAvailableVerbsList.Count; j++)
            {
                if (updatedAvailableVerbsList[j].IsMeleeAttack)
                {
                    float          num3       = num2;
                    float          num4       = updatedAvailableVerbsList[j].GetSelectionWeight(null) / num;
                    VerbEntry      verbEntry  = updatedAvailableVerbsList[j];
                    VerbProperties verbProps  = verbEntry.verb.verbProps;
                    VerbEntry      verbEntry2 = updatedAvailableVerbsList[j];
                    num2 = num3 + num4 * verbProps.AdjustedArmorPenetration(verbEntry2.verb, pawn);
                }
            }
            return(num2);
        }
        private float GetMeleeCooldown(StatRequest req, bool applyPostProcess = true)
        {
            Pawn pawn = req.Thing as Pawn;

            if (pawn != null)
            {
                List <VerbEntry> updatedAvailableVerbsList = pawn.meleeVerbs.GetUpdatedAvailableVerbsList();
                if (updatedAvailableVerbsList.Count == 0)
                {
                    return(1f);
                }
                float num = 0f;
                for (int i = 0; i < updatedAvailableVerbsList.Count; i++)
                {
                    if (updatedAvailableVerbsList[i].IsMeleeAttack)
                    {
                        num += updatedAvailableVerbsList[i].SelectionWeight;
                    }
                }
                float num2 = 0f;
                for (int j = 0; j < updatedAvailableVerbsList.Count; j++)
                {
                    if (updatedAvailableVerbsList[j].IsMeleeAttack)
                    {
                        VerbEntry      verbEntry      = updatedAvailableVerbsList[j];
                        ThingWithComps ownerEquipment = verbEntry.verb.ownerEquipment;
                        float          num3           = num2;
                        float          num4           = updatedAvailableVerbsList[j].SelectionWeight / num;
                        VerbEntry      verbEntry2     = updatedAvailableVerbsList[j];
                        VerbProperties verbProps      = verbEntry2.verb.verbProps;
                        VerbEntry      verbEntry3     = updatedAvailableVerbsList[j];
                        num2 = num3 + num4 * (float)verbProps.AdjustedCooldownTicks(verbEntry3.verb, pawn, ownerEquipment);
                    }
                }
                return((float)(num2 / 60.0));
            }
            return(1f);
        }
예제 #4
0
 internal float <> m__0(VerbEntry ve)
 {
     return(ve.GetSelectionWeight(this.target));
 }