public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
 {
     if (!initiator.IsColonist || !recipient.IsColonist)
     {
         return(0f);
     }
     if (!RendezvousUtility.AcceptableGameConditionsToStartHangingOut(initiator.Map))
     {
         return(0f);
     }
     if (!PsycheHelper.PsychologyEnabled(initiator) || !PsycheHelper.PsychologyEnabled(recipient))
     {
         return(0f);
     }
     if (!LovePartnerRelationUtility.LovePartnerRelationExists(initiator, recipient))
     {
         return(0f);
     }
     if (PsycheHelper.Comp(initiator).Psyche.lastDateTick >= Find.TickManager.TicksGame - GenDate.TicksPerDay * 7 || PsycheHelper.Comp(recipient).Psyche.lastDateTick >= Find.TickManager.TicksGame - GenDate.TicksPerDay * 7)
     {
         return(0f);
     }
     if (!GatheringsUtility.ShouldGuestKeepAttendingGathering(initiator) || !GatheringsUtility.ShouldGuestKeepAttendingGathering(recipient))
     {
         return(0f);
     }
     return(1.2f * (1f + Mathf.InverseLerp(100f, 0f, initiator.needs.mood.thoughts.TotalOpinionOffset(recipient))) * PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic) * (1f - PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Independent))
            * PsycheHelper.Comp(recipient).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Romantic) * (1f - PsycheHelper.Comp(recipient).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Independent)) * RendezvousUtility.ColonySizeFactor(initiator));
 }
예제 #2
0
        public static bool AcceptableGameConditionsToStartHangingOut(Map map)
        {
            if (GatheringsUtility.AnyLordJobPreventsNewGatherings(map))
            {
                return(false);
            }
            if (map.dangerWatcher.DangerRating != StoryDanger.None)
            {
                return(false);
            }
            int freeColonistsSpawnedCount = map.mapPawns.FreeColonistsSpawnedCount;

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

            foreach (Pawn current in map.mapPawns.FreeColonistsSpawned)
            {
                if (current.health.hediffSet.BleedRateTotal > 0f)
                {
                    return(false);
                }
                if (current.Drafted)
                {
                    num++;
                }
            }
            if ((float)num / (float)freeColonistsSpawnedCount >= 0.5f)
            {
                return(false);
            }
            return(true);
        }
        public static bool TryStartGathering(Map map)
        {
            Pawn organizer = GatheringsUtility.FindRandomGatheringOrganizer(Faction.OfPlayer, map, GatheringDefOf.Party);


            //Pawn pawn = PartyUtility.FindRandomPartyOrganizer(Faction.OfPlayer, map);
            if (organizer == null)
            {
                Messages.Message("ElectionFail_ColonistsNotFound", MessageTypeDefOf.RejectInput);

                return(false);
            }

            IntVec3 intVec;

            //RCellFinder.TryFindGatheringSpot(pawn, GatheringDef.Named(""), intVec)
            if (!RCellFinder.TryFindGatheringSpot(organizer, GatheringDefOf.Party, out intVec))
            {
                Messages.Message("Couldn't find a suitable safe spot for the election.", MessageTypeDefOf.RejectInput);

                return(false);
            }
            LordMaker.MakeNewLord(organizer.Faction, new LordJob_Joinable_SetLeadership(intVec), map, null);
            Find.LetterStack.ReceiveLetter("Election", "ElectionGathering", LetterDefOf.PositiveEvent, new TargetInfo(intVec, map, false), null);
            return(true);
        }
        // Token: 0x0600001B RID: 27 RVA: 0x000028D0 File Offset: 0x00000AD0
        public bool TryStartParty()
        {
            var  pawn = GatheringsUtility.FindRandomGatheringOrganizer(Faction.OfPlayer, map, GatheringDefOf.Party);
            bool result;

            if (pawn == null)
            {
                result = false;
            }
            else
            {
                if (!RCellFinder.TryFindGatheringSpot(pawn, GatheringDefOf.Party, true, out var intVec))
                {
                    result = false;
                }
                else
                {
                    LordMaker.MakeNewLord(pawn.Faction, new LordJob_Joinable_CParty(intVec, pawn), map);
                    Find.LetterStack.ReceiveLetter("CParyLabel".Translate(), "CParyLetter".Translate(),
                                                   LetterDefOf.PositiveEvent, new TargetInfo(intVec, map));
                    result = true;
                }
            }

            return(result);
        }
