private static void CreateLord(Faction faction, IntVec3 chillSpot, List <Pawn> pawns, Map map)
        {
            var mapComp = Hospitality_MapComponent.Instance(map);

            int stayDuration = (int)(Rand.Range(1f, 2.4f) * GenDate.TicksPerDay);
            var lordJob      = new LordJob_VisitColony(faction, chillSpot, stayDuration);

            LordMaker.MakeNewLord(faction, lordJob, map, pawns);


            // Set default interaction
            pawns.ForEach(delegate(Pawn p) {
                var compGuest = p.GetComp <CompGuest>();
                if (compGuest != null)
                {
                    compGuest.mayBuy    = mapComp.defaultMayBuy;
                    compGuest.chat      = mapComp.defaultInteractionMode == PrisonerInteractionModeDefOf.Chat;
                    compGuest.GuestArea = mapComp.defaultAreaRestriction;
                }
            });

            bool gotTrader = false;

            if (Rand.Value < 0.75f)
            {
                gotTrader = TryConvertOnePawnToSmallTrader(pawns, faction, map);
            }
            string label;
            string description;
            Pawn   pawn = pawns.Find(x => faction.leader == x);

            if (pawns.Count == 1)
            {
                string traderDesc = (!gotTrader) ? string.Empty : "SingleVisitorArrivesTraderInfo".Translate();
                string leaderDesc = (pawn == null) ? string.Empty : "SingleVisitorArrivesLeaderInfo".Translate();
                label       = "LetterLabelSingleVisitorArrives".Translate();
                description = "SingleVisitorArrives".Translate(new object[]
                {
                    pawns[0].GetTitle().ToLower(),
                    faction.Name,
                    pawns[0].Name,
                    traderDesc,
                    leaderDesc
                });
                description = description.AdjustedFor(pawns[0]);
            }
            else
            {
                string traderDesc = (!gotTrader) ? string.Empty : "GroupVisitorsArriveTraderInfo".Translate();
                string leaderDesc = (pawn == null) ? string.Empty : "GroupVisitorsArriveLeaderInfo".Translate(new object[] { pawn.LabelShort });
                label       = "LetterLabelGroupVisitorsArrive".Translate();
                description = "GroupVisitorsArrive".Translate(new object[]
                {
                    faction.Name,
                    traderDesc,
                    leaderDesc
                });
            }
            Find.LetterStack.ReceiveLetter(label, description, LetterDefOf.Good, pawns[0]);
        }
Ejemplo n.º 2
0
        public override void Notify_PawnLost(Pawn p, PawnLostCondition condition)
        {
            base.Notify_PawnLost(p, condition);

            switch (condition)
            {
            case PawnLostCondition.ExitedMap:
            case PawnLostCondition.ChangedFaction:
                //foreach (var action in e.actions.OfType<EventAction_Pawns>()) action.RemovePawn(p);
                break;

            case PawnLostCondition.Undefined:
            case PawnLostCondition.Vanished:
            case PawnLostCondition.IncappedOrKilled:
            case PawnLostCondition.MadePrisoner:
            case PawnLostCondition.LeftVoluntarily:
            case PawnLostCondition.Drafted:
                Hospitality_MapComponent.Instance(lord.Map).QueueEvent(new Event
                {
                    delayTicks = (int)(GenDate.TicksPerHour * Rand.Range(1f, 3f)),
                    actions    =
                        new List <EventAction>
                    {
                        new EventAction_AngerForPawn(p, faction),
                        new EventAction_BreakPawns(new List <Pawn> {
                            p
                        })
                    }
                });
                break;

            default:
                throw new ArgumentOutOfRangeException("condition");
            }
        }
        private static void ShowAskMayComeDialog(Faction faction, Map map, TaggedString reasons, Direction8Way spawnDirection, Action allow, Action refuse)
        {
            var text = "VisitorsArrivedDesc".Translate(faction, reasons);

            DiaNode   diaNode   = new DiaNode(text);
            DiaOption diaOption = new DiaOption("VisitorsArrivedAccept".Translate())
            {
                action = allow, resolveTree = true
            };

            diaNode.options.Add(diaOption);

            DiaOption diaOption2 = new DiaOption("VisitorsArrivedRefuse".Translate())
            {
                action = refuse, resolveTree = true
            };

            diaNode.options.Add(diaOption2);

            if (!map.listerBuildings.AllBuildingsColonistOfClass <Building_GuestBed>().Any())
            {
                DiaOption diaOption3 = new DiaOption("VisitorsArrivedRefuseUntilBeds".Translate());
                diaOption3.resolveTree = true;
                diaOption3.action      = () => {
                    Hospitality_MapComponent.RefuseGuestsUntilWeHaveBeds(map);
                    refuse();
                };
                diaNode.options.Add(diaOption3);
            }

            string title = "VisitorsArrivedTitle".Translate(new NamedArgument((MapParent)map.ParentHolder, "WORLDOBJECT"), spawnDirection.LabelShort());

            Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true, title));
        }
