Пример #1
0
        public SkyTarget CurSkyTarget(Map map)
        {
            float num  = GenCelestial.CurCelestialSunGlow(map);
            int   num2 = 0;
            int   num3 = 0;

            for (int i = 0; i < skyTargets.Length; i++)
            {
                num3 = i;
                if (num + 0.001f < skyTargets[i].celGlowThreshold)
                {
                    break;
                }
                num2 = i;
            }
            SkyThreshold skyThreshold  = skyTargets[num2];
            SkyThreshold skyThreshold2 = skyTargets[num3];
            float        num4          = skyThreshold2.celGlowThreshold - skyThreshold.celGlowThreshold;
            float        t             = (num4 != 0f) ? ((num - skyThreshold.celGlowThreshold) / num4) : 1f;
            SkyTarget    result        = default(SkyTarget);

            result.glow   = num;
            result.colors = SkyColorSet.Lerp(skyThreshold.colors, skyThreshold2.colors, t);
            if (GenCelestial.IsDaytime(num))
            {
                result.lightsourceShineIntensity = 1f;
                result.lightsourceShineSize      = 1f;
            }
            else
            {
                result.lightsourceShineIntensity = 0.7f;
                result.lightsourceShineSize      = 0.5f;
            }
            return(result);
        }
        public override string GetReport()
        {
            if (base.Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Eclipse))
            {
                return("Sunbathing");
            }
            if (base.Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Aurora))
            {
                return("Sunbathing");
            }
            float num = GenCelestial.CurCelestialSunGlow(base.Map);

            if (num < 0.1f)
            {
                return("Sunbathing");
            }
            if (num >= 0.65f)
            {
                return("Sunbathing");
            }
            if (GenLocalDate.DayPercent(this.pawn) < 0.5f)
            {
                return("Sunbathing");
            }
            return("Sunbathing");
        }
        //Sunrise is very dangerous to be out.
        public static bool IsSunRisingOrDaylight(Map m)
        {
            //If it's daylight, it's not safe.
            var curSunlight = GenCelestial.CurCelestialSunGlow(m);

            if (GenCelestial.IsDaytime(curSunlight))
            {
                return(true);
            }

            if (curSunlight > 0.01f)
            {
                var lastSunlight = 0f;
                if (!lastSunlightChecks.ContainsKey(m))
                {
                    lastSunlightChecks.Add(m, curSunlight);
                    lastSunlight = curSunlight;
                }
                else
                {
                    lastSunlight = lastSunlightChecks[m];
                }
                return(curSunlight > lastSunlight);
            }
            return(false);
        }
Пример #4
0
    public override string GetReport()
    {
        if (Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Eclipse))
        {
            return("Brrr.OohEclipse".Translate());
        }

        if (Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Aurora))
        {
            return("Brrr.OohAurora".Translate());
        }

        var num = GenCelestial.CurCelestialSunGlow(Map);

        if (num < 0.1f)
        {
            return("Brrr.OohStarGazing".Translate());
        }

        if (num >= 0.65f)
        {
            return("Brrr.OohClouds".Translate());
        }

        if (GenLocalDate.DayPercent(pawn) < 0.5f)
        {
            return("Brrr.OohSunrise".Translate());
        }

        return("Brrr.OohSunset".Translate());
    }
Пример #5
0
        public string DebugString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("SkyManager: ");
            stringBuilder.AppendLine("CurCelestialSunGlow: " + GenCelestial.CurCelestialSunGlow(Find.CurrentMap));
            stringBuilder.AppendLine("CurSkyGlow: " + CurSkyGlow.ToStringPercent());
            stringBuilder.AppendLine("CurrentSkyTarget: " + CurrentSkyTarget().ToString());
            return(stringBuilder.ToString());
        }
        //=> (GenLocalDate.HourInteger(p) >= 6 && GenLocalDate.HourInteger(p) <= 17) && !Find.World.GameConditionManager.ConditionIsActive(GameConditionDefOf.Eclipse);
        public static bool IsDaylight(Map m)
        {
            float num = GenCelestial.CurCelestialSunGlow(m);

            if (GenCelestial.IsDaytime(num) &&
                IsForcedDarknessConditionInactive(m))
            {
                return(true);
            }
            return(false);
        }
