Ejemplo n.º 1
0
        public static LightInfo GetLightSourceInfo(Map map, LightType type)
        {
            float num = GenLocalDate.DayPercent(map);
            bool  flag;
            float intensity;

            switch (type)
            {
            case LightType.Shadow:
                flag      = IsDaytime(CurCelestialSunGlow(map));
                intensity = CurShadowStrength(map);
                break;

            case LightType.LightingSun:
                flag      = true;
                intensity = Mathf.Clamp01((CurCelestialSunGlow(map) - 0.6f + 0.2f) / 0.15f);
                break;

            case LightType.LightingMoon:
                flag      = false;
                intensity = Mathf.Clamp01((0f - (CurCelestialSunGlow(map) - 0.6f - 0.2f)) / 0.15f);
                break;

            default:
                Log.ErrorOnce("Invalid light type requested", 64275614);
                flag      = true;
                intensity = 0f;
                break;
            }
            float t;
            float num2;
            float num3;

            if (flag)
            {
                t    = num;
                num2 = -1.5f;
                num3 = 15f;
            }
            else
            {
                t    = ((!(num > 0.5f)) ? (0.5f + Mathf.InverseLerp(0f, 0.5f, num) * 0.5f) : (Mathf.InverseLerp(0.5f, 1f, num) * 0.5f));
                num2 = -0.9f;
                num3 = 15f;
            }
            float     num4   = Mathf.LerpUnclamped(0f - num3, num3, t);
            float     y      = num2 - 2.5f * (num4 * num4 / 100f);
            LightInfo result = default(LightInfo);

            result.vector    = new Vector2(num4, y);
            result.intensity = intensity;
            return(result);
        }
Ejemplo n.º 2
0
        private float LowestTemperatureComing(Map map)
        {
            Twelfth twelfth = GenLocalDate.Twelfth(map);
            float   a       = GetTemperature(twelfth, map);

            for (int i = 0; i < 3; i++)
            {
                twelfth = twelfth.NextTwelfth();
                a       = Mathf.Min(a, GetTemperature(twelfth, map));
            }
            return(Mathf.Min(a, map.mapTemperature.OutdoorTemp));
        }
Ejemplo n.º 3
0
        public override void Generate(Map map)
        {
            int num = 0;

            for (int i = (int)(GenLocalDate.Twelfth(map) - Twelfth.Third); i <= (int)GenLocalDate.Twelfth(map); i++)
            {
                int num2 = i;
                if (num2 < 0)
                {
                    num2 += 12;
                }
                Twelfth twelfth = (Twelfth)num2;
                float   num3    = GenTemperature.AverageTemperatureAtTileForTwelfth(map.Tile, twelfth);
                if (num3 < 0f)
                {
                    num++;
                }
            }
            float num4 = 0f;

            switch (num)
            {
            case 0:
                return;

            case 1:
                num4 = 0.3f;
                break;

            case 2:
                num4 = 0.7f;
                break;

            case 3:
                num4 = 1f;
                break;
            }
            if (map.mapTemperature.SeasonalTemp > 0f)
            {
                num4 *= 0.4f;
            }
            if ((double)num4 < 0.3)
            {
                return;
            }
            foreach (IntVec3 current in map.AllCells)
            {
                if (!current.Roofed(map))
                {
                    map.steadyAtmosphereEffects.AddFallenSnowAt(current, num4);
                }
            }
        }