Ejemplo n.º 4
0
        private void SetDefaults(PrisonerInteractionModeDef mode)
        {
            Map map = SelPawn.MapHeld;

            if (map == null)
            {
                return;
            }

            var oldMode = Hospitality_MapComponent.Instance(map).defaultInteractionMode;

            if (oldMode == mode)
            {
                return;
            }

            Hospitality_MapComponent.Instance(map).defaultInteractionMode = mode;

            var guests = GuestUtility.GetAllGuests(map);

            foreach (var guest in guests)
            {
                var comp = guest.GetComp <CompGuest>();
                if (comp == null)
                {
                    continue;
                }
                comp.chat = mode == PrisonerInteractionModeDefOf.Chat;
            }
        }
Ejemplo n.º 5
0
        private void SetAllDefaults(Pawn pawn)
        {
            Map map = SelPawn.MapHeld;

            if (map == null)
            {
                return;
            }

            var mapComp = Hospitality_MapComponent.Instance(map);

            if (pawn.GetComp <CompGuest>() != null)
            {
                mapComp.defaultInteractionMode = pawn.GetComp <CompGuest>().chat ? PrisonerInteractionModeDefOf.ReduceResistance : PrisonerInteractionModeDefOf.NoInteraction;
            }

            mapComp.defaultAreaRestriction = pawn.GetGuestArea();
            mapComp.defaultAreaShopping    = pawn.GetShoppingArea();

            var guests = GuestUtility.GetAllGuests(map);

            foreach (var guest in guests)
            {
                var comp = guest.GetComp <CompGuest>();
                if (comp != null)
                {
                    comp.chat         = mapComp.defaultInteractionMode == PrisonerInteractionModeDefOf.ReduceResistance;
                    comp.GuestArea    = mapComp.defaultAreaRestriction;
                    comp.ShoppingArea = mapComp.defaultAreaShopping;
                }
            }
        }
        private Dictionary<int, int> bribeCount = new Dictionary<int, int>(); // uses faction.randomKey

        #endregion Fields

        #region Constructors

        public Hospitality_MapComponent()
        {
            // Inject MapComponent
            Instance = (Hospitality_MapComponent) Find.Map.components.FirstOrDefault(c => c is Hospitality_MapComponent) ?? this;

            // Inject tab
            InjectTab(typeof (ITab_Pawn_Guest), def => def.race != null && def.race.Humanlike);
        }
Ejemplo n.º 7
0
        public static void PlanNewVisit(IIncidentTarget map, float afterDays, Faction faction = null)
        {
            var realMap = map as Map;

            if (realMap == null)
            {
                return;
            }

            IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.AllyArrival, realMap);

            if (faction != null)
            {
                incidentParms.faction = faction;
            }
            var incident = new FiringIncident(IncidentDefOf.VisitorGroup, null, incidentParms);

            Hospitality_MapComponent.Instance(realMap).QueueIncident(incident, afterDays);
        }