예제 #5
0
        // Token: 0x06000843 RID: 2115 RVA: 0x00043A60 File Offset: 0x00041E60
        public override void LordToilTick()
        {
            //TODO test

            //if (--this.Data.ticksToNextPulse <= 0)
            {
                //this.Data.ticksToNextPulse = this.ticksPerPartyPulse;

                List <Pawn> ownedPawns = this.lord.ownedPawns;
                for (int i = 0; i < ownedPawns.Count; i++)
                {
                    //
                    if (--this.Data.presentForTicks[ownedPawns[i]] <= 0)
                    {
                        this.Data.presentForTicks[ownedPawns[i]] = this.ticksPerPartyPulse;
                        //

                        //if (PartyUtility.InPartyArea(ownedPawns[i].Position, this.spot, base.Map))
                        if (GatheringsUtility.InGatheringArea(ownedPawns[i].Position, this.spot, base.Map))
                        {
                            //ownedPawns[i].needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.AttendedParty, null);
                            LordJob_RimStory lordJob_Joinable_Party = this.lord.LordJob as LordJob_RimStory;
                            if (lordJob_Joinable_Party != null)
                            {
                                TaleRecorder.RecordTale(TaleDefOf.AttendedParty, new object[]
                                {
                                    ownedPawns[i],
                                    lordJob_Joinable_Party.Organizer
                                });
                            }
                        }
                    }
                }
            }
        }
예제 #6
0
        // Token: 0x06000011 RID: 17 RVA: 0x00002424 File Offset: 0x00000624
        public override void LordToilTick()
        {
            var unused = Data;
            var num    = ticksToNextPulse - 1;

            ticksToNextPulse = num;
            if (num > 0)
            {
                return;
            }

            ticksToNextPulse = ticksPerPartyPulse;
            var ownedPawns = lord.ownedPawns;

            foreach (var pawn in ownedPawns)
            {
                if (!GatheringsUtility.InGatheringArea(pawn.Position, spot, Map))
                {
                    continue;
                }

                pawn.needs.mood.thoughts.memories.TryGainMemory(XDefOf.FeelingFestive);
                if (lord.LordJob is LordJob_Joinable_CParty lordJob_Joinable_CParty)
                {
                    TaleRecorder.RecordTale(TaleDefOf.AttendedParty, pawn, lordJob_Joinable_CParty.Organizer);
                }
            }
        }
예제 #7
0
        public static bool TryStartMassFuneral(Map map)
        {
            if (Utils.CurrentDay() == 7 || Utils.CurrentDay() == 14)
            {
                //Pawn pawn = PartyUtility.FindRandomPartyOrganizer(Faction.OfPlayer, map);
                Pawn pawn = GatheringsUtility.FindRandomGatheringOrganizer(Faction.OfPlayer, map, GatheringDefOf.Party);

                if (pawn == null)
                {
                    return(false);
                }
                IntVec3 intVec;
                //if (!RCellFinder.TryFindPartySpot(pawn, out intVec))
                if (!RCellFinder.TryFindGatheringSpot(pawn, GatheringDefOf.Party, out intVec))
                {
                    return(false);
                }
                foreach (Pawn deadPawn in Resources.deadPawnsForMassFuneralBuried)
                {
                    if (deadPawn != null)
                    {
                        deadPawnsNames = deadPawnsNames + deadPawn.Label + "\n";
                    }
                }
                Lord lord = LordMaker.MakeNewLord(pawn.Faction, new LordJob_RimStory(Resources.lastGrave.Position, pawn), map, null);
                Find.LetterStack.ReceiveLetter("FuneralLetter".Translate(), "FuneralDesc".Translate() + deadPawnsNames, LetterDefOf.NeutralEvent, Resources.lastGrave);

                deadPawnsNames = "";
                return(true);
            }
            return(false);
        }
예제 #8
0
        public override bool CanExecute(Map map, Pawn organizer = null)
        {
            var nextTick = new IntRange(3500000, 3700000).RandomInRange;

            //Log.Message("map.GetComponent<VFEV_MapComponentHelper>().lastFeastStartTick: " + map.GetComponent<VFEV_MapComponentHelper>().lastFeastStartTick, true);
            //Log.Message("nextTick: " + nextTick, true);
            //Log.Message("Find.TickManager.TicksGame: " + Find.TickManager.TicksGame, true);

            if (map.GetComponent <VFEV_MapComponentHelper>().lastFeastStartTick + nextTick > Find.TickManager.TicksGame)
            {
                //Log.Message("Result false");
                return(false);
            }
            if (organizer == null)
            {
                organizer = FindOrganizer(map);
            }
            if (organizer == null)
            {
                return(false);
            }
            if (!TryFindGatherSpot(organizer, out IntVec3 _))
            {
                return(false);
            }
            if (!GatheringsUtility.PawnCanStartOrContinueGathering(organizer))
            {
                return(false);
            }
            return(true);
        }
예제 #9
0
        public override bool IsPossible()
        {
            if (target is Map map)
            {
                map = target as Map;
            }
            else
            {
                return(false);
            }

            pawn = GatheringsUtility.FindRandomGatheringOrganizer(Faction.OfPlayer, Helper.AnyPlayerMap, GatheringDefOf.Party);
            if (pawn == null)
            {
                return(false);
            }

            IntVec3 intVec;

            if (!RCellFinder.TryFindGatheringSpot(pawn, GatheringDefOf.Party, out intVec))
            {
                return(false);
            }

            return(true);
        }
        public override StateGraph CreateGraph()
        {
            var      stateGraph = new StateGraph();
            LordToil lordToil   = CreateGatheringToil(spot, organizer, gatheringDef);

            stateGraph.AddToil(lordToil);
            var lordToil_End = new LordToil_End();

            stateGraph.AddToil(lordToil_End);
            var speechDuration = 12500f;
            var transition     = new Transition(lordToil, lordToil_End);

            transition.AddTrigger(new Trigger_TickCondition(ShouldBeCalledOff));
            transition.AddTrigger(new Trigger_PawnKilled());
            transition.AddTrigger(new Trigger_PawnLost(PawnLostCondition.LeftVoluntarily, organizer));
            transition.AddPreAction(new TransitionAction_Custom((Action) delegate
            {
                ApplyOutcome(lord.ticksInToil / speechDuration);
            }));
            stateGraph.AddTransition(transition);
            timeoutTrigger = new Trigger_TicksPassedAfterConditionMet((int)speechDuration,
                                                                      () => GatheringsUtility.InGatheringArea(organizer.Position,
                                                                                                              spot,
                                                                                                              organizer.Map), 60);
            var transition2 = new Transition(lordToil, lordToil_End);

            transition2.AddTrigger(timeoutTrigger);
            transition2.AddPreAction(new TransitionAction_Custom((Action) delegate { ApplyOutcome(1f); }));
            stateGraph.AddTransition(transition2);
            return(stateGraph);
        }
예제 #11
0
 private bool ShouldAfterPartyBeCalledOff()
 {
     return(firstPawn.Destroyed || secondPawn.Destroyed || firstPawn.Downed || secondPawn.Downed ||
            spot.GetDangerFor(firstPawn, Map) != Danger.None ||
            spot.GetDangerFor(secondPawn, Map) != Danger.None ||
            !GatheringsUtility.AcceptableGameConditionsToContinueGathering(Map));
 }
예제 #12
0
        public override Job TryGiveJobInGatheringArea(Pawn pawn,
                                                      IntVec3 gatheringSpot)
        {
            MatesMod.Log("TryGiveJobInGatheringArea");

            return(TryGiveJobInt(pawn,
                                 x =>
                                 GatheringsUtility.InGatheringArea(x.parent.Position, gatheringSpot,
                                                                   pawn.Map)));
        }
