Ejemplo n.º 1
0
        public static float CalculateTagEfficiency(HediffSet diffSet, BodyPartTagDef tag, float maximum = 3.40282347E+38f, FloatRange lerp = default(FloatRange), List <PawnCapacityUtility.CapacityImpactor> impactors = null, float bestPartEfficiencySpecialWeight = -1f)
        {
            BodyDef body = diffSet.pawn.RaceProps.body;
            float   num  = 0f;
            int     num2 = 0;
            float   num3 = 0f;
            List <PawnCapacityUtility.CapacityImpactor> list = null;

            foreach (BodyPartRecord current in body.GetPartsWithTag(tag))
            {
                BodyPartRecord part = current;
                List <PawnCapacityUtility.CapacityImpactor> impactors2 = list;
                float num4 = PawnCapacityUtility.CalculatePartEfficiency(diffSet, part, false, impactors2);
                if (impactors != null && num4 != 1f && list == null)
                {
                    list       = new List <PawnCapacityUtility.CapacityImpactor>();
                    part       = current;
                    impactors2 = list;
                    PawnCapacityUtility.CalculatePartEfficiency(diffSet, part, false, impactors2);
                }
                num += num4;
                num3 = Mathf.Max(num3, num4);
                num2++;
            }
            if (num2 == 0)
            {
                return(1f);
            }
            float num5;

            if (bestPartEfficiencySpecialWeight >= 0f && num2 >= 2)
            {
                num5 = num3 * bestPartEfficiencySpecialWeight + (num - num3) / (float)(num2 - 1) * (1f - bestPartEfficiencySpecialWeight);
            }
            else
            {
                num5 = num / (float)num2;
            }
            float num6 = num5;

            if (lerp != default(FloatRange))
            {
                num6 = lerp.LerpThroughRange(num6);
            }
            num6 = Mathf.Min(num6, maximum);
            if (impactors != null && list != null && (maximum != 1f || num5 <= 1f || num6 == 1f))
            {
                impactors.AddRange(list);
            }
            return(num6);
        }
        public static float CalculateTagEfficiency(HediffSet diffSet, BodyPartTagDef tag, float maximum = 3.40282347E+38f, FloatRange lerp = default(FloatRange), List <PawnCapacityUtility.CapacityImpactor> impactors = null)
        {
            BodyDef body = diffSet.pawn.RaceProps.body;
            float   num  = 0f;
            int     num2 = 0;
            List <PawnCapacityUtility.CapacityImpactor> list = null;

            foreach (BodyPartRecord bodyPartRecord in body.GetPartsWithTag(tag))
            {
                BodyPartRecord part = bodyPartRecord;
                List <PawnCapacityUtility.CapacityImpactor> impactors2 = list;
                float num3 = PawnCapacityUtility.CalculatePartEfficiency(diffSet, part, false, impactors2);
                if (impactors != null && num3 != 1f && list == null)
                {
                    list       = new List <PawnCapacityUtility.CapacityImpactor>();
                    part       = bodyPartRecord;
                    impactors2 = list;
                    PawnCapacityUtility.CalculatePartEfficiency(diffSet, part, false, impactors2);
                }
                num += num3;
                num2++;
            }
            float result;

            if (num2 == 0)
            {
                result = 1f;
            }
            else
            {
                float num4 = num / (float)num2;
                float num5 = num4;
                if (lerp != default(FloatRange))
                {
                    num5 = lerp.LerpThroughRange(num5);
                }
                num5 = Mathf.Min(num5, maximum);
                if (impactors != null && list != null && (maximum != 1f || num4 <= 1f || num5 == 1f))
                {
                    impactors.AddRange(list);
                }
                result = num5;
            }
            return(result);
        }
