Пример #1
0
        private Map MapLowInsulin()
        {
            List <Map> maps = Find.Maps;

            for (int i = 0; i < maps.Count; i++)
            {
                Map      map = maps[i];
                ThingDef def = TypeGetter.ThingDef(EThingDef.Insulin);
                if (map.IsPlayerHome && map.mapPawns.AnyColonistSpawned)
                {
                    int totalInsuline = map.spawnedThings.TotalStackCountOfDef(def);

                    if (totalInsuline == 0)
                    {
                        return(null);
                    }

                    totalInsuline -= GetTotalDiabetics(map) * InsulinThreshold;

                    if (totalInsuline < 0)
                    {
                        return(map);
                    }
                }
            }
            return(null);
        }
        public static Thing FindNextInsulin(Pawn pawn)
        {
            Thing insulin = FindInInventory(pawn.inventory.innerContainer);

            if (insulin != null)
            {
                return(insulin);
            }

            List <Thing> candidates = new List <Thing>();

            candidates.AddRange(pawn.Map.listerThings.ThingsOfDef(TypeGetter.ThingDef(EThingDef.Insulin)));
            for (int i = 0; i < candidates.Count; i++)
            {
                Thing thing = candidates[i];
                if (thing.IsForbidden(pawn))
                {
                    candidates.Remove(thing);
                    i--;
                }
            }
            Log.Message("Count: " + candidates.Count);
            if (candidates.Count == 0)
            {
                return(null);
            }

            insulin = GenClosest.ClosestThing_Global_Reachable(pawn.Position, pawn.Map, candidates,
                                                               PathEndMode.OnCell, TraverseParms.For(pawn));

            return(insulin);
        }
Пример #3
0
        public override TaggedString GetExplanation()
        {
            Map map = this.MapLowInsulin();

            if (map == null)
            {
                return("");
            }

            int totalInsulin   = map.resourceCounter.GetCount(TypeGetter.ThingDef(EThingDef.Insulin));
            int totalDiabetics = GetTotalDiabetics(map);

            return("LowInsulinDesc".Translate(totalInsulin.ToStringCached(), totalDiabetics.ToStringCached()));
        }