public bool TryStartParty()
        {
            Pawn    pawn = PartyUtility.FindRandomPartyOrganizer(Faction.OfPlayer, this.map);
            bool    result;
            IntVec3 intVec;

            if (pawn == null)
            {
                result = false;
            }
            else if (!RCellFinder.TryFindPartySpot(pawn, out intVec))
            {
                result = false;
            }
            else
            {
                LordMaker.MakeNewLord(pawn.Faction, new LordJob_Joinable_Party(intVec, pawn), this.map, null);
                Find.LetterStack.ReceiveLetter("LetterLabelNewParty".Translate(), "LetterNewParty".Translate(new object[]
                {
                    pawn.LabelShort
                }), LetterDefOf.PositiveEvent, new TargetInfo(intVec, this.map, false), null, null);
                this.lastLordStartTick = Find.TickManager.TicksGame;
                this.startPartyASAP    = false;
                result = true;
            }
            return(result);
        }
Exemplo n.º 2
0
        public static bool InPartyArea(IntVec3 cell, IntVec3 partySpot, Map map)
        {
            bool result;

            if (PartyUtility.UseWholeRoomAsPartyArea(partySpot, map) && cell.GetRoom(map, RegionType.Set_Passable) == partySpot.GetRoom(map, RegionType.Set_Passable))
            {
                result = true;
            }
            else if (cell.InHorDistOf(partySpot, 10f))
            {
                Building      edifice        = cell.GetEdifice(map);
                TraverseParms traverseParams = TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.None, false);
                if (edifice != null)
                {
                    result = map.reachability.CanReach(partySpot, edifice, PathEndMode.ClosestTouch, traverseParams);
                }
                else
                {
                    result = map.reachability.CanReach(partySpot, cell, PathEndMode.ClosestTouch, traverseParams);
                }
            }
            else
            {
                result = false;
            }
            return(result);
        }
Exemplo n.º 3
0
        private Thing FindBestGame(Pawn pawn, bool inBed, IntVec3 partySpot)
        {
            JoyGiver_InteractBuilding.tmpCandidates.Clear();
            this.GetSearchSet(pawn, JoyGiver_InteractBuilding.tmpCandidates);
            if (JoyGiver_InteractBuilding.tmpCandidates.Count == 0)
            {
                return(null);
            }
            Predicate <Thing> predicate = (Thing t) => this.CanInteractWith(pawn, t, inBed);

            if (partySpot.IsValid)
            {
                Predicate <Thing> oldValidator = predicate;
                predicate = ((Thing x) => PartyUtility.InPartyArea(x.Position, partySpot, pawn.Map) && oldValidator(x));
            }
            IntVec3           position       = pawn.Position;
            Map               map            = pawn.Map;
            List <Thing>      searchSet      = JoyGiver_InteractBuilding.tmpCandidates;
            PathEndMode       peMode         = PathEndMode.OnCell;
            TraverseParms     traverseParams = TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false);
            Predicate <Thing> validator      = predicate;
            Thing             result         = GenClosest.ClosestThing_Global_Reachable(position, map, searchSet, peMode, traverseParams, 9999f, validator, null);

            JoyGiver_InteractBuilding.tmpCandidates.Clear();
            return(result);
        }
        public override float VoluntaryJoinPriorityFor(Pawn p)
        {
            float result;

            if (this.IsInvited(p))
            {
                if (!PartyUtility.ShouldPawnKeepPartying(p))
                {
                    result = 0f;
                }
                else if (this.spot.IsForbidden(p))
                {
                    result = 0f;
                }
                else
                {
                    if (!this.lord.ownedPawns.Contains(p))
                    {
                        if (this.IsPartyAboutToEnd())
                        {
                            return(0f);
                        }
                    }
                    result = VoluntarilyJoinableLordJobJoinPriorities.PartyGuest;
                }
            }
            else
            {
                result = 0f;
            }
            return(result);
        }
