// Token: 0x06000014 RID: 20 RVA: 0x00002724 File Offset: 0x00000924
 public override void TickRare()
 {
     if (lastBroadcastSeason == Season.Undefined)
     {
         lastBroadcastSeason = GenLocalDate.Season(Map);
     }
     seasonScore += 0.001f * qualityValue;
     if (qualityValue > 0f)
     {
         qualityValue -= Math.Min(qualityValue, (0.0008f * qualityValue) + 0.01f);
     }
     if (qualityValue < 0f)
     {
         qualityValue += Math.Min(-qualityValue, 0.005f);
     }
     if (!GetComp <CompPowerTrader>().PowerOn&& serviceRegularity > 0f)
     {
         serviceRegularity -= 0.001f;
     }
     if (GenLocalDate.Season(Map) != lastBroadcastSeason)
     {
         lastBroadcastSeason = GenLocalDate.Season(Map);
         ChangeSeasons(Map.Tile);
     }
 }
예제 #2
0
        private void CheckSeason()
        {
            if (MapHeld == null)
            {
                return;
            }

            var isSpring = GenLocalDate.Season(MapHeld) == Season.Spring;

            isSummer = GenLocalDate.Season(MapHeld) == Season.Summer;
            if (!isSpring)
            {
                return;
            }

            if (Find.TickManager.TicksGame < nextSpawnTimestamp)
            {
                return;
            }

            if (nextSpawnTimestamp != -1)
            {
                TrySpawnFilth();
            }

            nextSpawnTimestamp = Find.TickManager.TicksGame + (int)(spawnEveryDays * Rand.Range(10000f, 60000f));
        }
예제 #3
0
        public string getFloodType()
        {
            string flood  = "normal";
            Season season = GenLocalDate.Season(this.map);

            if (this.floodThreat > 1000000)
            {
                flood = "high";
            }
            else if (season.Label() == "spring")
            {
                flood = "high";
            }
            else if (season.Label() == "fall")
            {
                flood = "low";
            }
            GameCondition_Drought isDrought = this.map.gameConditionManager.GetActiveCondition <GameCondition_Drought>();

            if (isDrought != null)
            {
                flood = isDrought.floodOverride;
            }
            return(flood);
        }
예제 #4
0
        public static bool PawnMapSeason(this Pawn p, List <string> parameters)
        {
            if (p.Map == null)
            {
                return(false);
            }
            Season mapSeason = GenLocalDate.Season(p.Map);

            foreach (string s in parameters)
            {
                switch (s)
                {
                case "Spring":
                    if (mapSeason == Season.Spring)
                    {
                        return(true);
                    }
                    continue;

                case "Summer":
                    if (mapSeason == Season.Summer)
                    {
                        return(true);
                    }
                    continue;

                case "Fall":
                    if (mapSeason == Season.Fall)
                    {
                        return(true);
                    }
                    continue;

                case "Winter":
                    if (mapSeason == Season.Winter)
                    {
                        return(true);
                    }
                    continue;

                case "PermanentSummer":
                    if (mapSeason == Season.PermanentSummer)
                    {
                        return(true);
                    }
                    continue;

                case "PermanentWinter":
                    if (mapSeason == Season.PermanentWinter)
                    {
                        return(true);
                    }
                    continue;

                default: continue;
                }
            }
            return(false);
        }
예제 #5
0
        public static Season GetSeason(this Pawn pawn)
        {
            if (pawn.Map == null)
            {
                return(Season.Undefined);
            }

            return(GenLocalDate.Season(pawn.Map));
        }
예제 #6
0
 public override bool Trigger(IncidentDef param, Map map)
 {
     if (map is null)
     {
         return(false);
     }
     if (!allowedSeasons?.Contains(GenLocalDate.Season(map.Tile)) ?? true)
     {
         return(false);
     }
     return(base.Trigger(param, map));
 }
예제 #7
0
        public static bool CheckSeason(this Pawn p, List <Season> seasons)
        {
            if (p.Map == null)
            {
                return(false);
            }

            if (seasons.Contains(GenLocalDate.Season(p.Map)))
            {
                return(true);
            }

            return(false);
        }