Ejemplo n.º 4
0
        public override void Generate(Map map, GenStepParams parms)
        {
            int num = 0;

            for (int i = (int)(GenLocalDate.Twelfth(map) - 2); i <= (int)GenLocalDate.Twelfth(map); i++)
            {
                int num2 = i;
                if (num2 < 0)
                {
                    num2 += 12;
                }
                Twelfth twelfth = (Twelfth)num2;
                float   num3    = GenTemperature.AverageTemperatureAtTileForTwelfth(map.Tile, twelfth);
                if (num3 < 0f)
                {
                    num++;
                }
            }
            float num4 = 0f;

            switch (num)
            {
            case 0:
                return;

            case 1:
                num4 = 0.3f;
                break;

            case 2:
                num4 = 0.7f;
                break;

            case 3:
                num4 = 1f;
                break;
            }
            if (map.mapTemperature.SeasonalTemp > 0f)
            {
                num4 *= 0.4f;
            }
            if (!((double)num4 < 0.3))
            {
                foreach (IntVec3 allCell in map.AllCells)
                {
                    if (!allCell.Roofed(map))
                    {
                        map.steadyEnvironmentEffects.AddFallenSnowAt(allCell, num4);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private static NeededWarmth ApparelWarmthNeededNow(Pawn pawn, PawnGenerationRequest request, out float mapTemperature)
        {
            int tile = request.Tile;

            if (tile == -1)
            {
                Map anyPlayerHomeMap = Find.AnyPlayerHomeMap;
                if (anyPlayerHomeMap != null)
                {
                    tile = anyPlayerHomeMap.Tile;
                }
            }
            NeededWarmth result;

            if (tile == -1)
            {
                mapTemperature = 21f;
                result         = NeededWarmth.Any;
            }
            else
            {
                NeededWarmth neededWarmth = NeededWarmth.Any;
                Twelfth      twelfth      = GenLocalDate.Twelfth(tile);
                mapTemperature = GenTemperature.AverageTemperatureAtTileForTwelfth(tile, twelfth);
                for (int i = 0; i < 2; i++)
                {
                    NeededWarmth neededWarmth2 = PawnApparelGenerator.CalculateNeededWarmth(pawn, tile, twelfth);
                    if (neededWarmth2 != NeededWarmth.Any)
                    {
                        neededWarmth = neededWarmth2;
                        break;
                    }
                    twelfth = twelfth.NextTwelfth();
                }
                if (pawn.kindDef.apparelIgnoreSeasons)
                {
                    if (request.ForceAddFreeWarmLayerIfNeeded && neededWarmth == NeededWarmth.Warm)
                    {
                        result = neededWarmth;
                    }
                    else
                    {
                        result = NeededWarmth.Any;
                    }
                }
                else
                {
                    result = neededWarmth;
                }
            }
            return(result);
        }
Ejemplo n.º 6
0
        public void RecalculateAllowed()
        {
            float num = GenLocalDate.DayPercent(base.parent);

            if (this.Props.startTime <= this.Props.endTime)
            {
                this.Allowed = (num > this.Props.startTime && num < this.Props.endTime);
            }
            else
            {
                this.Allowed = (num <this.Props.endTime || num> this.Props.startTime);
            }
        }
Ejemplo n.º 7
0
        public void RecalculateAllowed()
        {
            float num = GenLocalDate.DayPercent(parent);

            if (Props.startTime <= Props.endTime)
            {
                Allowed = num > Props.startTime && num < Props.endTime;
            }
            else
            {
                Allowed = num <Props.endTime || num> Props.startTime;
            }
        }
Ejemplo n.º 8
0
        public static int DayOfYear(Thing thing)
        {
            int result;

            if (Current.ProgramState == ProgramState.Playing)
            {
                result = GenDate.DayOfYear((long)GenLocalDate.TicksAbs, GenLocalDate.LongitudeForDate(thing));
            }
            else
            {
                result = 0;
            }
            return(result);
        }
Ejemplo n.º 9
0
        public static int Year(Map map)
        {
            int result;

            if (Current.ProgramState != ProgramState.Playing)
            {
                result = 5500;
            }
            else
            {
                result = GenLocalDate.Year(map.Tile);
            }
            return(result);
        }
        public override float ValueFor(Sample samp)
        {
            float result;

            if (Find.CurrentMap == null)
            {
                result = 0f;
            }
            else
            {
                result = GenLocalDate.HourFloat(Find.CurrentMap);
            }
            return(result);
        }
        private bool AppropriateNow(SongDef song)
        {
            if (!song.playOnMap)
            {
                return(false);
            }
            if (this.DangerMusicMode)
            {
                if (!song.tense)
                {
                    return(false);
                }
            }
            else if (song.tense)
            {
                return(false);
            }
            Map map = Find.AnyPlayerHomeMap ?? Find.CurrentMap;

            if (!song.allowedSeasons.NullOrEmpty <Season>())
            {
                if (map == null)
                {
                    return(false);
                }
                if (!song.allowedSeasons.Contains(GenLocalDate.Season(map)))
                {
                    return(false);
                }
            }
            if (this.recentSongs.Contains(song))
            {
                return(false);
            }
            if (song.allowedTimeOfDay == TimeOfDay.Any)
            {
                return(true);
            }
            if (map == null)
            {
                return(true);
            }
            if (song.allowedTimeOfDay == TimeOfDay.Night)
            {
                return(GenLocalDate.DayPercent(map) < 0.2f || GenLocalDate.DayPercent(map) > 0.7f);
            }
            return(GenLocalDate.DayPercent(map) > 0.2f && GenLocalDate.DayPercent(map) < 0.7f);
        }
Ejemplo n.º 12
0
        private bool AppropriateNow(SongDef song)
        {
            if (!song.playOnMap)
            {
                return(false);
            }
            if (this.DangerMusicMode)
            {
                if (!song.tense)
                {
                    return(false);
                }
            }
            else if (song.tense)
            {
                return(false);
            }
            Map map = Find.AnyPlayerHomeMap ?? Find.VisibleMap;

            if (!song.allowedSeasons.NullOrEmpty())
            {
                if (map == null)
                {
                    return(false);
                }
                if (!song.allowedSeasons.Contains(GenLocalDate.Season(map)))
                {
                    return(false);
                }
            }
            if (this.recentSongs.Contains(song))
            {
                return(false);
            }
            if (song.allowedTimeOfDay != TimeOfDay.Any)
            {
                if (map == null)
                {
                    return(true);
                }
                if (song.allowedTimeOfDay == TimeOfDay.Night)
                {
                    return(GenLocalDate.DayPercent(map) < 0.20000000298023224 || GenLocalDate.DayPercent(map) > 0.699999988079071);
                }
                return(GenLocalDate.DayPercent(map) > 0.20000000298023224 && GenLocalDate.DayPercent(map) < 0.699999988079071);
            }
            return(true);
        }
Ejemplo n.º 13
0
        public static bool AcceptableGameConditionsToStartParty(Map map)
        {
            if (!AcceptableGameConditionsToContinueParty(map))
            {
                return(false);
            }
            if (GenLocalDate.HourInteger(map) < 4 || GenLocalDate.HourInteger(map) > 21)
            {
                return(false);
            }
            if (GatheringsUtility.AnyLordJobPreventsNewGatherings(map))
            {
                return(false);
            }
            if (map.dangerWatcher.DangerRating != 0)
            {
                return(false);
            }
            int freeColonistsSpawnedCount = map.mapPawns.FreeColonistsSpawnedCount;

            if (freeColonistsSpawnedCount < 4)
            {
                return(false);
            }
            int num = 0;

            foreach (Pawn item in map.mapPawns.FreeColonistsSpawned)
            {
                if (item.health.hediffSet.BleedRateTotal > 0f)
                {
                    return(false);
                }
                if (item.Drafted)
                {
                    num++;
                }
            }
            if ((float)num / (float)freeColonistsSpawnedCount >= 0.5f)
            {
                return(false);
            }
            if (!EnoughPotentialGuestsToStartParty(map))
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 14
0
 public static bool ShouldTrashBuilding(Pawn pawn, Building b, bool attackAllInert = false)
 {
     if (!b.def.useHitPoints)
     {
         return(false);
     }
     if ((b.def.building.isInert && !attackAllInert) || b.def.building.isTrap)
     {
         int num         = GenLocalDate.HourOfDay(pawn) / 3;
         int specialSeed = b.GetHashCode() * 612361 ^ pawn.GetHashCode() * 391 ^ num * 734273247;
         if (!Rand.ChanceSeeded(0.008f, specialSeed))
         {
             return(false);
         }
     }
     return((!b.def.building.isTrap || !((Building_Trap)b).Armed) && TrashUtility.CanTrash(pawn, b) && pawn.HostileTo(b));
 }
Ejemplo n.º 15
0
        public static bool AcceptableGameConditionsToStartParty(Map map)
        {
            bool result;

            if (!PartyUtility.AcceptableGameConditionsToContinueParty(map))
            {
                result = false;
            }
            else if (GenLocalDate.HourInteger(map) < 4 || GenLocalDate.HourInteger(map) > 21)
            {
                result = false;
            }
            else if (GatheringsUtility.AnyLordJobPreventsNewGatherings(map))
            {
                result = false;
            }
            else if (map.dangerWatcher.DangerRating != StoryDanger.None)
            {
                result = false;
            }
            else
            {
                int freeColonistsSpawnedCount = map.mapPawns.FreeColonistsSpawnedCount;
                if (freeColonistsSpawnedCount < 4)
                {
                    result = false;
                }
                else
                {
                    int num = 0;
                    foreach (Pawn pawn in map.mapPawns.FreeColonistsSpawned)
                    {
                        if (pawn.health.hediffSet.BleedRateTotal > 0f)
                        {
                            return(false);
                        }
                        if (pawn.Drafted)
                        {
                            num++;
                        }
                    }
                    result = ((float)num / (float)freeColonistsSpawnedCount < 0.5f && PartyUtility.EnoughPotentialGuestsToStartParty(map, null));
                }
            }
            return(result);
        }
Ejemplo n.º 16
0
 public void SkillsTick()
 {
     if (this.pawn.IsHashIntervalTick(200))
     {
         if (GenLocalDate.HourInteger(this.pawn) == 0 && (this.lastXpSinceMidnightResetTimestamp < 0 || Find.TickManager.TicksGame - this.lastXpSinceMidnightResetTimestamp >= 30000))
         {
             for (int i = 0; i < this.skills.Count; i++)
             {
                 this.skills[i].xpSinceMidnight = 0f;
             }
             this.lastXpSinceMidnightResetTimestamp = Find.TickManager.TicksGame;
         }
         for (int j = 0; j < this.skills.Count; j++)
         {
             this.skills[j].Interval();
         }
     }
 }
Ejemplo n.º 17
0
 public static bool ShouldTrashBuilding(Pawn pawn, Building b, bool attackAllInert = false)
 {
     if (!b.def.useHitPoints)
     {
         return(false);
     }
     if (pawn.mindState.spawnedByInfestationThingComp && b.GetComp <CompCreatesInfestations>() != null)
     {
         return(false);
     }
     if ((b.def.building.isInert && !attackAllInert) || b.def.building.isTrap)
     {
         int num         = GenLocalDate.HourOfDay(pawn) / 3;
         int specialSeed = b.GetHashCode() * 612361 ^ pawn.GetHashCode() * 391 ^ num * 73427324;
         if (!Rand.ChanceSeeded(0.008f, specialSeed))
         {
             return(false);
         }
     }
     return(!b.def.building.isTrap && TrashUtility.CanTrash(pawn, b) && pawn.HostileTo(b));
 }
Ejemplo n.º 18
0
        public static bool ShouldTrashBuilding(Pawn pawn, Building b, bool attackAllInert = false)
        {
            if (!b.def.useHitPoints || (b.def.building != null && b.def.building.ai_neverTrashThis))
            {
                return(false);
            }
            if (pawn.mindState.spawnedByInfestationThingComp && b.GetComp <CompCreatesInfestations>() != null)
            {
                return(false);
            }
            if (((b.def.building.isInert || b.def.IsFrame) && !attackAllInert) || b.def.building.isTrap)
            {
                int num         = GenLocalDate.HourOfDay(pawn) / 3;
                int specialSeed = (b.GetHashCode() * 612361) ^ (pawn.GetHashCode() * 391) ^ (num * 73427324);
                if (!Rand.ChanceSeeded(0.008f, specialSeed))
                {
                    return(false);
                }
            }
            if (b.def.building.isTrap)
            {
                return(false);
            }
            CompCanBeDormant comp = b.GetComp <CompCanBeDormant>();

            if (comp != null && !comp.Awake)
            {
                return(false);
            }
            if (b.Faction == Faction.OfMechanoids)
            {
                return(false);
            }
            if (!CanTrash(pawn, b) || !pawn.HostileTo(b))
            {
                return(false);
            }
            return(true);
        }
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            switch ((p.GetHashCode() ^ (GenLocalDate.DayOfYear(p) + GenLocalDate.Year(p) * 60) * 391) % 10)
            {
            case 0:
                return(ThoughtState.ActiveAtStage(0));

            case 1:
                return(ThoughtState.ActiveAtStage(1));

            case 2:
                return(ThoughtState.ActiveAtStage(1));

            case 3:
                return(ThoughtState.ActiveAtStage(1));

            case 4:
                return(ThoughtState.Inactive);

            case 5:
                return(ThoughtState.Inactive);

            case 6:
                return(ThoughtState.ActiveAtStage(2));

            case 7:
                return(ThoughtState.ActiveAtStage(2));

            case 8:
                return(ThoughtState.ActiveAtStage(2));

            case 9:
                return(ThoughtState.ActiveAtStage(3));

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 20
0
        public override string GetReport()
        {
            string result;

            if (base.Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Eclipse))
            {
                result = "WatchingEclipse".Translate();
            }
            else if (base.Map.gameConditionManager.ConditionIsActive(GameConditionDefOf.Aurora))
            {
                result = "WatchingAurora".Translate();
            }
            else
            {
                float num = GenCelestial.CurCelestialSunGlow(base.Map);
                if (num < 0.1f)
                {
                    result = "Stargazing".Translate();
                }
                else if (num < 0.65f)
                {
                    if (GenLocalDate.DayPercent(this.pawn) < 0.5f)
                    {
                        result = "WatchingSunrise".Translate();
                    }
                    else
                    {
                        result = "WatchingSunset".Translate();
                    }
                }
                else
                {
                    result = "CloudWatching".Translate();
                }
            }
            return(result);
        }
Ejemplo n.º 21
0
 public static float HourFloat(Map map)
 {
     return(GenLocalDate.HourFloat(map.Tile));
 }
Ejemplo n.º 22
0
 public static float YearPercent(Map map)
 {
     return(GenLocalDate.YearPercent(map.Tile));
 }
Ejemplo n.º 23
0
 public static int DayOfQuadrum(Map map)
 {
     return(GenLocalDate.DayOfQuadrum(map.Tile));
 }
Ejemplo n.º 24
0
 public static int HourInteger(Map map)
 {
     return(GenLocalDate.HourInteger(map.Tile));
 }
Ejemplo n.º 25
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            Job result;

            if (pawn.outfits == null)
            {
                Log.ErrorOnce(pawn + " tried to run JobGiver_OptimizeApparel without an OutfitTracker", 5643897, false);
                result = null;
            }
            else if (pawn.Faction != Faction.OfPlayer)
            {
                Log.ErrorOnce("Non-colonist " + pawn + " tried to optimize apparel.", 764323, false);
                result = null;
            }
            else
            {
                if (!DebugViewSettings.debugApparelOptimize)
                {
                    if (Find.TickManager.TicksGame < pawn.mindState.nextApparelOptimizeTick)
                    {
                        return(null);
                    }
                }
                else
                {
                    JobGiver_OptimizeApparel.debugSb = new StringBuilder();
                    JobGiver_OptimizeApparel.debugSb.AppendLine(string.Concat(new object[]
                    {
                        "Scanning for ",
                        pawn,
                        " at ",
                        pawn.Position
                    }));
                }
                Outfit         currentOutfit = pawn.outfits.CurrentOutfit;
                List <Apparel> wornApparel   = pawn.apparel.WornApparel;
                for (int i = wornApparel.Count - 1; i >= 0; i--)
                {
                    if (!currentOutfit.filter.Allows(wornApparel[i]) && pawn.outfits.forcedHandler.AllowedToAutomaticallyDrop(wornApparel[i]))
                    {
                        return(new Job(JobDefOf.RemoveApparel, wornApparel[i])
                        {
                            haulDroppedApparel = true
                        });
                    }
                }
                Thing        thing = null;
                float        num   = 0f;
                List <Thing> list  = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Apparel);
                if (list.Count == 0)
                {
                    this.SetNextOptimizeTick(pawn);
                    result = null;
                }
                else
                {
                    JobGiver_OptimizeApparel.neededWarmth = PawnApparelGenerator.CalculateNeededWarmth(pawn, pawn.Map.Tile, GenLocalDate.Twelfth(pawn));
                    for (int j = 0; j < list.Count; j++)
                    {
                        Apparel apparel = (Apparel)list[j];
                        if (currentOutfit.filter.Allows(apparel))
                        {
                            if (apparel.IsInAnyStorage())
                            {
                                if (!apparel.IsForbidden(pawn))
                                {
                                    float num2 = JobGiver_OptimizeApparel.ApparelScoreGain(pawn, apparel);
                                    if (DebugViewSettings.debugApparelOptimize)
                                    {
                                        JobGiver_OptimizeApparel.debugSb.AppendLine(apparel.LabelCap + ": " + num2.ToString("F2"));
                                    }
                                    if (num2 >= 0.05f && num2 >= num)
                                    {
                                        if (ApparelUtility.HasPartsToWear(pawn, apparel.def))
                                        {
                                            if (pawn.CanReserveAndReach(apparel, PathEndMode.OnCell, pawn.NormalMaxDanger(), 1, -1, null, false))
                                            {
                                                thing = apparel;
                                                num   = num2;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (DebugViewSettings.debugApparelOptimize)
                    {
                        JobGiver_OptimizeApparel.debugSb.AppendLine("BEST: " + thing);
                        Log.Message(JobGiver_OptimizeApparel.debugSb.ToString(), false);
                        JobGiver_OptimizeApparel.debugSb = null;
                    }
                    if (thing == null)
                    {
                        this.SetNextOptimizeTick(pawn);
                        result = null;
                    }
                    else
                    {
                        result = new Job(JobDefOf.Wear, thing);
                    }
                }
            }
            return(result);
        }
        public override float GetPriority(Pawn pawn)
        {
            Need_Rest rest = pawn.needs.rest;
            float     result;

            if (rest == null)
            {
                result = 0f;
            }
            else if (rest.CurCategory < this.minCategory)
            {
                result = 0f;
            }
            else if (Find.TickManager.TicksGame < pawn.mindState.canSleepTick)
            {
                result = 0f;
            }
            else
            {
                Lord lord = pawn.GetLord();
                if (lord != null && !lord.CurLordToil.AllowSatisfyLongNeeds)
                {
                    result = 0f;
                }
                else
                {
                    TimeAssignmentDef timeAssignmentDef;
                    if (pawn.RaceProps.Humanlike)
                    {
                        timeAssignmentDef = ((pawn.timetable != null) ? pawn.timetable.CurrentAssignment : TimeAssignmentDefOf.Anything);
                    }
                    else
                    {
                        int num = GenLocalDate.HourOfDay(pawn);
                        if (num < 7 || num > 21)
                        {
                            timeAssignmentDef = TimeAssignmentDefOf.Sleep;
                        }
                        else
                        {
                            timeAssignmentDef = TimeAssignmentDefOf.Anything;
                        }
                    }
                    float curLevel = rest.CurLevel;
                    if (timeAssignmentDef == TimeAssignmentDefOf.Anything)
                    {
                        if (curLevel < 0.3f)
                        {
                            result = 8f;
                        }
                        else
                        {
                            result = 0f;
                        }
                    }
                    else if (timeAssignmentDef == TimeAssignmentDefOf.Work)
                    {
                        result = 0f;
                    }
                    else if (timeAssignmentDef == TimeAssignmentDefOf.Joy)
                    {
                        if (curLevel < 0.3f)
                        {
                            result = 8f;
                        }
                        else
                        {
                            result = 0f;
                        }
                    }
                    else
                    {
                        if (timeAssignmentDef != TimeAssignmentDefOf.Sleep)
                        {
                            throw new NotImplementedException();
                        }
                        if (curLevel < RestUtility.FallAsleepMaxLevel(pawn))
                        {
                            result = 8f;
                        }
                        else
                        {
                            result = 0f;
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 27
0
 public static void SetFallShaderGlobals(Map map)
 {
     if (GenPlant.FallIntensityOverride)
     {
         Shader.SetGlobalFloat(ShaderPropertyIDs.FallIntensity, GenPlant.FallIntensity);
     }
     else
     {
         Vector2 vector = Find.WorldGrid.LongLatOf(map.Tile);
         Shader.SetGlobalFloat(ShaderPropertyIDs.FallIntensity, GenPlant.GetFallColorFactor(vector.y, GenLocalDate.DayOfYear(map)));
     }
     Shader.SetGlobalInt("_FallGlobalControls", (!GenPlant.FallGlobalControls) ? 0 : 1);
     if (GenPlant.FallGlobalControls)
     {
         Shader.SetGlobalVector("_FallSrc", new Vector3(GenPlant.FallSrcR, GenPlant.FallSrcG, GenPlant.FallSrcB));
         Shader.SetGlobalVector("_FallDst", new Vector3(GenPlant.FallDstR, GenPlant.FallDstG, GenPlant.FallDstB));
         Shader.SetGlobalVector("_FallRange", new Vector3(GenPlant.FallRangeBegin, GenPlant.FallRangeEnd));
     }
 }
Ejemplo n.º 28
0
 public static Twelfth Twelfth(Thing thing)
 {
     return(GenDate.Twelfth(GenLocalDate.TicksAbs, GenLocalDate.LongitudeForDate(thing)));
 }
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (pawn.outfits == null)
            {
                Log.ErrorOnce(pawn + " tried to run JobGiver_OptimizeApparel without an OutfitTracker", 5643897);
                return(null);
            }
            if (pawn.Faction != Faction.OfPlayer)
            {
                Log.ErrorOnce("Non-colonist " + pawn + " tried to optimize apparel.", 764323);
                return(null);
            }
            if (!DebugViewSettings.debugApparelOptimize)
            {
                if (Find.TickManager.TicksGame < pawn.mindState.nextApparelOptimizeTick)
                {
                    return(null);
                }
            }
            else
            {
                JobGiver_OptimizeApparel.debugSb = new StringBuilder();
                JobGiver_OptimizeApparel.debugSb.AppendLine("Scanning for " + pawn + " at " + pawn.Position);
            }
            Outfit         currentOutfit = pawn.outfits.CurrentOutfit;
            List <Apparel> wornApparel   = pawn.apparel.WornApparel;

            for (int num = wornApparel.Count - 1; num >= 0; num--)
            {
                if (!currentOutfit.filter.Allows(wornApparel[num]) && pawn.outfits.forcedHandler.AllowedToAutomaticallyDrop(wornApparel[num]))
                {
                    Job job = new Job(JobDefOf.RemoveApparel, wornApparel[num]);
                    job.haulDroppedApparel = true;
                    return(job);
                }
            }
            Thing        thing = null;
            float        num2  = 0f;
            List <Thing> list  = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Apparel);

            if (list.Count == 0)
            {
                this.SetNextOptimizeTick(pawn);
                return(null);
            }
            JobGiver_OptimizeApparel.neededWarmth = PawnApparelGenerator.CalculateNeededWarmth(pawn, pawn.Map.Tile, GenLocalDate.Twelfth(pawn));
            for (int i = 0; i < list.Count; i++)
            {
                Apparel apparel = (Apparel)list[i];
                if (currentOutfit.filter.Allows(apparel))
                {
                    SlotGroup slotGroup = apparel.Map.slotGroupManager.SlotGroupAt(apparel.Position);
                    if (slotGroup != null && !apparel.IsForbidden(pawn))
                    {
                        float num3 = JobGiver_OptimizeApparel.ApparelScoreGain(pawn, apparel);
                        if (DebugViewSettings.debugApparelOptimize)
                        {
                            JobGiver_OptimizeApparel.debugSb.AppendLine(apparel.LabelCap + ": " + num3.ToString("F2"));
                        }
                        if (!(num3 < 0.05000000074505806) && !(num3 < num2) && ApparelUtility.HasPartsToWear(pawn, apparel.def) && pawn.CanReserveAndReach(apparel, PathEndMode.OnCell, pawn.NormalMaxDanger(), 1, -1, null, false))
                        {
                            thing = apparel;
                            num2  = num3;
                        }
                    }
                }
            }
            if (DebugViewSettings.debugApparelOptimize)
            {
                JobGiver_OptimizeApparel.debugSb.AppendLine("BEST: " + thing);
                Log.Message(JobGiver_OptimizeApparel.debugSb.ToString());
                JobGiver_OptimizeApparel.debugSb = null;
            }
            if (thing == null)
            {
                this.SetNextOptimizeTick(pawn);
                return(null);
            }
            return(new Job(JobDefOf.Wear, thing));
        }
Ejemplo n.º 30
0
 public static int HourOfDay(Thing thing)
 {
     return(GenDate.HourOfDay(GenLocalDate.TicksAbs, GenLocalDate.LongitudeForDate(thing)));
 }