Exemplo n.º 5
0
 protected override IntVec3 GetExactWanderDest(Pawn pawn)
 {
     if (!PartyUtility.TryFindRandomCellInPartyArea(pawn, out IntVec3 result))
     {
         return(IntVec3.Invalid);
     }
     return(result);
 }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
 private bool ShouldBeCalledOff()
 {
     if (!PartyUtility.AcceptableGameConditionsToContinueParty(base.Map))
     {
         return(true);
     }
     if (!spot.Roofed(base.Map) && !JoyUtility.EnjoyableOutsideNow(base.Map))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 8
0
        public static bool TryFindRandomCellInPartyArea(Pawn pawn, out IntVec3 result)
        {
            IntVec3             cell      = pawn.mindState.duty.focus.Cell;
            Predicate <IntVec3> validator = (IntVec3 x) => x.Standable(pawn.Map) && !x.IsForbidden(pawn) && pawn.CanReserveAndReach(x, PathEndMode.OnCell, Danger.None, 1, -1, null, false);

            if (PartyUtility.UseWholeRoomAsPartyArea(cell, pawn.Map))
            {
                Room room = cell.GetRoom(pawn.Map, RegionType.Set_Passable);
                return((from x in room.Cells
                        where validator(x)
                        select x).TryRandomElement <IntVec3>(out result));
            }
            return(CellFinder.TryFindRandomReachableCellNear(cell, pawn.Map, 10f, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), (Predicate <IntVec3>)((IntVec3 x) => validator(x)), (Predicate <Region>)null, out result, 10));
        }
Exemplo n.º 9
0
        protected override bool Satisfied(Pawn pawn)
        {
            bool result;

            if (pawn.mindState.duty == null)
            {
                result = false;
            }
            else
            {
                IntVec3 cell = pawn.mindState.duty.focus.Cell;
                result = PartyUtility.InPartyArea(pawn.Position, cell, pawn.Map);
            }
            return(result);
        }
        protected override IntVec3 GetExactWanderDest(Pawn pawn)
        {
            IntVec3 intVec;
            IntVec3 result;

            if (!PartyUtility.TryFindRandomCellInPartyArea(pawn, out intVec))
            {
                result = IntVec3.Invalid;
            }
            else
            {
                result = intVec;
            }
            return(result);
        }
Exemplo n.º 11
0
 private bool AreFiancesInPartyArea()
 {
     if (!lord.ownedPawns.Contains(firstPawn) || !lord.ownedPawns.Contains(secondPawn))
     {
         return(false);
     }
     if (firstPawn.Map != base.Map || !PartyUtility.InPartyArea(firstPawn.Position, spot, base.Map))
     {
         return(false);
     }
     if (secondPawn.Map != base.Map || !PartyUtility.InPartyArea(secondPawn.Position, spot, base.Map))
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 12
0
        public static bool EnoughPotentialGuestsToStartParty(Map map, IntVec3?partySpot = default(IntVec3?))
        {
            int value = Mathf.RoundToInt((float)((float)map.mapPawns.FreeColonistsSpawnedCount * 0.64999997615814209));

            value = Mathf.Clamp(value, 2, 10);
            int num = 0;

            foreach (Pawn item in map.mapPawns.FreeColonistsSpawned)
            {
                if (PartyUtility.ShouldPawnKeepPartying(item) && (!partySpot.HasValue || !partySpot.Value.IsForbidden(item)) && (!partySpot.HasValue || item.CanReach(partySpot.Value, PathEndMode.Touch, Danger.Some, false, TraverseMode.ByPawn)))
                {
                    num++;
                }
            }
            return(num >= value);
        }
Exemplo n.º 13
0
 private bool AreFiancesInPartyArea()
 {
     if (base.lord.ownedPawns.Contains(this.firstPawn) && base.lord.ownedPawns.Contains(this.secondPawn))
     {
         if (this.firstPawn.Map == base.Map && PartyUtility.InPartyArea(this.firstPawn.Position, this.spot, base.Map))
         {
             if (this.secondPawn.Map == base.Map && PartyUtility.InPartyArea(this.secondPawn.Position, this.spot, base.Map))
             {
                 return(true);
             }
             return(false);
         }
         return(false);
     }
     return(false);
 }
Exemplo n.º 14
0
 private bool ShouldAfterPartyBeCalledOff()
 {
     if (!this.firstPawn.Destroyed && !this.secondPawn.Destroyed)
     {
         if (this.spot.GetDangerFor(this.firstPawn, base.Map) == Danger.None && this.spot.GetDangerFor(this.secondPawn, base.Map) == Danger.None)
         {
             if (!PartyUtility.AcceptableGameConditionsToContinueParty(base.Map))
             {
                 return(true);
             }
             return(false);
         }
         return(true);
     }
     return(true);
 }
Exemplo 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);
        }
