public static void SetupAsVisitor(this Pawn visitor)
 {
     GuestUtility.AddNeedJoy(visitor);
     GuestUtility.AddNeedComfort(visitor);
     visitor.FixTimetable();
     visitor.FixDrugPolicy();
 }
Exemple #2
0
 public override void UpdateAllDuties()
 {
     foreach (Pawn pawn in lord.ownedPawns)
     {
         GuestUtility.AddNeedJoy(pawn);
         GuestUtility.AddNeedComfort(pawn);
         pawn.mindState.duty = new PawnDuty(GuestUtility.relaxDef, pawn.Position, Data.radius);
     }
 }
        private bool SpawnGroup(IncidentParms parms, Map map)
        {
            List <Pawn> visitors;

            try
            {
                //Log.Message(string.Format("Spawning visitors from {0}, at {1}.", parms.faction, parms.spawnCenter));
                visitors = SpawnPawns(parms);

                CheckVisitorsValid(visitors);
            }
            catch (Exception e)
            {
                Log.ErrorOnce("Something failed when spawning visitors: " + e.Message + "\n" + e.StackTrace, 464365853);
                GuestUtility.PlanNewVisit(map, Rand.Range(1f, 3f), parms.faction);
                return(true); // be gone, event
            }
            if (visitors == null || visitors.Count == 0)
            {
                return(false);
            }

            foreach (var visitor in visitors)
            {
                GuestUtility.AddNeedJoy(visitor);
                GuestUtility.AddNeedComfort(visitor);
                visitor.FixTimetable();
                visitor.FixDrugPolicy();
                //Log.Message(visitor.NameStringShort + ": "
                //            + visitor.drugs.CurrentPolicy[ThingDefOf.Luciferium].allowedForJoy);
                visitor.GetComp <CompGuest>().sentAway = false;
            }

            var spot = GetSpot(map, visitors.First().GetGuestArea());

            if (!spot.IsValid)
            {
                Log.ErrorOnce("Visitors failed to find a valid travel target.", 827358325);
                foreach (var visitor in visitors)
                {
                    visitor.DestroyOrPassToWorld();
                }
                return(false);
            }

            GiveItems(visitors);

            CreateLord(parms.faction, spot, visitors, map);
            return(true);
        }
Exemple #4
0
        public override bool TryExecute(IncidentParms parms)
        {
            if (!TryResolveParms(parms))
            {
                return(false);
            }

            Map map = (Map)parms.target;

            // We check here instead of CanFireNow, so we can reschedule the visit.
            if (!CheckCanCome(map, parms.faction))
            {
                GuestUtility.PlanNewVisit(map, Rand.Range(1f, 3f), parms.faction);
                return(false);
            }

            if (parms.points < 40)
            {
                Log.ErrorOnce("Trying to spawn visitors, but points are too low.", 9827456);
                return(false);
            }

            if (parms.faction == null)
            {
                Log.ErrorOnce("Trying to spawn visitors, but couldn't find valid faction.", 43638973);
                return(false);
            }
            if (!parms.spawnCenter.IsValid)
            {
                Log.ErrorOnce("Trying to spawn visitors, but could not find a valid spawn point.", 94839643);
                return(false);
            }
            List <Pawn> visitors;

            try
            {
                //Log.Message(string.Format("Spawning visitors from {0}, at {1}.", parms.faction, parms.spawnCenter));
                visitors = SpawnPawns(parms);
            }
            catch (Exception e)
            {
                Log.ErrorOnce("Something failed when spawning visitors: " + e.Message + "\n" + e.StackTrace, 464365853);
                return(true); // be gone, event
            }
            if (visitors == null || visitors.Count == 0)
            {
                return(false);
            }

            foreach (var visitor in visitors)
            {
                GuestUtility.AddNeedJoy(visitor);
                GuestUtility.AddNeedComfort(visitor);
                visitor.FixTimetable();
                visitor.FixDrugPolicy();
                //Log.Message(visitor.NameStringShort + ": "
                //            + visitor.drugs.CurrentPolicy[ThingDefOf.Luciferium].allowedForJoy);
            }

            var rooms = GetRooms(visitors[0], map);

            if (rooms.Length > 0)
            {
                var spot = rooms[0].room.Cells.Where(c => c.Roofed(map)).RandomElement();

                GiveItems(visitors);

                CreateLord(parms.faction, spot, visitors, map);

                return(true);
            }
            return(false);
        }