コード例 #1
0
        private bool TryFormAndSendCaravan()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);

            if (!this.CheckForErrors(pawnsFromTransferables))
            {
                return(false);
            }
            Direction8Way direction8WayFromTo = Find.WorldGrid.GetDirection8WayFromTo(this.CurrentTile, this.startingTile);
            IntVec3       intVec;

            if (!this.TryFindExitSpot(pawnsFromTransferables, true, out intVec))
            {
                if (!this.TryFindExitSpot(pawnsFromTransferables, false, out intVec))
                {
                    Messages.Message("CaravanCouldNotFindExitSpot".Translate(direction8WayFromTo.LabelShort()), MessageTypeDefOf.RejectInput, false);
                    return(false);
                }
                Messages.Message("CaravanCouldNotFindReachableExitSpot".Translate(direction8WayFromTo.LabelShort()), new GlobalTargetInfo(intVec, this.map, false), MessageTypeDefOf.CautionInput, false);
            }
            IntVec3 meetingPoint;

            if (!this.TryFindRandomPackingSpot(intVec, out meetingPoint))
            {
                Messages.Message("CaravanCouldNotFindPackingSpot".Translate(direction8WayFromTo.LabelShort()), new GlobalTargetInfo(intVec, this.map, false), MessageTypeDefOf.RejectInput, false);
                return(false);
            }
            CaravanFormingUtility.StartFormingCaravan((from x in pawnsFromTransferables
                                                       where !x.Downed
                                                       select x).ToList <Pawn>(), (from x in pawnsFromTransferables
                                                                                   where x.Downed
                                                                                   select x).ToList <Pawn>(), Faction.OfPlayer, this.transferables, meetingPoint, intVec, this.startingTile, this.destinationTile);
            Messages.Message("CaravanFormationProcessStarted".Translate(), pawnsFromTransferables[0], MessageTypeDefOf.PositiveEvent, false);
            return(true);
        }
コード例 #2
0
ファイル: Dialog_FormCaravan.cs プロジェクト: potsh/RimWorld
        private bool TryFormAndSendCaravan()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(transferables);

            if (!CheckForErrors(pawnsFromTransferables))
            {
                return(false);
            }
            Direction8Way direction8WayFromTo = Find.WorldGrid.GetDirection8WayFromTo(CurrentTile, startingTile);

            if (!TryFindExitSpot(pawnsFromTransferables, reachableForEveryColonist: true, out IntVec3 spot))
            {
                if (!TryFindExitSpot(pawnsFromTransferables, reachableForEveryColonist: false, out spot))
                {
                    Messages.Message("CaravanCouldNotFindExitSpot".Translate(direction8WayFromTo.LabelShort()), MessageTypeDefOf.RejectInput, historical: false);
                    return(false);
                }
                Messages.Message("CaravanCouldNotFindReachableExitSpot".Translate(direction8WayFromTo.LabelShort()), new GlobalTargetInfo(spot, map), MessageTypeDefOf.CautionInput, historical: false);
            }
            if (!TryFindRandomPackingSpot(spot, out IntVec3 packingSpot))
            {
                Messages.Message("CaravanCouldNotFindPackingSpot".Translate(direction8WayFromTo.LabelShort()), new GlobalTargetInfo(spot, map), MessageTypeDefOf.RejectInput, historical: false);
                return(false);
            }
            CaravanFormingUtility.StartFormingCaravan((from x in pawnsFromTransferables
                                                       where !x.Downed
                                                       select x).ToList(), (from x in pawnsFromTransferables
                                                                            where x.Downed
                                                                            select x).ToList(), Faction.OfPlayer, transferables, packingSpot, spot, startingTile, destinationTile);
            Messages.Message("CaravanFormationProcessStarted".Translate(), pawnsFromTransferables[0], MessageTypeDefOf.PositiveEvent, historical: false);
            return(true);
        }
