public void FixedUpdate()
 {
     if (Find.TickManager.TicksGame > lastTicks + 10)
     {
         lastTicks = Find.TickManager.TicksGame;
         if (reinjectNeeded)
         {
             reinjectTime -= Time.fixedDeltaTime;
             if (reinjectTime <= 0)
             {
                 reinjectTime = 0;
                 Find.Maps.ForEach(delegate(Map map)
                 {
                     map.mapPawns.AllPawnsSpawned.Where(
                         (Pawn p) => p.Name != null && p.TryGetComp <PawnComponent_Agency>() == null && p.Faction != null &&
                         p.Faction.def.defName.EqualsIgnoreCase("TheAgency")).ToList().ForEach(
                         delegate(Pawn p)
                     {
                         PawnComponent_Agency pca = new PawnComponent_Agency();
                         pca.parent = p;
                         p.AllComps.Add(pca);
                     });
                 });
             }
         }
     }
 }
Exemple #2
0
        public void FixedUpdate()
        {
            try
            {
                if (Find.TickManager == null)
                {
                    return;
                }

                if (Find.TickManager.TicksGame <= lastTicks + 10)
                {
                    return;
                }

                lastTicks     = Find.TickManager.TicksGame;
                reinjectTime -= Time.fixedDeltaTime;
                if (!(reinjectTime <= 0))
                {
                    return;
                }

                reinjectTime = 0;
                if (Find.Maps != null)
                {
                    Find.Maps.ForEach(delegate(Map map)
                    {
                        var pawns = map.mapPawns.AllPawnsSpawned.Where(p => p.Faction != null).ToList();
                        pawns.Where(p => p.Name != null && p.TryGetComp <PawnComponent_Agency>() == null &&
                                    p.Faction.def.defName.EqualsIgnoreCase("ROM_TheAgency")).ToList()
                        .ForEach(
                            delegate(Pawn p)
                        {
                            var pca = new PawnComponent_Agency
                            {
                                parent = p
                            };
                            p.AllComps.Add(pca);
                        });
                        pawns.Where(p =>
                                    p.Name != null && p.Faction.def.defName.EqualsIgnoreCase("Townsfolk") &&
                                    p.needs?.rest?.CurLevelPercentage < 40f).ToList().ForEach(
                            delegate(Pawn p) { p.needs.rest.CurLevelPercentage = 100; });
                    });
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }