Esempio n. 1
0
        public float GetDamageFactorFor(Tool tool, Pawn attacker, HediffComp_VerbGiver hediffCompSource)
        {
            float num = 1f;

            if (attacker != null)
            {
                if (hediffCompSource != null)
                {
                    num *= PawnCapacityUtility.CalculatePartEfficiency(hediffCompSource.Pawn.health.hediffSet, hediffCompSource.parent.Part, ignoreAddedParts: true);
                }
                else if (attacker != null && AdjustedLinkedBodyPartsGroup(tool) != null)
                {
                    float num2 = PawnCapacityUtility.CalculateNaturalPartsAverageEfficiency(attacker.health.hediffSet, AdjustedLinkedBodyPartsGroup(tool));
                    if (AdjustedEnsureLinkedBodyPartsGroupAlwaysUsable(tool))
                    {
                        num2 = Mathf.Max(num2, 0.4f);
                    }
                    num *= num2;
                }
                if (attacker != null && IsMeleeAttack)
                {
                    num *= attacker.ageTracker.CurLifeStage.meleeDamageFactor;
                }
            }
            return(num);
        }
Esempio n. 2
0
        public IEnumerable <Verb> GetHediffsVerbs()
        {
            int         j = 0;
            List <Verb> verbList;
            int         i;

            while (true)
            {
                if (j >= hediffs.Count)
                {
                    yield break;
                }
                HediffComp_VerbGiver vg = hediffs[j].TryGetComp <HediffComp_VerbGiver>();
                if (vg != null)
                {
                    verbList = vg.VerbTracker.AllVerbs;
                    i        = 0;
                    if (i < verbList.Count)
                    {
                        break;
                    }
                }
                j++;
            }
            yield return(verbList[i]);

            /*Error: Unable to find new state assignment for yield return*/;
        }
Esempio n. 3
0
        private void InitVerb(Verb verb, VerbProperties properties, IVerbOwner owner, Tool tool, ManeuverDef maneuver, string id)
        {
            verb.loadID    = id;
            verb.verbProps = properties;
            verb.tool      = tool;
            verb.maneuver  = maneuver;
            CompEquippable                compEquippable                = this.directOwner as CompEquippable;
            Pawn                          pawn                          = this.directOwner as Pawn;
            HediffComp_VerbGiver          hediffComp_VerbGiver          = this.directOwner as HediffComp_VerbGiver;
            Pawn_MeleeVerbs_TerrainSource pawn_MeleeVerbs_TerrainSource = this.directOwner as Pawn_MeleeVerbs_TerrainSource;

            if (compEquippable != null)
            {
                verb.ownerEquipment = compEquippable.parent;
            }
            else if (pawn != null)
            {
                verb.caster = pawn;
            }
            else if (hediffComp_VerbGiver != null)
            {
                verb.ownerHediffComp = hediffComp_VerbGiver;
                verb.caster          = hediffComp_VerbGiver.Pawn;
            }
            else if (pawn_MeleeVerbs_TerrainSource != null)
            {
                verb.terrainDef = pawn_MeleeVerbs_TerrainSource.def;
                verb.caster     = pawn_MeleeVerbs_TerrainSource.parent.Pawn;
            }
            else
            {
                Log.ErrorOnce("Couldn't find verb source", 27797477, false);
            }
            if (verb.tool != null)
            {
                if (verb.ownerEquipment != null)
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Weapon;
                }
                else if (verb.ownerHediffComp != null)
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Hediff;
                }
                else if (verb.terrainDef != null)
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Terrain;
                }
                else
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Bodypart;
                }
            }
        }
Esempio n. 4
0
 public IEnumerable <Verb> GetHediffsVerbs()
 {
     for (int i = 0; i < this.hediffs.Count; i++)
     {
         HediffComp_VerbGiver vg = this.hediffs[i].TryGetComp <HediffComp_VerbGiver>();
         if (vg != null)
         {
             List <Verb> verbList = vg.VerbTracker.AllVerbs;
             for (int j = 0; j < verbList.Count; j++)
             {
                 yield return(verbList[j]);
             }
         }
     }
 }
Esempio n. 5
0
        public IEnumerable <Verb> GetHediffsVerbs()
        {
            int j = 0;

            while (j < hediffs.Count)
            {
                HediffComp_VerbGiver hediffComp_VerbGiver = hediffs[j].TryGetComp <HediffComp_VerbGiver>();
                if (hediffComp_VerbGiver != null)
                {
                    List <Verb> verbList = hediffComp_VerbGiver.VerbTracker.AllVerbs;
                    for (int i = 0; i < verbList.Count; i++)
                    {
                        yield return(verbList[i]);
                    }
                }
                int num = j + 1;
                j = num;
            }
        }
Esempio n. 6
0
        private void InitVerb(Verb verb, VerbProperties properties, IVerbOwner owner, Tool tool, ManeuverDef maneuver, string id)
        {
            verb.loadID    = id;
            verb.verbProps = properties;
            verb.tool      = tool;
            verb.maneuver  = maneuver;
            CompEquippable       compEquippable       = this.directOwner as CompEquippable;
            Pawn                 pawn                 = this.directOwner as Pawn;
            HediffComp_VerbGiver hediffComp_VerbGiver = this.directOwner as HediffComp_VerbGiver;

            if (compEquippable != null)
            {
                verb.ownerEquipment = compEquippable.parent;
            }
            else if (pawn != null)
            {
                verb.caster = pawn;
            }
            else if (hediffComp_VerbGiver != null)
            {
                verb.ownerHediffComp = hediffComp_VerbGiver;
                verb.caster          = hediffComp_VerbGiver.Pawn;
            }
            if (verb.tool != null)
            {
                if (verb.ownerEquipment != null)
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Weapon;
                }
                else if (verb.ownerHediffComp != null)
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Hediff;
                }
                else
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Bodypart;
                }
            }
        }