예제 #8
0
        internal static void Postfix(ref float __result, Map ___map, ThingDef plant)
        {
            if (!plant.HasModExtension <DM_ModExtension>())
            {
                return;
            }
            DM_ModExtension ext = plant.GetModExtension <DM_ModExtension>();

            if (SeasonUtility.GetPreviousSeason(ext.season) == GenLocalDate.Season(___map) && ext.spawnInPreviousSeason)
            {
                __result = (ext.commonality / 2);
                return;
            }
            __result = ext.commonality;
        }
예제 #9
0
        internal static void Postfix(IntVec3 c, Map ___map, List <ThingDef> outPlants)
        {
            List <ThingDef> thingDefs = DefDatabase <ThingDef> .AllDefsListForReading;

            foreach (ThingDef thingDef in thingDefs.Where(x => x.HasModExtension <DM_ModExtension>()))
            {
                outPlants.Remove(thingDef);
                DM_ModExtension ext = thingDef.GetModExtension <DM_ModExtension>();
                if (!thingDef.CanEverPlantAt_NewTemp(c, ___map))
                {
                    return;
                }
                if (GenLocalDate.Season(___map) == ext.season || (SeasonUtility.GetPreviousSeason(ext.season) == GenLocalDate.Season(___map) && ext.spawnInPreviousSeason) || (DMSeasonUtility.GetNextSeason(ext.season) == GenLocalDate.Season(___map) && ext.spawnInNextSeason))
                {
                    outPlants.Add(thingDef);
                }
            }
        }
        /*
         * public static float MeltAmountAt(float temperature)
         * {
         *      if (temperature < 0f)
         *      {
         *              return 0f;
         *      }
         *      if (temperature < 10f)
         *      {
         *              return temperature * temperature * 0.0058f * 0.1f;
         *      }
         *      return temperature * 0.0058f;
         * }
         */


        public string getFloodType()
        {
            string flood  = "normal";
            Season season = GenLocalDate.Season(this.map);

            if (this.floodThreat > 1000000)
            {
                flood = "high";
            }
            else if (season.Label() == "spring")
            {
                flood = "high";
            }
            else if (season.Label() == "fall")
            {
                flood = "low";
            }
            return(flood);
        }
예제 #11
0
        private void SearchForFlowers(Map map, bool forced = false)
        {
            int interval = Props.updateTicks;

            if (Find.TickManager.CurTimeSpeed >= TimeSpeed.Superfast &&
                (GenLocalDate.Season(parent.Map) == Season.Winter ||
                 (foundThingsInt != null && foundThingsInt.Count > 1)
                )
                )
            {
                interval += 5000; // return;
            }
            if (!forced && !Gen.IsHashIntervalTick(parent, interval))
            {
                return;
            }

            // Update flowers if needed
            IEnumerable <Thing> foundThings = FindValidThingsInRange(map);

            foundThingsInt = foundThings.ToList();
        }
예제 #12
0
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            if (!settings.Active)
            {
                return(false);
            }

            Map    map    = (Map)parms.target;
            Season season = GenLocalDate.Season(map);

            if (season != Season.Summer)
            {
                return(false);
            }

            int day = GenLocalDate.DayOfSeason(map);

            if (day > 8 || day < 7)
            {
                return(false);
            }

            return(true);
        }
