예제 #1
0
        /// <summary>
        /// Checks the light level at a pawn or their caravan.
        /// </summary>
        /// <returns>The light level.</returns>
        private float CheckLightLevel()
        {
            if (pawn.Spawned)
            {
                return(pawn.Map.glowGrid.GameGlowAt(pawn.Position));
            }
            else if (pawn.CarriedBy != null)
            {
                return(pawn.CarriedBy.Map.glowGrid.GameGlowAt(pawn.CarriedBy.Position));
            }
            else if (pawn.ParentHolder != null && pawn.ParentHolder is Caravan caravan)
            {
                var time = GenDate.HourFloat(GenTicks.TicksAbs, Find.WorldGrid.LongLatOf(caravan.Tile).x);

                if (time > 19 || time < 5)
                {
                    return(0f);                       // Night
                }
                else if (time > 18 || time < 6)
                {
                    return(0.5f);                            // Dusk/Dawn
                }
                else
                {
                    return(1f); // Day
                }
            }

            return(0.5f);
        }
        public static bool WouldBeRestingAt(int tile, long ticksAbs)
        {
            Vector2 vector = Find.WorldGrid.LongLatOf(tile);
            float   num    = GenDate.HourFloat(ticksAbs, vector.x);

            return(num < 6.0 || num > 22.0);
        }
 //Caravan
 public static void get_Resting_Vampires(Caravan __instance, ref bool __result)
 {
     if (__instance.PawnsListForReading.Any(x => x.IsVampire()))
     {
         float num = GenDate.HourFloat((long)GenTicks.TicksAbs, Find.WorldGrid.LongLatOf(__instance.Tile).x);
         __result = num >= 6f && num <= 17f;
     }
 }
예제 #4
0
        public static bool RestingNowAtImproved(int tile)
        {
            float num = GenDate.HourFloat(GenTicks.TicksAbs, Find.WorldGrid.LongLatOf(tile).x);

            if (!(num < 4f))
            {
                return(num > 23.5f);
            }
            return(true);
        }
        public static int LeftNonRestTicksAt(int tile, long ticksAbs)
        {
            if (WouldBeRestingAt(tile, ticksAbs))
            {
                return(0);
            }
            float num = GenDate.HourFloat(ticksAbs, Find.WorldGrid.LongLatOf(tile).x);

            return(Mathf.CeilToInt((22f - num) * 2500f));
        }
        public static bool WouldBeRestingAt(int tile, long ticksAbs)
        {
            float num = GenDate.HourFloat(ticksAbs, Find.WorldGrid.LongLatOf(tile).x);

            if (!(num < 6f))
            {
                return(num > 22f);
            }
            return(true);
        }
        public static int LeftNonRestTicksAt(int tile, long ticksAbs)
        {
            if (CaravanRestUtility.WouldBeRestingAt(tile, ticksAbs))
            {
                return(0);
            }
            Vector2 vector = Find.WorldGrid.LongLatOf(tile);
            float   num    = GenDate.HourFloat(ticksAbs, vector.x);

            return(Mathf.CeilToInt((float)((22.0 - num) * 2500.0)));
        }
예제 #8
0
        public static int LeftRestTicksAt(int tile, long ticksAbs)
        {
            if (!CaravanRestUtility.WouldBeRestingAt(tile, ticksAbs))
            {
                return(0);
            }
            float num = GenDate.HourFloat(ticksAbs, Find.WorldGrid.LongLatOf(tile).x);

            if (num < 6f)
            {
                return(Mathf.CeilToInt((6f - num) * 2500f));
            }
            return(Mathf.CeilToInt((24f - num + 6f) * 2500f));
        }
예제 #9
0
        public static int LeftNonRestTicksAt(int tile, long ticksAbs)
        {
            int result;

            if (CaravanRestUtility.WouldBeRestingAt(tile, ticksAbs))
            {
                result = 0;
            }
            else
            {
                float num = GenDate.HourFloat(ticksAbs, Find.WorldGrid.LongLatOf(tile).x);
                result = Mathf.CeilToInt((22f - num) * 2500f);
            }
            return(result);
        }
예제 #10
0
        //Caravan
        public static bool get_Resting_Vampires(Caravan __instance, ref bool __result)
        {
            int countNonVampHumanoids = __instance.PawnsListForReading.Count(x => !x.NonHumanlikeOrWildMan() && !x.IsVampire());
            int countVampHumanoids    = __instance.PawnsListForReading.Count(x => !x.NonHumanlikeOrWildMan() && x.IsVampire());

            //In a mixed caravan, pawns can travel during the day.
            if (countNonVampHumanoids >= countVampHumanoids)
            {
                return(true);
            }

            //In a vampire only caravan, they can travel only at night.
            float num = GenDate.HourFloat((long)GenTicks.TicksAbs, Find.WorldGrid.LongLatOf(__instance.Tile).x);

            __result = num >= 6f && num <= 17f;
            return(false);
        }