//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);
        }
Пример #2
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);
        }
        //=> (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);
        }
Пример #4
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);
                        }
                    }
                }
            }
        }
Пример #5
0
        private static ThingDef ResolveSpawner(IncidentParms parms)
        {
            Map iwMap      = (Map)parms.target;
            var abberation = (GenCelestial.IsDaytime(GenCelestial.CelestialSunGlow(iwMap, Find.TickManager.TicksAbs)))
                ? MonsterDefOf.ROM_StarVampireSpawnerAbberation
                : MonsterDefOf.ROM_StarVampireSpawnerNight;

            var chance = Rand.Value;

            if (chance > 0.3)
            {
                return(MonsterDefOf.ROM_StarVampireSpawner);
            }
            else if (chance > 0.05)
            {
                return(abberation);
            }
            else
            {
                return(MonsterDefOf.ROM_StarVampireSpawnerAlbino);
            }
        }
        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);
        }