예제 #13
0
        public override float RandomSelectionWeight(Pawn initiator, Pawn recipient)
        {
            if (!GatheringsUtility.ShouldGuestKeepAttendingGathering(initiator) || !GatheringsUtility.ShouldGuestKeepAttendingGathering(recipient))
            {
                return(0f);
            }
            if (!PsycheHelper.PsychologyEnabled(initiator) || !PsycheHelper.PsychologyEnabled(recipient))
            {
                return(0f);
            }
            if (initiator.GetLord() != null || recipient.GetLord() != null)
            {
                return(0f);
            }
            if (initiator.Drafted || recipient.Drafted)
            {
                return(0f);
            }
            if (!RendezvousUtility.AcceptableGameConditionsToStartHangingOut(initiator.Map))
            {
                return(0f);
            }
            if (initiator.Faction != recipient.Faction)
            {
                return(0f);
            }
            float initiatorFactor = 0f;
            float recipientFactor = 0f;

            if (initiator.relations.OpinionOf(recipient) > -20)
            {
                initiatorFactor = PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Extroverted) + 0.15f + Mathf.InverseLerp(0f, 100f, initiator.relations.OpinionOf(recipient));
                recipientFactor = (PsycheHelper.Comp(recipient).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Friendly) + PsycheHelper.Comp(recipient).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Cool)) / 2f;
            }
            else if (initiator.relations.OpinionOf(recipient) <= -20)
            {
                initiatorFactor = Mathf.InverseLerp(0.6f, 1f, PsycheHelper.Comp(initiator).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Empathetic));
                recipientFactor = PsycheHelper.Comp(recipient).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Trusting);
            }
            float scheduleFactor = 0f;

            if (initiator.GetTimeAssignment() == TimeAssignmentDefOf.Anything)
            {
                scheduleFactor = 0.33f;
            }
            else if (initiator.GetTimeAssignment() == TimeAssignmentDefOf.Joy)
            {
                scheduleFactor = 1f;
            }
            if (initiator.mindState.IsIdle && recipient.mindState.IsIdle && initiator.GetTimeAssignment() != TimeAssignmentDefOf.Work && recipient.GetTimeAssignment() != TimeAssignmentDefOf.Work)
            {
                scheduleFactor = 5f;
            }
            return(0.05f * initiatorFactor * recipientFactor * scheduleFactor * RendezvousUtility.ColonySizeFactor(initiator));
        }
예제 #14
0
        // Token: 0x06000059 RID: 89 RVA: 0x00003803 File Offset: 0x00001A03
        protected override IEnumerable <Toil> MakeNewToils()
        {
            List <Toil> list = Stage.Director.RequestPlayToils(GetActor(), Stage);

            foreach (Toil toil in list)
            {
                toil.AddFailCondition(() => !GatheringsUtility.AcceptableGameConditionsToContinueGathering(GetActor().Map));
                yield return(toil);
            }
            yield break;
        }
        // Token: 0x06000906 RID: 2310 RVA: 0x000474A0 File Offset: 0x000458A0
        protected override bool Satisfied(Pawn pawn)
        {
            if (pawn.mindState.duty == null)
            {
                return(false);
            }
            IntVec3 cell = pawn.mindState.duty.focus.Cell;

            //return PartyUtility.InPartyArea(pawn.Position, cell, pawn.Map);
            return(GatheringsUtility.InGatheringArea(pawn.Position, cell, pawn.Map));
        }
예제 #16
0
        public override void LordToilTick()
        {
            List <Pawn> ownedPawns = lord.ownedPawns;

            for (int index = 0; index < ownedPawns.Count; ++index)
            {
                if (GatheringsUtility.InGatheringArea(ownedPawns[index].Position, spot, Map))
                {
                    ownedPawns[index].needs.joy.GainJoy(joyPerTick, JoyKindDefOf.Social);
                    if (!Data.wasPresent.Contains(ownedPawns[index]))
                    {
                        Data.wasPresent.Add(ownedPawns[index]);
                    }
                }
            }
        }
예제 #17
0
 public override float VoluntaryJoinPriorityFor(Pawn p)
 {
     if (!this.IsInvited(p))
     {
         return(0f);
     }
     if (!GatheringsUtility.ShouldGuestKeepAttendingGathering(p))
     {
         return(0f);
     }
     if (!this.lord.ownedPawns.Contains(p) && this.IsPartyAboutToEnd())
     {
         return(0f);
     }
     return(20f);
 }
        public bool TryStartGathering(Map map)
        {
            Pawn pawn = GatheringsUtility.FindRandomGatheringOrganizer(Faction.OfPlayer, map, GatheringDefOf.Party);

            if (pawn == null)
            {
                Messages.Message("ElectionFail_ColonistsNotFound".Translate(), MessageTypeDefOf.RejectInput);

                return(false);
            }

            lastElectionTick = Find.TickManager.TicksGame;
            allowElection    = false;
            LordMaker.MakeNewLord(pawn.Faction, new LordJob_Joinable_SetLeadership(Position), map, null);
            Find.LetterStack.ReceiveLetter("Election".Translate(), "ElectionGathering".Translate(), LetterDefOf.PositiveEvent, new TargetInfo(Position, map, false), null);
            return(true);
        }