Ejemplo n.º 8
0
        private void SetAllDefaults(Pawn pawn)
        {
            Map map = SelPawn.MapHeld;

            if (map == null)
            {
                return;
            }

            var mapComp = Hospitality_MapComponent.Instance(map);

            if (pawn.GetComp <CompGuest>() != null)
            {
                mapComp.defaultInteractionMode = pawn.GetComp <CompGuest>().chat
                ? PrisonerInteractionModeDefOf.Chat
                : PrisonerInteractionModeDefOf.NoInteraction;

                mapComp.defaultMayBuy = pawn.GetComp <CompGuest>().mayBuy;
            }

            if (pawn.playerSettings != null)
            {
                mapComp.defaultAreaRestriction = pawn.GetComp <CompGuest>().GuestArea;
            }

            var guests = GuestUtility.GetAllGuests(map);

            foreach (var guest in guests)
            {
                var comp = guest.GetComp <CompGuest>();
                if (comp != null)
                {
                    comp.chat      = mapComp.defaultInteractionMode == PrisonerInteractionModeDefOf.Chat;
                    comp.GuestArea = mapComp.defaultAreaRestriction;
                    comp.mayBuy    = mapComp.defaultMayBuy;
                }
            }
        }
        private static void CreateLord(Faction faction, IntVec3 chillSpot, List <Pawn> pawns, Map map)
        {
            var mapComp = Hospitality_MapComponent.Instance(map);

            int stayDuration = (int)(Rand.Range(1f, 2.4f) * GenDate.TicksPerDay);
            var lordJob      = new LordJob_VisitColony(faction, chillSpot, stayDuration);

            LordMaker.MakeNewLord(faction, lordJob, map, pawns);


            // Set default interaction
            pawns.ForEach(delegate(Pawn p) {
                var compGuest = p.GetComp <CompGuest>();
                if (compGuest != null)
                {
                    compGuest.chat         = mapComp.defaultInteractionMode == PrisonerInteractionModeDefOf.ReduceResistance;
                    compGuest.GuestArea    = mapComp.defaultAreaRestriction;
                    compGuest.ShoppingArea = mapComp.defaultAreaShopping;
                }
            });

            bool gotTrader   = false;
            int  traderIndex = 0;

            if (Rand.Value < 0.75f)
            {
                gotTrader = TryConvertOnePawnToSmallTrader(pawns, faction, map, out traderIndex);
            }
            string label;
            string description;
            Pawn   pawn = pawns.Find(x => faction.leader == x);

            if (pawns.Count == 1)
            {
                string traderDesc = !gotTrader ? string.Empty : "SingleVisitorArrivesTraderInfo".Translate();
                string leaderDesc = (pawn == null) ? string.Empty : "SingleVisitorArrivesLeaderInfo".Translate();
                label       = "LetterLabelSingleVisitorArrives".Translate();
                description = "SingleVisitorArrives".Translate(new object[]
                {
                    pawns[0].story.Title,
                    faction.Name,
                    pawns[0].Name,
                    traderDesc,
                    leaderDesc
                });
                description = description.AdjustedFor(pawns[0]);
            }
            else
            {
                string traderDesc = (!gotTrader) ? string.Empty : "GroupVisitorsArriveTraderInfo".Translate();
                string leaderDesc = (pawn == null) ? string.Empty : "GroupVisitorsArriveLeaderInfo".Translate(new object[] { pawn.LabelShort });
                label       = "LetterLabelGroupVisitorsArrive".Translate();
                description = "GroupVisitorsArrive".Translate(new object[]
                {
                    faction.Name,
                    traderDesc,
                    leaderDesc
                });
            }
            // NEW
            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(pawns, ref label, ref description, "LetterRelatedPawnsNeutralGroup".Translate(new object[]
            {
                Faction.OfPlayer.def.pawnsPlural
            }), true, true);
            //Find.LetterStack.ReceiveLetter(label, description, LetterDefOf.NeutralEvent, pawns[0], faction, null);
            var lookTarget = gotTrader ? pawns[traderIndex] : pawns[0];

            Find.LetterStack.ReceiveLetter(label, description, LetterDefOf.PositiveEvent, lookTarget, faction);
        }