Пример #7
0
        public static float BackgroundDarkAlphaForText()
        {
            if (Find.CurrentMap == null)
            {
                return(0f);
            }
            float num  = GenCelestial.CurCelestialSunGlow(Find.CurrentMap);
            float num2 = ((Find.CurrentMap.Biome == BiomeDefOf.IceSheet) ? 1f : Mathf.Clamp01(Find.CurrentMap.snowGrid.TotalDepth / 1000f));

            return(num * num2 * 0.41f);
        }
Пример #8
0
        public static float BackgroundDarkAlphaForText()
        {
            if (Find.VisibleMap == null)
            {
                return(0f);
            }
            float num  = GenCelestial.CurCelestialSunGlow(Find.VisibleMap);
            float num2 = (float)((Find.VisibleMap.Biome != BiomeDefOf.IceSheet) ? Mathf.Clamp01((float)(Find.VisibleMap.snowGrid.TotalDepth / 1000.0)) : 1.0);

            return((float)(num * num2 * 0.40999999642372131));
        }
        /// <summary>
        /// Daylight occurs when glow levels rise above 60%.
        /// I used a stopwatch to determine the average time between
        /// the percentage raises is about 161 ticks.
        /// For instance, if the current glow is 40%, 60% - 40% = 20%.
        ///   Then 20 multiplied by 161, which yields 3220 total ticks until daylight.
        /// </summary>
        /// <param name="map"></param>
        /// <returns></returns>
        public static int DetermineTicksUntilDaylight(Map map)
        {
            int result = Int32.MaxValue;

            if (VampireUtility.IsSunRisingOrDaylight(map))
            {
                int curLightLevel      = (int)(GenCelestial.CurCelestialSunGlow(map) * 100);
                int maxLightLevel      = 60;
                int diffLightLevel     = maxLightLevel - curLightLevel;
                int ticksLeftForTravel = TicksBetweenLightChanges * diffLightLevel;
                result = ticksLeftForTravel;
            }
            return(result);
        }
Пример #10
0
 public override void GameConditionTick()
 {
     base.GameConditionTick();
     if (GenCelestial.CurCelestialSunGlow(base.SingleMap) > thresholdToEnd)
     {
         End();
     }
     foreach (Pawn pawn in map.mapPawns.AllPawns)
     {
         if (map.glowGrid.PsychGlowAt(pawn.Position) == PsychGlow.Dark)
         {
             DamagePawn(pawn);
         }
     }
 }
Пример #11
0
        public static float BackgroundDarkAlphaForText()
        {
            float result;

            if (Find.CurrentMap == null)
            {
                result = 0f;
            }
            else
            {
                float num  = GenCelestial.CurCelestialSunGlow(Find.CurrentMap);
                float num2 = (Find.CurrentMap.Biome != BiomeDefOf.IceSheet) ? Mathf.Clamp01(Find.CurrentMap.snowGrid.TotalDepth / 1000f) : 1f;
                result = num * num2 * 0.41f;
            }
            return(result);
        }
Пример #12
0
        public override void Tick()
        {
            base.Tick();

            if (active)
            {
                if (Find.TickManager.TicksGame % chargeRate == 0)
                {
                    if (!Armor.FullCharge && Armor.Wearer != null)
                    {
                        float num = GenCelestial.CurCelestialSunGlow(Armor.Wearer.Map);
                        if (GenCelestial.IsDaytime(num))
                        {
                            Armor.AddCharge(chargeNum);
                        }
                    }
                }
            }
        }