예제 #19
0
        public bool TryStartEvent(Map map)
        {
            if (faction != null)
            {
                bool flag = true;
                foreach (int y in yearsWhenEventStarted)
                {
                    if (y == Utils.CurrentYear())
                    {
                        flag = false;
                    }
                }

                if (Utils.CurrentDay() == date.day && Utils.CurrentQuadrum() == date.quadrum && Utils.CurrentHour() >= Resources.minHour && Utils.CurrentHour() <= Resources.maxHour && Utils.CurrentYear() != date.year && flag)
                {
                    //Pawn pawn = PartyUtility.FindRandomPartyOrganizer(Faction.OfPlayer, map);
                    Pawn pawn = GatheringsUtility.FindRandomGatheringOrganizer(Faction.OfPlayer, map, GatheringDefOf.Party);
                    if (pawn == null)
                    {
                        return(false);
                    }
                    IntVec3 intVec;
                    //if (!RCellFinder.TryFindPartySpot(pawn, out intVec))
                    if (!RCellFinder.TryFindGatheringSpot(pawn, GatheringDefOf.Party, out intVec))
                    {
                        return(false);
                    }

                    yearsWhenEventStarted.Add(Utils.CurrentYear());

                    yearsWhenEventStarted.Add(Utils.CurrentYear());
                    //Lord lord = LordMaker.MakeNewLord(pawn.Faction, new LordJob_Joinable_Party(intVec, pawn), map, null);
                    Lord lord = LordMaker.MakeNewLord(pawn.Faction, new LordJob_Joinable_Party(intVec, pawn, GatheringDefOf.Party), map, null);

                    //Find.LetterStack.ReceiveLetter("Day of "+faction.Name+" defeat", "Your colonists are celebrating " + faction.Name + "'s defeat on \n" + date, LetterDefOf.PositiveEvent);
                    //Find.LetterStack.ReceiveLetter("DayOfVictory".Translate(faction.Name), "DayOfVictoryDesc".Translate(new object[] { faction.Name, date }), LetterDefOf.PositiveEvent);
                    string label = TranslatorFormattedStringExtensions.Translate("DayOfVictory", faction.Name);
                    string text  = TranslatorFormattedStringExtensions.Translate("DayOfVictoryDesc", faction.Name, date.ToString());
                    Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.PositiveEvent);
                    return(true);
                }

                flag = true;
            }
            return(false);
        }
예제 #20
0
        private bool ShouldPawnKeepVoting(Pawn p)
        {
            if (!PsycheHelper.PsychologyEnabled(p))
            {
                return(false);
            }
            bool matchingCandidates = (from c in candidates
                                       where c.pawn == p
                                       select c).Count() > 0;

            if (voters.Contains(p.GetHashCode()) && !matchingCandidates)
            {
                return(false);
            }
            bool notApathetic = PsycheHelper.Comp(p).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Passionate) > (0.6f / candidates.Count);

            return(GatheringsUtility.ShouldGuestKeepAttendingGathering(p) && (notApathetic || matchingCandidates));
        }
예제 #21
0
        // Token: 0x06000085 RID: 133 RVA: 0x00003FB4 File Offset: 0x000021B4
        public bool PerformersAreReady()
        {
            bool result;

            if (!IsValidLead(Lead) || !GatheringsUtility.InGatheringArea(Lead.Position, Venue.Position, Venue.Map))
            {
                result = false;
            }
            else
            {
                if (Venue.VenueDef.performersNeeded > 1 && (!IsValidSupport(Support) || !GatheringsUtility.InGatheringArea(Support.Position, Venue.Position, Venue.Map)))
                {
                    return(false);
                }
                result = true;
            }
            return(result);
        }
예제 #22
0
        private bool ShouldPawnKeepVoting(Pawn p)
        {
            if (!(p is PsychologyPawn))
            {
                return(false);
            }
            PsychologyPawn realPawn           = p as PsychologyPawn;
            bool           matchingCandidates = (from c in candidates
                                                 where c.pawn == realPawn
                                                 select c).Count() > 0;

            if (voters.Contains(p.GetHashCode()) && !matchingCandidates)
            {
                return(false);
            }
            bool notApathetic = realPawn.psyche.GetPersonalityRating(PersonalityNodeDefOf.Passionate) > (0.6f / candidates.Count);

            return(GatheringsUtility.ShouldGuestKeepAttendingGathering(p) && (notApathetic || matchingCandidates));
        }