Ejemplo n.º 3
0
        public static float CalculateTagEfficiency(HediffSet diffSet, BodyPartTagDef tag, float maximum = float.MaxValue, FloatRange lerp = default(FloatRange), List <CapacityImpactor> impactors = null, float bestPartEfficiencySpecialWeight = -1f)
        {
            BodyDef body                 = diffSet.pawn.RaceProps.body;
            float   totalEfficiency      = 0f;
            int     partCount            = 0;
            float   bestPartEfficiency   = 0f;
            List <CapacityImpactor> list = null;

            foreach (BodyPartRecord item in body.GetPartsWithTag(tag))
            {
                BodyPartRecord          part       = item;
                List <CapacityImpactor> impactors2 = list;
                float partEfficiency = CalculatePartEfficiency(diffSet, part, ignoreAddedParts: false, impactors2);
                if (impactors != null && partEfficiency != 1f && list == null)
                {
                    list       = new List <CapacityImpactor>();
                    part       = item;
                    impactors2 = list;
                    CalculatePartEfficiency(diffSet, part, ignoreAddedParts: false, impactors2);
                }
                totalEfficiency   += partEfficiency;
                bestPartEfficiency = Mathf.Max(bestPartEfficiency, partEfficiency);
                partCount++;
            }
            if (partCount == 0)
            {
                return(1f);
            }
            float weightedEfficiency = (!(bestPartEfficiencySpecialWeight >= 0f) || partCount < 2) ? (totalEfficiency / (float)partCount) : (bestPartEfficiency * bestPartEfficiencySpecialWeight + (totalEfficiency - bestPartEfficiency) / (float)(partCount - 1) * (1f - bestPartEfficiencySpecialWeight));
            float num6 = weightedEfficiency;

            if (lerp != default(FloatRange))
            {
                num6 = lerp.LerpThroughRange(num6);
            }
            num6 = Mathf.Min(num6, maximum);
            if (impactors != null && list != null && (maximum != 1f || weightedEfficiency <= 1f || num6 == 1f))
            {
                impactors.AddRange(list);
            }
            return(num6);
        }
Ejemplo n.º 4
0
        public static float CalculateTagEfficiency(HediffSet diffSet, BodyPartTagDef tag, float maximum = float.MaxValue, FloatRange lerp = default(FloatRange), List <CapacityImpactor> impactors = null, float bestPartEfficiencySpecialWeight = -1f)
        {
            BodyDef body = diffSet.pawn.RaceProps.body;
            float   num  = 0f;
            int     num2 = 0;
            float   num3 = 0f;
            List <CapacityImpactor> list = null;

            foreach (BodyPartRecord item in body.GetPartsWithTag(tag))
            {
                float num4 = CalculatePartEfficiency(diffSet, item, ignoreAddedParts: false, list);
                if (impactors != null && num4 != 1f && list == null)
                {
                    list = new List <CapacityImpactor>();
                    CalculatePartEfficiency(diffSet, item, ignoreAddedParts: false, list);
                }
                num += num4;
                num3 = Mathf.Max(num3, num4);
                num2++;
            }
            if (num2 == 0)
            {
                return(1f);
            }
            float num5 = ((!(bestPartEfficiencySpecialWeight >= 0f) || num2 < 2) ? (num / (float)num2) : (num3 * bestPartEfficiencySpecialWeight + (num - num3) / (float)(num2 - 1) * (1f - bestPartEfficiencySpecialWeight)));
            float num6 = num5;

            if (lerp != default(FloatRange))
            {
                num6 = lerp.LerpThroughRange(num6);
            }
            num6 = Mathf.Min(num6, maximum);
            if (impactors != null && list != null && (maximum != 1f || num5 <= 1f || num6 == 1f))
            {
                impactors.AddRange(list);
            }
            return(num6);
        }
Ejemplo n.º 5
0
        public override void Spawn(Map map, Vector3 origin)
        {
            for (int i = 0; i < moteCount; i++)
            {
                MoteThrown moteThrown = ThingMaker.MakeThing(mote, null) as MoteThrown;
                if (moteThrown == null)
                {
                    return;
                }

                float   angle = Rand.Range(0f, 360f);
                Vector3 dir   = new Vector3(1f, 0f, 0f).RotatedBy(angle);

                float magnitude   = Rand.Range(0f, 1f);
                float actualScale = scale.LerpThroughRange(magnitude);
                moteThrown.exactPosition = origin + dir * radius.LerpThroughRange(magnitude);
                moteThrown.exactRotation = angle + 90;
                moteThrown.exactScale    = new Vector3(actualScale, actualScale, actualScale);
                moteThrown.SetVelocity(angle + 90, magnitude * speed);
                GenSpawn.Spawn(moteThrown, origin.ToIntVec3(), map, WipeMode.Vanish);
                moteThrown.spawnTick -= (int)(magnitude * 0.75f * (mote.mote.fadeOutTime * 60));
            }
        }