Exemplo n.º 16
0
        private Thing FindFood(Pawn pawn, IntVec3 partySpot)
        {
            Predicate <Thing> validator = delegate(Thing x)
            {
                if (!x.IngestibleNow)
                {
                    return(false);
                }
                if (!x.def.IsNutritionGivingIngestible)
                {
                    return(false);
                }
                if (!PartyUtility.InPartyArea(x.Position, partySpot, pawn.Map))
                {
                    return(false);
                }
                if (x.def.IsDrug)
                {
                    return(false);
                }
                if ((int)x.def.ingestible.preferability <= 4)
                {
                    return(false);
                }
                if (!pawn.WillEat(x))
                {
                    return(false);
                }
                if (x.IsForbidden(pawn))
                {
                    return(false);
                }
                if (!x.IsSociallyProper(pawn))
                {
                    return(false);
                }
                if (!pawn.CanReserve(x))
                {
                    return(false);
                }
                return(true);
            };

            return(GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForGroup(ThingRequestGroup.FoodSourceNotPlantOrTree), PathEndMode.ClosestTouch, TraverseParms.For(TraverseMode.NoPassClosedDoors), 14f, validator, null, 0, 12));
        }
Exemplo n.º 17
0
 public static bool AcceptableGameConditionsToStartParty(Map map)
 {
     if (!PartyUtility.AcceptableGameConditionsToContinueParty(map))
     {
         return(false);
     }
     if (GenLocalDate.HourInteger(map) >= 4 && GenLocalDate.HourInteger(map) <= 21)
     {
         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 > 0.0)
             {
                 return(false);
             }
             if (item.Drafted)
             {
                 num++;
             }
         }
         if ((float)num / (float)freeColonistsSpawnedCount >= 0.5)
         {
             return(false);
         }
         if (!PartyUtility.EnoughPotentialGuestsToStartParty(map, null))
         {
             return(false);
         }
         return(true);
     }
     return(false);
 }
        public bool TryStartParty()
        {
            Pawn pawn = PartyUtility.FindRandomPartyOrganizer(Faction.OfPlayer, map);

            if (pawn == null)
            {
                return(false);
            }
            if (!RCellFinder.TryFindPartySpot(pawn, out IntVec3 result))
            {
                return(false);
            }
            LordMaker.MakeNewLord(pawn.Faction, new LordJob_Joinable_Party(result, pawn), map);
            Find.LetterStack.ReceiveLetter("LetterLabelNewParty".Translate(), "LetterNewParty".Translate(pawn.LabelShort, pawn), LetterDefOf.PositiveEvent, new TargetInfo(result, map));
            lastLordStartTick = Find.TickManager.TicksGame;
            startPartyASAP    = false;
            return(true);
        }
Exemplo n.º 19
0
        private Thing FindBestGame(Pawn pawn, bool inBed, IntVec3 partySpot)
        {
            List <Thing>      searchSet = this.GetSearchSet(pawn);
            Predicate <Thing> predicate = (Thing t) => this.CanInteractWith(pawn, t, inBed);

            if (partySpot.IsValid)
            {
                Predicate <Thing> oldValidator = predicate;
                predicate = ((Thing x) => PartyUtility.InPartyArea(x.Position, partySpot, pawn.Map) && oldValidator(x));
            }
            IntVec3           position       = pawn.Position;
            Map               map            = pawn.Map;
            List <Thing>      searchSet2     = searchSet;
            PathEndMode       peMode         = PathEndMode.OnCell;
            TraverseParms     traverseParams = TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false);
            Predicate <Thing> validator      = predicate;

            return(GenClosest.ClosestThing_Global_Reachable(position, map, searchSet2, peMode, traverseParams, 9999f, validator, null));
        }
Exemplo n.º 20
0
 public override void LordToilTick()
 {
     if (--Data.ticksToNextPulse <= 0)
     {
         Data.ticksToNextPulse = ticksPerPartyPulse;
         List <Pawn> ownedPawns = lord.ownedPawns;
         for (int i = 0; i < ownedPawns.Count; i++)
         {
             if (PartyUtility.InPartyArea(ownedPawns[i].Position, spot, base.Map))
             {
                 ownedPawns[i].needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.AttendedParty);
                 LordJob_Joinable_Party lordJob_Joinable_Party = lord.LordJob as LordJob_Joinable_Party;
                 if (lordJob_Joinable_Party != null)
                 {
                     TaleRecorder.RecordTale(TaleDefOf.AttendedParty, ownedPawns[i], lordJob_Joinable_Party.Organizer);
                 }
             }
         }
     }
 }