예제 #23
0
        //RCellFinder
        public static void TryFindGatheringSpot_PostFix(Pawn organizer, ref IntVec3 result, ref bool __result)
        {
            bool enjoyableOutside = JoyUtility.EnjoyableOutsideNow(organizer, null);
            Map  map = organizer.Map;

            if (map.listerThings.ThingsOfDef(ThingDef.Named("LotRH_PlantPartyTree")).Any(x => x is Plant y && y.HarvestableNow))
            {
                bool baseValidator(IntVec3 cell)
                {
                    if (!cell.Standable(map))
                    {
                        return(false);
                    }
                    if (cell.GetDangerFor(organizer, map) != Danger.None)
                    {
                        return(false);
                    }
                    if (!enjoyableOutside && !cell.Roofed(map))
                    {
                        return(false);
                    }
                    if (cell.IsForbidden(organizer))
                    {
                        return(false);
                    }
                    if (!organizer.CanReserveAndReach(cell, PathEndMode.OnCell, Danger.None, 1, -1, null, false))
                    {
                        return(false);
                    }
                    Room room = cell.GetRoom(map, RegionType.Set_Passable);
                    bool flag = room != null && room.isPrisonCell;

                    return(organizer.IsPrisoner == flag && GatheringsUtility.EnoughPotentialGuestsToStartGathering(map, GatheringDefOf.Party, new IntVec3?(cell)));
                }

                if ((from x in map.listerThings.ThingsOfDef(ThingDef.Named("LotRH_PlantPartyTree")).Where(x => x is Plant y && y.HarvestableNow)
                     where baseValidator(x.InteractionCell)
                     select x.InteractionCell).TryRandomElement(out result))
                {
                    __result = true;
                }
            }
        }
예제 #24
0
        public bool TryStartEvent(Map map)
        {
            bool flag = true;

            foreach (int y in yearsWhenEventStarted)
            {
                if (y == Utils.CurrentYear())
                {
                    flag = false;
                }
            }


            if (Utils.CurrentDay() == date.day && Utils.CurrentQuadrum() == date.quadrum && Utils.CurrentHour() >= Resources.minHour && Utils.CurrentHour() <= Resources.maxHour && Utils.CurrentYear() != date.year && flag)
            {
                //Pawn pawn = PartyUtility.FindRandomPartyOrganizer(Faction.OfPlayer, map);
                Pawn pawn = GatheringsUtility.FindRandomGatheringOrganizer(Faction.OfPlayer, map, GatheringDefOf.Party);

                if (pawn == null)
                {
                    return(false);
                }
                IntVec3 intVec;
                //if (!RCellFinder.TryFindPartySpot(pawn, out intVec))
                if (!RCellFinder.TryFindGatheringSpot(pawn, GatheringDefOf.Party, out intVec))
                {
                    return(false);
                }

                yearsWhenEventStarted.Add(Utils.CurrentYear());
                //Lord lord = LordMaker.MakeNewLord(pawn.Faction, new LordJob_Joinable_Party(intVec, pawn), map, null);
                Lord lord = LordMaker.MakeNewLord(pawn.Faction, new LordJob_Joinable_Party(intVec, pawn, GatheringDefOf.Party), map, null);

                //Find.LetterStack.ReceiveLetter("Memorial Day", "Colonist are gathering to honor fallen colonists.", LetterDefOf.PositiveEvent);
                Find.LetterStack.ReceiveLetter("AMemorialDayLetter".Translate(), "AMemorialDayDesc".Translate(), LetterDefOf.PositiveEvent);
                return(true);
            }

            flag = true;
            return(false);
        }
예제 #25
0
        private bool IsGuest(Pawn p)
        {
            if (!p.RaceProps.Humanlike)
            {
                return(false);
            }
            if (p == organizer)
            {
                return(false);
            }
            if (p.Faction != organizer.Faction)
            {
                return(false);
            }
            if (!GatheringsUtility.ShouldGuestKeepAttendingGathering(p))
            {
                return(false);
            }

            return(true);
        }