Esempio n. 7
0
        public float AdjustedMeleeSelectionWeight_NewTmp(Tool tool, Pawn attacker, ThingDef equipment, ThingDef equipmentStuff, HediffComp_VerbGiver hediffCompSource, bool comesFromPawnNativeVerbs)
        {
            if (!IsMeleeAttack)
            {
                return(0f);
            }
            if (attacker != null && (int)attacker.RaceProps.intelligence < (int)minIntelligence)
            {
                return(0f);
            }
            float num  = 1f;
            float num2 = AdjustedExpectedDamageForVerbUsableInMelee_NewTmp(tool, attacker, equipment, equipmentStuff, hediffCompSource);

            if (num2 >= 0.001f || !typeof(Verb_MeleeApplyHediff).IsAssignableFrom(verbClass))
            {
                num *= num2 * num2;
            }
            num *= commonality;
            if (tool != null)
            {
                num *= tool.chanceFactor;
            }
            if (comesFromPawnNativeVerbs && (tool == null || !tool.alwaysTreatAsWeapon))
            {
                num *= 0.3f;
            }
            return(num);
        }
Esempio n. 8
0
 private float AdjustedExpectedDamageForVerbUsableInMelee_NewTmp(Tool tool, Pawn attacker, ThingDef equipment, ThingDef equipmentStuff, HediffComp_VerbGiver hediffCompSource)
 {
     if (IsMeleeAttack)
     {
         return(AdjustedMeleeDamageAmount_NewTmp(tool, attacker, equipment, equipmentStuff, hediffCompSource));
     }
     if (LaunchesProjectile && defaultProjectile != null)
     {
         return(defaultProjectile.projectile.GetDamageAmount_NewTmp(equipment, equipmentStuff));
     }
     return(0f);
 }
Esempio n. 9
0
        public float AdjustedArmorPenetration_NewTmp(Tool tool, Pawn attacker, ThingDef equipment, ThingDef equipmentStuff, HediffComp_VerbGiver hediffCompSource)
        {
            float num = tool?.armorPenetration ?? meleeArmorPenetrationBase;

            if (num < 0f)
            {
                num = AdjustedMeleeDamageAmount_NewTmp(tool, attacker, equipment, equipmentStuff, hediffCompSource) * 0.015f;
            }
            else if (equipment != null)
            {
                float statValueAbstract = equipment.GetStatValueAbstract(StatDefOf.MeleeWeapon_DamageMultiplier, equipmentStuff);
                num *= statValueAbstract;
            }
            return(num);
        }
Esempio n. 10
0
        public float AdjustedMeleeDamageAmount_NewTmp(Tool tool, Pawn attacker, ThingDef equipment, ThingDef equipmentStuff, HediffComp_VerbGiver hediffCompSource)
        {
            if (!IsMeleeAttack)
            {
                Log.ErrorOnce($"Attempting to get melee damage for a non-melee verb {this}", 26181238);
            }
            float num = tool?.AdjustedBaseMeleeDamageAmount_NewTmp(equipment, equipmentStuff, meleeDamageDef) ?? ((float)meleeDamageBaseAmount);

            if (attacker != null)
            {
                num *= GetDamageFactorFor(tool, attacker, hediffCompSource);
            }
            return(num);
        }
Esempio n. 11
0
 private float AdjustedExpectedDamageForVerbUsableInMelee(Tool tool, Pawn attacker, Thing equipment, HediffComp_VerbGiver hediffCompSource)
 {
     if (this.IsMeleeAttack)
     {
         return(this.AdjustedMeleeDamageAmount(tool, attacker, equipment, hediffCompSource));
     }
     if (this.LaunchesProjectile && this.defaultProjectile != null)
     {
         return((float)this.defaultProjectile.projectile.GetDamageAmount(equipment, null));
     }
     return(0f);
 }
Esempio n. 12
0
        public float AdjustedArmorPenetration(Tool tool, Pawn attacker, Thing equipment, HediffComp_VerbGiver hediffCompSource)
        {
            float num;

            if (tool != null)
            {
                num = tool.armorPenetration;
            }
            else
            {
                num = this.meleeArmorPenetrationBase;
            }
            if (num < 0f)
            {
                float num2 = this.AdjustedMeleeDamageAmount(tool, attacker, equipment, hediffCompSource);
                num = num2 * 0.015f;
            }
            return(num);
        }
Esempio n. 13
0
        public float AdjustedMeleeDamageAmount(Tool tool, Pawn attacker, Thing equipment, HediffComp_VerbGiver hediffCompSource)
        {
            if (!this.IsMeleeAttack)
            {
                Log.ErrorOnce(string.Format("Attempting to get melee damage for a non-melee verb {0}", this), 26181238, false);
            }
            float num;

            if (tool != null)
            {
                num = tool.AdjustedBaseMeleeDamageAmount(equipment, this.meleeDamageDef);
            }
            else
            {
                num = (float)this.meleeDamageBaseAmount;
            }
            if (attacker != null)
            {
                num *= this.GetDamageFactorFor(tool, attacker, hediffCompSource);
            }
            return(num);
        }