Пример #13
0
        public SkyTarget CurSkyTarget(Map map)
        {
            float num  = GenCelestial.CurCelestialSunGlow(map);
            int   num2 = 0;
            int   num3 = 0;
            int   num4 = 0;

            while (num4 < this.skyTargets.Length)
            {
                num3 = num4;
                if (!(num + 0.0010000000474974513 < this.skyTargets[num4].celGlowThreshold))
                {
                    num2 = num4;
                    num4++;
                    continue;
                }
                break;
            }
            SkyThreshold skyThreshold  = this.skyTargets[num2];
            SkyThreshold skyThreshold2 = this.skyTargets[num3];
            float        num5          = skyThreshold2.celGlowThreshold - skyThreshold.celGlowThreshold;
            float        t             = (float)((num5 != 0.0) ? ((num - skyThreshold.celGlowThreshold) / num5) : 1.0);
            SkyTarget    result        = default(SkyTarget);

            result.glow   = num;
            result.colors = SkyColorSet.Lerp(skyThreshold.colors, skyThreshold2.colors, t);
            if (GenCelestial.IsDaytime(num))
            {
                result.lightsourceShineIntensity = 1f;
                result.lightsourceShineSize      = 1f;
            }
            else
            {
                result.lightsourceShineIntensity = 0.7f;
                result.lightsourceShineSize      = 0.5f;
            }
            return(result);
        }
        public override void CompTick()
        {
            base.CompTick();
            if (!waitingForNight && this.parent.IsHashIntervalTick(Props.checkingInterval) && this.parent.Map != null &&
                (!Props.requiresTamed || (Props.requiresTamed && this.parent.Faction != null && this.parent.Faction.IsPlayer)))
            {
                IncidentDef incidentDef = IncidentDef.Named(Props.incidentToCause);

                if (incidentDef.defName == "Aurora")
                {
                    waitingForNight = true;
                }
                else
                {
                    IncidentParms parms = StorytellerUtility.DefaultParmsNow(incidentDef.category, this.parent.Map);
                    incidentDef.Worker.TryExecute(parms);
                }
            }
            if (waitingForNight && this.parent.IsHashIntervalTick(this.checkingForNightInterval) && this.parent.Map != null && GenCelestial.CurCelestialSunGlow(this.parent.Map) <= 0.4f &&
                (!Props.requiresTamed || (Props.requiresTamed && this.parent.Faction != null && this.parent.Faction.IsPlayer)))
            {
                IncidentDef   incidentDef = IncidentDef.Named(Props.incidentToCause);
                IncidentParms parms       = StorytellerUtility.DefaultParmsNow(incidentDef.category, this.parent.Map);
                incidentDef.Worker.TryExecute(parms);
                waitingForNight = false;
            }
        }
        // Token: 0x06000568 RID: 1384 RVA: 0x00035040 File Offset: 0x00033440
        public override Job TryGiveJob(Pawn pawn)
        {
            string IsCurrentWeatherClear = "Null";

            if (pawn.Map.weatherManager.curWeather != null)
            {
                IsCurrentWeatherClear = pawn.Map.weatherManager.curWeather.ToString();
            }
            if (IsCurrentWeatherClear != "Clear")
            {
                return(null);
            }
            float CurrentCelestialGlow = GenCelestial.CurCelestialSunGlow(pawn.Map);

            if (CurrentCelestialGlow <= 0.4f)
            {
                return(null);
            }

            /*
             * if (GenLocalDate.DayPercent(pawn.Map) < 0.5f)
             * {
             *  return null;
             * }
             */
            if (!JoyUtility.EnjoyableOutsideNow(pawn, null))
            {
                return(null);
            }
            if (PawnUtility.WillSoonHaveBasicNeed(pawn))
            {
                return(null);
            }
            Predicate <IntVec3> cellValidator = (IntVec3 x) => !PawnUtility.KnownDangerAt(x, pawn.Map, pawn) && !x.GetTerrain(pawn.Map).avoidWander&& x.Standable(pawn.Map) && !x.Roofed(pawn.Map);
            Predicate <Region>  validator     = delegate(Region x)
            {
                IntVec3 intVec;
                return(x.Room.PsychologicallyOutdoors && !x.IsForbiddenEntirely(pawn) && x.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out intVec));
            };
            Region reg;

            if (!CellFinder.TryFindClosestRegionWith(pawn.GetRegion(RegionType.Set_Passable), TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), validator, 100, out reg, RegionType.Set_Passable))
            {
                return(null);
            }
            IntVec3 root;

            if (!reg.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out root))
            {
                return(null);
            }
            List <IntVec3> list;

            if (!WalkPathFinder.TryFindWalkPath(pawn, root, out list))
            {
                return(null);
            }
            Job job = new Job(this.def.jobDef, list[0]);

            job.targetQueueA = new List <LocalTargetInfo>();
            for (int i = 1; i < list.Count; i++)
            {
                job.targetQueueA.Add(list[i]);
            }
            job.locomotionUrgency = LocomotionUrgency.Walk;
            return(job);
        }
Пример #16
0
 public bool IsActive(Map map)
 {
     return(map.GameConditionManager.ConditionIsActive(base.def) && GenCelestial.CurCelestialSunGlow(map) <= LightToBeActive);
 }
Пример #17
0
 private bool AuroraWillEndSoon(Map map)
 {
     return(GenCelestial.CurCelestialSunGlow(map) > 0.5f || GenCelestial.CelestialSunGlow(map, Find.TickManager.TicksAbs + 5000) > 0.5f);
 }