예제 #13
0
 public override void Tick(int currentTick)
 {
     //Constituent tick
     if (currentTick % GenDate.TicksPerHour * 2 == 0)
     {
         Map playerFactionMap            = Find.WorldObjects.FactionBases.Find(b => b.Faction.IsPlayer).Map;
         IEnumerable <Pawn> constituents = (from p in playerFactionMap.mapPawns.FreeColonistsSpawned
                                            where !p.health.hediffSet.HasHediff(HediffDefOfPsychology.Mayor) && p.GetTimeAssignment() != TimeAssignmentDefOf.Work && p.Awake()
                                            select p);
         if (constituents.Count() > 0)
         {
             Pawn potentialConstituent       = constituents.RandomElementByWeight(p => 0.0001f + Mathf.Pow(Mathf.Abs(0.7f - p.needs.mood.CurLevel), 2));
             IEnumerable <Pawn> activeMayors = (from m in playerFactionMap.mapPawns.FreeColonistsSpawned
                                                where !m.Dead && m.health.hediffSet.HasHediff(HediffDefOfPsychology.Mayor) && ((Hediff_Mayor)m.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Mayor)).worldTileElectedOn == potentialConstituent.Map.Tile &&
                                                m.GetTimeAssignment() != TimeAssignmentDefOf.Work && m.GetTimeAssignment() != TimeAssignmentDefOf.Sleep && m.GetLord() == null && m.Awake()
                                                select m);
             if (potentialConstituent != null && activeMayors.Count() > 0)
             {
                 Pawn           mayor = activeMayors.RandomElement(); //There should only be one.
                 PsychologyPawn psychologyConstituent = potentialConstituent as PsychologyPawn;
                 IntVec3        gather   = default(IntVec3);
                 bool           foundBed = false;
                 if (mayor.ownership != null && mayor.ownership.OwnedBed != null)
                 {
                     gather   = mayor.ownership.OwnedBed.Position;
                     foundBed = true;
                 }
                 if ((psychologyConstituent == null || Rand.Value < (1f - psychologyConstituent.psyche.GetPersonalityRating(PersonalityNodeDefOf.Independent)) / 5f) && (foundBed || RCellFinder.TryFindPartySpot(mayor, out gather)))
                 {
                     List <Pawn> pawns = new List <Pawn>();
                     pawns.Add(mayor);
                     pawns.Add(potentialConstituent);
                     Lord meeting = LordMaker.MakeNewLord(mayor.Faction, new LordJob_VisitMayor(gather, potentialConstituent, mayor, (potentialConstituent.needs.mood.CurLevel < 0.4f)), mayor.Map, pawns);
                     if (!foundBed)
                     {
                         mayor.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOfPsychology.MayorNoBedroom);
                     }
                 }
             }
         }
     }
     //Election tick
     if (currentTick % (GenDate.TicksPerDay / 4f) == 0)
     {
         foreach (FactionBase factionBase in Find.WorldObjects.FactionBases)
         {
             //If the base isn't owned or named by the player, no election can be held.
             if (!factionBase.Faction.IsPlayer || !factionBase.namedByPlayer)
             {
                 continue;
             }
             //Self-explanatory.
             if (!PsychologyBase.ActivateElections())
             {
                 continue;
             }
             //If the base is not at least a year old, no election will be held.
             if ((Find.TickManager.TicksGame - factionBase.creationGameTicks) / GenDate.TicksPerYear < 1)
             {
                 continue;
             }
             //A base must have at least 7 people in it to hold an election.
             if (factionBase.Map.mapPawns.FreeColonistsSpawnedCount < 7)
             {
                 continue;
             }
             //If an election is already being held, don't start a new one.
             if (factionBase.Map.gameConditionManager.ConditionIsActive(GameConditionDefOfPsychology.Election) || factionBase.Map.lordManager.lords.Find(l => l.LordJob is LordJob_Joinable_Election) != null)
             {
                 continue;
             }
             //Elections are held in the fall and during the day.
             if (GenLocalDate.Season(factionBase.Map) != Season.Fall || (GenLocalDate.HourOfDay(factionBase.Map) < 7 || GenLocalDate.HourOfDay(factionBase.Map) > 20))
             {
                 continue;
             }
             //If an election has already been completed this year, don't start a new one.
             IEnumerable <Pawn> activeMayors = (from m in factionBase.Map.mapPawns.FreeColonistsSpawned
                                                where !m.Dead && m.health.hediffSet.HasHediff(HediffDefOfPsychology.Mayor) && ((Hediff_Mayor)m.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Mayor)).worldTileElectedOn == factionBase.Map.Tile && ((Hediff_Mayor)m.health.hediffSet.GetFirstHediffOfDef(HediffDefOfPsychology.Mayor)).yearElected == GenLocalDate.Year(factionBase.Map.Tile)
                                                select m);
             if (activeMayors.Count() > 0)
             {
                 continue;
             }
             //Try to space out the elections so they don't all proc at once.
             if (Rand.RangeInclusive(1, 15 - GenLocalDate.DayOfSeason(factionBase.Map.Tile)) > 1)
             {
                 continue;
             }
             IncidentParms parms = new IncidentParms();
             parms.target  = factionBase.Map;
             parms.faction = factionBase.Faction;
             FiringIncident fi = new FiringIncident(IncidentDefOfPsychology.Election, null, parms);
             Find.Storyteller.TryFire(fi);
         }
     }
 }