コード例 #3
0
        private bool TryFormAndSendCaravan()
        {
            List <Pawn> pawnsFromTransferables = TransferableUtility.GetPawnsFromTransferables(this.transferables);

            if (!this.CheckForErrors(pawnsFromTransferables))
            {
                return(false);
            }
            Direction8Way direction8WayFromTo = Find.WorldGrid.GetDirection8WayFromTo(this.CurrentTile, this.startingTile);
            IntVec3       intVec;

            if (!this.TryFindExitSpot(pawnsFromTransferables, true, out intVec))
            {
                if (!this.TryFindExitSpot(pawnsFromTransferables, false, out intVec))
                {
                    Messages.Message("CaravanCouldNotFindExitSpot".Translate(new object[]
                    {
                        direction8WayFromTo.LabelShort()
                    }), MessageSound.RejectInput);
                    return(false);
                }
                Messages.Message("CaravanCouldNotFindReachableExitSpot".Translate(new object[]
                {
                    direction8WayFromTo.LabelShort()
                }), new GlobalTargetInfo(intVec, this.map, false), MessageSound.Negative);
            }
            IntVec3 meetingPoint;

            if (!this.TryFindRandomPackingSpot(intVec, out meetingPoint))
            {
                Messages.Message("CaravanCouldNotFindPackingSpot".Translate(new object[]
                {
                    direction8WayFromTo.LabelShort()
                }), new GlobalTargetInfo(intVec, this.map, false), MessageSound.RejectInput);
                return(false);
            }
            CaravanFormingUtility.StartFormingCaravan(pawnsFromTransferables, Faction.OfPlayer, this.transferables, meetingPoint, intVec, this.startingTile);
            Messages.Message("CaravanFormationProcessStarted".Translate(), pawnsFromTransferables[0], MessageSound.Benefit);
            return(true);
        }
コード例 #4
0
        private static void ShowAskMayComeDialog(Faction faction, Map map, string reasons, Direction8Way spawnDirection, Action allow, Action refuse)
        {
            string text = "VisitorsArrivedDesc".Translate(faction, reasons);

            DiaNode   diaNode   = new DiaNode(text);
            DiaOption diaOption = new DiaOption("VisitorsArrivedAccept".Translate());

            diaOption.action      = allow;
            diaOption.resolveTree = true;
            diaNode.options.Add(diaOption);

            DiaOption diaOption2 = new DiaOption("VisitorsArrivedRefuse".Translate());

            diaOption2.action      = refuse;
            diaOption2.resolveTree = true;
            diaNode.options.Add(diaOption2);

            var    location = ((MapParent)map.ParentHolder).Label;
            string title    = "VisitorsArrivedTitle".Translate(location, spawnDirection.LabelShort());

            Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true, title));
        }
コード例 #5
0
        private void DrawConfig(Rect rect)
        {
            Rect rect2 = new Rect(0f, rect.y, rect.width, 30f);

            Text.Font = GameFont.Medium;
            Widgets.Label(rect2, "ExitDirection".Translate());
            Text.Font = GameFont.Small;
            List <int> list = CaravanExitMapUtility.AvailableExitTilesAt(this.map);

            if (list.Any <int>())
            {
                for (int i = 0; i < list.Count; i++)
                {
                    Direction8Way direction8WayFromTo = Find.WorldGrid.GetDirection8WayFromTo(this.CurrentTile, list[i]);
                    float         y         = rect.y + (float)i * this.ExitDirectionRadioSize.y + 30f + 4f;
                    Rect          rect3     = new Rect(rect.x, y, this.ExitDirectionRadioSize.x, this.ExitDirectionRadioSize.y);
                    Vector2       vector    = Find.WorldGrid.LongLatOf(list[i]);
                    string        labelText = "ExitDirectionRadioButtonLabel".Translate(new object[]
                    {
                        direction8WayFromTo.LabelShort(),
                        vector.y.ToStringLatitude(),
                        vector.x.ToStringLongitude()
                    });
                    if (Widgets.RadioButtonLabeled(rect3, labelText, this.startingTile == list[i]))
                    {
                        this.startingTile = list[i];
                    }
                }
            }
            else
            {
                GUI.color = Color.gray;
                Widgets.Label(new Rect(rect.x, rect.y + 30f + 4f, rect.width, 100f), "NoCaravanExitDirectionAvailable".Translate());
                GUI.color = Color.white;
            }
        }
コード例 #6
0
        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));
        }