Exemplo n.º 21
0
 private bool ShouldAfterPartyBeCalledOff()
 {
     if (firstPawn.Destroyed || secondPawn.Destroyed)
     {
         return(true);
     }
     if (firstPawn.Downed || secondPawn.Downed)
     {
         return(true);
     }
     if (spot.GetDangerFor(firstPawn, base.Map) != Danger.None || spot.GetDangerFor(secondPawn, base.Map) != Danger.None)
     {
         return(true);
     }
     if (!PartyUtility.AcceptableGameConditionsToContinueParty(base.Map))
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 22
0
 public override float VoluntaryJoinPriorityFor(Pawn p)
 {
     if (IsInvited(p))
     {
         if (!PartyUtility.ShouldPawnKeepPartying(p))
         {
             return(0f);
         }
         if (spot.IsForbidden(p))
         {
             return(0f);
         }
         if (!lord.ownedPawns.Contains(p) && IsPartyAboutToEnd())
         {
             return(0f);
         }
         return(VoluntarilyJoinableLordJobJoinPriorities.PartyGuest);
     }
     return(0f);
 }
Exemplo n.º 23
0
        public static bool EnoughPotentialGuestsToStartParty(Map map, IntVec3?partySpot = null)
        {
            int num = Mathf.RoundToInt((float)map.mapPawns.FreeColonistsSpawnedCount * 0.65f);

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

            foreach (Pawn current in map.mapPawns.FreeColonistsSpawned)
            {
                if (PartyUtility.ShouldPawnKeepPartying(current))
                {
                    if (!partySpot.HasValue || !partySpot.Value.IsForbidden(current))
                    {
                        if (!partySpot.HasValue || current.CanReach(partySpot.Value, PathEndMode.Touch, Danger.Some, false, TraverseMode.ByPawn))
                        {
                            num2++;
                        }
                    }
                }
            }
            return(num2 >= num);
        }
 private bool ShouldBeCalledOff()
 {
     return(!PartyUtility.AcceptableGameConditionsToContinueParty(base.Map) || (!this.spot.Roofed(base.Map) && !JoyUtility.EnjoyableOutsideNow(base.Map, null)));
 }
Exemplo n.º 25
0
 public override Job TryGiveJobInPartyArea(Pawn pawn, IntVec3 partySpot)
 {
     return(this.TryGiveJobInternal(pawn, (Thing x) => !x.Spawned || PartyUtility.InPartyArea(x.Position, partySpot, pawn.Map)));
 }
Exemplo n.º 26
0
 internal bool <> m__0(Thing x)
 {
     return(!x.Spawned || PartyUtility.InPartyArea(x.Position, this.partySpot, this.pawn.Map));
 }
Exemplo n.º 27
0
 public override Job TryGiveJobInPartyArea(Pawn pawn, IntVec3 partySpot)
 {
     return(this.TryGiveJobInt(pawn, (CompGatherSpot x) => PartyUtility.InPartyArea(x.parent.Position, partySpot, pawn.Map)));
 }
 private bool ShouldAfterPartyBeCalledOff()
 {
     return(this.firstPawn.Destroyed || this.secondPawn.Destroyed || (this.firstPawn.Downed || this.secondPawn.Downed) || (this.spot.GetDangerFor(this.firstPawn, base.Map) != Danger.None || this.spot.GetDangerFor(this.secondPawn, base.Map) != Danger.None) || !PartyUtility.AcceptableGameConditionsToContinueParty(base.Map));
 }
Exemplo n.º 29
0
 private void Tick_TryStartParty()
 {
     if (!this.map.IsPlayerHome)
     {
         return;
     }
     if (Find.TickManager.TicksGame % 5000 == 0)
     {
         if (Rand.MTBEventOccurs(40f, 60000f, 5000f))
         {
             this.startPartyASAP = true;
         }
         if (this.startPartyASAP && Find.TickManager.TicksGame - this.lastLordStartTick >= 600000 && PartyUtility.AcceptableGameConditionsToStartParty(this.map))
         {
             this.TryStartParty();
         }
     }
 }
        private Thing FindFood(Pawn pawn, IntVec3 partySpot)
        {
            Predicate <Thing> validator = (Thing x) => x.IngestibleNow && x.def.IsNutritionGivingIngestible && PartyUtility.InPartyArea(x.Position, partySpot, pawn.Map) && !x.def.IsDrug && x.def.ingestible.preferability > FoodPreferability.RawBad && pawn.WillEat(x, null) && !x.IsForbidden(pawn) && x.IsSociallyProper(pawn) && pawn.CanReserve(x, 1, -1, null, false);

            return(GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForGroup(ThingRequestGroup.FoodSourceNotPlantOrTree), PathEndMode.ClosestTouch, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), 14f, validator, null, 0, 12, false, RegionType.Set_Passable, false));
        }