예제 #26
0
 // Token: 0x0600078F RID: 1935 RVA: 0x0003FD88 File Offset: 0x0003E188
 public override float VoluntaryJoinPriorityFor(Pawn p)
 {
     if (!this.IsInvited(p))
     {
         return(0f);
     }
     //if (!PartyUtility.ShouldPawnKeepPartying(p))
     if (GatheringsUtility.ShouldPawnKeepGathering(p, GatheringDefOf.Party))
     {
         return(0f);
     }
     if (this.spot.IsForbidden(p))
     {
         return(0f);
     }
     if (!this.lord.ownedPawns.Contains(p) && this.IsPartyAboutToEnd())
     {
         return(0f);
     }
     //return VoluntarilyJoinableLordJobJoinPriorities.PartyGuest;
     return(VoluntarilyJoinableLordJobJoinPriorities.SocialGathering);
 }
        public bool AcceptableMapConditionsToStartElection(Map map)
        {
            if (!GatheringsUtility.AcceptableGameConditionsToContinueGathering(map) || (!Position.Roofed(map) && !JoyUtility.EnjoyableOutsideNow(map, null)))
            {
                return(false);
            }
            if (GenLocalDate.HourInteger(map) < 8 || GenLocalDate.HourInteger(map) > 21)
            {
                return(false);
            }
            List <Lord> lords = map.lordManager.lords;

            for (int i = 0; i < lords.Count; i++)
            {
                if (lords[i].LordJob is LordJob_Joinable_Party || lords[i].LordJob is LordJob_Joinable_MarriageCeremony || lords[i].LordJob is LordJob_Joinable_SetLeadership)
                {
                    return(false);
                }
            }

            if (map.dangerWatcher.DangerRating != StoryDanger.None)
            {
                return(false);
            }
            int num2 = Mathf.RoundToInt((float)map.mapPawns.FreeColonistsSpawnedCount * 0.65f);

            num2 = Mathf.Clamp(num2, 2, 10);
            int num3 = 0;

            foreach (Pawn current2 in map.mapPawns.FreeColonistsSpawned)
            {
                if (GatheringsUtility.ShouldGuestKeepAttendingGathering(current2))
                {
                    num3++;
                }
            }
            return(num3 >= num2);
        }
예제 #28
0
        private void Finished()
        {
            List <Pawn> ownedPawns = this.lord.ownedPawns;
            int         num        = 0;

            for (int i = 0; i < ownedPawns.Count; i++)
            {
                if (GatheringsUtility.InGatheringArea(ownedPawns[i].Position, this.spot, base.Map))
                {
                    ownedPawns[i].needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("AttendedElection"), null);
                    num++;
                }
            }
            if (num != 0)
            {
                IncidentParms parms = StorytellerUtility.DefaultParmsNow(IncidentDef.Named("SetLeadership").category, this.Map);
                IncidentDef.Named("SetLeadership").Worker.TryExecute(parms);
            }
            else
            {
                Messages.Message("ElectionNoAttendees".Translate(), MessageTypeDefOf.RejectInput);
            }
        }
        // Token: 0x06000007 RID: 7 RVA: 0x00002208 File Offset: 0x00000408
        public override float VoluntaryJoinPriorityFor(Pawn p)
        {
            if (!IsInvited(p))
            {
                return(0f);
            }

            if (!GatheringsUtility.ShouldPawnKeepGathering(p, GatheringDefOf.Party))
            {
                return(0f);
            }

            if (spot.IsForbidden(p))
            {
                return(0f);
            }

            if (!lord.ownedPawns.Contains(p) && IsPartyAboutToEnd())
            {
                return(0f);
            }

            return(VoluntarilyJoinableLordJobJoinPriorities.SocialGathering);
        }
        static bool Prefix(Map map, GatheringDef gatheringDef, ref bool __result)
        {
            if (gatheringDef == DiscoDefOf.DSC_DiscoGathering)
            {
                if (!GatheringsUtility.AcceptableGameConditionsToContinueGathering(map) || GatheringsUtility.AnyLordJobPreventsNewGatherings(map) || map.dangerWatcher.DangerRating != StoryDanger.None)
                {
                    __result = false;
                    return(false);
                }

                int colonistsSpawnedCount = map.mapPawns.FreeColonistsSpawnedCount;
                if (colonistsSpawnedCount < 3)
                {
                    return(false);
                }

                int num = 0;
                foreach (Pawn pawn in map.mapPawns.FreeColonistsSpawned)
                {
                    if (pawn.health.hediffSet.BleedRateTotal > 0.05)
                    {
                        __result = false;
                        return(false);
                    }
                    if (pawn.Drafted)
                    {
                        num++;
                    }
                }

                __result = num / (double)colonistsSpawnedCount < 0.75 && GatheringsUtility.EnoughPotentialGuestsToStartGathering(map, gatheringDef);
                return(false);
            }

            return(true);
        }