Пример #1
0
        private int FreeWarmClothesSetsCount(Map map)
        {
            jackets.Clear();
            shirts.Clear();
            pants.Clear();
            List <Thing> list = map.listerThings.ThingsInGroup(ThingRequestGroup.Apparel);

            for (int i = 0; i < list.Count; i++)
            {
                if (!list[i].IsInAnyStorage() || list[i].GetStatValue(StatDefOf.Insulation_Cold) <= 0f)
                {
                    continue;
                }
                if (list[i].def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso))
                {
                    if (list[i].def.apparel.layers.Contains(ApparelLayerDefOf.OnSkin))
                    {
                        shirts.Add(list[i]);
                    }
                    else
                    {
                        jackets.Add(list[i]);
                    }
                }
                if (list[i].def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs))
                {
                    pants.Add(list[i]);
                }
            }
            jackets.Sort(SortByInsulationCold);
            shirts.Sort(SortByInsulationCold);
            pants.Sort(SortByInsulationCold);
            float num = ThingDefOf.Human.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin) - LowestTemperatureComing(map);

            if (num <= 0f)
            {
                return(GenMath.Max(jackets.Count, shirts.Count, pants.Count));
            }
            int num2 = 0;

            while (jackets.Any() || shirts.Any() || pants.Any())
            {
                float num3 = 0f;
                if (jackets.Any())
                {
                    Thing thing = jackets[jackets.Count - 1];
                    jackets.RemoveLast();
                    num3 += thing.GetStatValue(StatDefOf.Insulation_Cold);
                }
                if (num3 < num && shirts.Any())
                {
                    Thing thing2 = shirts[shirts.Count - 1];
                    shirts.RemoveLast();
                    num3 += thing2.GetStatValue(StatDefOf.Insulation_Cold);
                }
                if (num3 < num && pants.Any())
                {
                    for (int j = 0; j < pants.Count; j++)
                    {
                        float statValue = pants[j].GetStatValue(StatDefOf.Insulation_Cold);
                        if (statValue + num3 >= num)
                        {
                            num3 += statValue;
                            pants.RemoveAt(j);
                            break;
                        }
                    }
                }
                if (!(num3 >= num))
                {
                    break;
                }
                num2++;
            }
            jackets.Clear();
            shirts.Clear();
            pants.Clear();
            return(num2);
        }
Пример #2
0
        private int FreeWarmClothesSetsCount(Map map)
        {
            Alert_NeedWarmClothes.jackets.Clear();
            Alert_NeedWarmClothes.shirts.Clear();
            Alert_NeedWarmClothes.pants.Clear();
            List <Thing> list = map.listerThings.ThingsInGroup(ThingRequestGroup.Apparel);

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].IsInAnyStorage() && !(list[i].GetStatValue(StatDefOf.Insulation_Cold, true) >= 0.0))
                {
                    if (list[i].def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso))
                    {
                        if (list[i].def.apparel.layers.Contains(ApparelLayer.OnSkin))
                        {
                            Alert_NeedWarmClothes.shirts.Add(list[i]);
                        }
                        else
                        {
                            Alert_NeedWarmClothes.jackets.Add(list[i]);
                        }
                    }
                    if (list[i].def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs))
                    {
                        Alert_NeedWarmClothes.pants.Add(list[i]);
                    }
                }
            }
            Alert_NeedWarmClothes.jackets.SortByDescending((Thing x) => x.GetStatValue(StatDefOf.Insulation_Cold, true));
            Alert_NeedWarmClothes.shirts.SortByDescending((Thing x) => x.GetStatValue(StatDefOf.Insulation_Cold, true));
            Alert_NeedWarmClothes.pants.SortByDescending((Thing x) => x.GetStatValue(StatDefOf.Insulation_Cold, true));
            float num = ThingDefOf.Human.GetStatValueAbstract(StatDefOf.ComfyTemperatureMin, null) - this.LowestTemperatureComing(map);

            if (num <= 0.0)
            {
                return(GenMath.Max(Alert_NeedWarmClothes.jackets.Count, Alert_NeedWarmClothes.shirts.Count, Alert_NeedWarmClothes.pants.Count));
            }
            int num2 = 0;

            while (true)
            {
                if (!Alert_NeedWarmClothes.jackets.Any() && !Alert_NeedWarmClothes.shirts.Any() && !Alert_NeedWarmClothes.pants.Any())
                {
                    break;
                }
                float num3 = 0f;
                if (Alert_NeedWarmClothes.jackets.Any())
                {
                    Thing thing = Alert_NeedWarmClothes.jackets[Alert_NeedWarmClothes.jackets.Count - 1];
                    Alert_NeedWarmClothes.jackets.RemoveLast();
                    float num4 = (float)(0.0 - thing.GetStatValue(StatDefOf.Insulation_Cold, true));
                    num3 += num4;
                }
                if (num3 < num && Alert_NeedWarmClothes.shirts.Any())
                {
                    Thing thing2 = Alert_NeedWarmClothes.shirts[Alert_NeedWarmClothes.shirts.Count - 1];
                    Alert_NeedWarmClothes.shirts.RemoveLast();
                    float num5 = (float)(0.0 - thing2.GetStatValue(StatDefOf.Insulation_Cold, true));
                    num3 += num5;
                }
                if (num3 < num && Alert_NeedWarmClothes.pants.Any())
                {
                    for (int j = 0; j < Alert_NeedWarmClothes.pants.Count; j++)
                    {
                        float num6 = (float)(0.0 - Alert_NeedWarmClothes.pants[j].GetStatValue(StatDefOf.Insulation_Cold, true));
                        if (num6 + num3 >= num)
                        {
                            num3 += num6;
                            Alert_NeedWarmClothes.pants.RemoveAt(j);
                            break;
                        }
                    }
                }
                if (!(num3 >= num))
                {
                    break;
                }
                num2++;
            }
            return(num2);
        }