示例#1
0
        public static War MakeWar(string warName, WarGoalDef goal, FactionInteraction declaredWarFaction, FactionInteraction defendingFaction)
        {
            War war = new War(warName, goal, declaredWarFaction, defendingFaction);

            war.id = QuestsManager.Communications.UniqueIdManager.GetNextWarID();

            return(war);
        }
示例#2
0
文件: War.cs 项目: SwimUp/moreevents
        public War(string warName, WarGoalDef goal, FactionInteraction declaredWarFaction, FactionInteraction defendingFaction)
        {
            DeclaredWarFaction = declaredWarFaction;
            DefendingFaction   = defendingFaction;

            WarGoalDef = goal;
            WarName    = warName;

            AssaultFactions = new List <FactionInteraction>()
            {
                declaredWarFaction
            };
            var attackedAlliance = AttackedAlliance;

            if (attackedAlliance != null)
            {
                foreach (var faction in attackedAlliance.Factions)
                {
                    if (faction == DeclaredWarFaction)
                    {
                        continue;
                    }

                    AssaultFactions.Add(faction);
                }
            }

            DefendingFactions = new List <FactionInteraction> {
                defendingFaction
            };
            var defendAlliance = DefendAlliance;

            if (defendAlliance != null)
            {
                foreach (var faction in defendAlliance.Factions)
                {
                    if (faction == DefendingFaction)
                    {
                        continue;
                    }

                    DefendingFactions.Add(faction);
                }
            }

            StartTicks = Find.TickManager.TicksGame;
        }
示例#3
0
        public MakeWarWindow(FactionInteraction faction, Pawn speaker, Pawn defendant)
        {
            doCloseX   = true;
            forcePause = true;

            interactFaction = faction;

            this.speaker   = speaker;
            this.defendant = defendant;

            defendMode = faction.InWars.Any(x => x.DefendingFactions.Contains(faction) && x.DeclaredWarFaction.Faction == speaker.Faction);

            if (defendMode)
            {
                war  = faction.InWars.First(x => x.DeclaredWarFaction.Faction == speaker.Faction);
                stat = war.StatWorker.GetStat();
            }

            warGoalDef = DefDatabase <WarGoalDef> .AllDefs.First();
        }
示例#4
0
        private void DrawWarMode(Rect inRect)
        {
            Text.Anchor = TextAnchor.MiddleCenter;

            float y         = inRect.y;
            Rect  titleRect = new Rect(inRect.x, y, inRect.width, 25);

            Widgets.Label(titleRect, "MakeWarWindow_DrawWarModeTitle".Translate(interactFaction.Faction.Name));

            y += 30;
            Rect selectWarGoalRect = new Rect(inRect.x, y, inRect.width, 25);

            if (GUIUtils.DrawCustomButton(selectWarGoalRect, "MakeWarWindow_DrawWarMode_SelectWarGoal".Translate(warGoalDef.LabelCap), Color.white))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (var goal in DefDatabase <WarGoalDef> .AllDefs)
                {
                    options.Add(new FloatMenuOption(goal.LabelCap, delegate
                    {
                        warGoalDef = goal;
                    }));
                }

                Find.WindowStack.Add(new FloatMenu(options));
            }

            y += 28;

            Text.Anchor = TextAnchor.UpperLeft;

            float height       = inRect.height - y - 80;
            Rect  fullInfoRect = new Rect(inRect.x, y, inRect.width, height);

            Widgets.Label(fullInfoRect, warGoalDef.description);

            y += height;

            Text.Anchor = TextAnchor.MiddleCenter;
            Rect warNameRect = new Rect(inRect.x, y, inRect.width, 25);

            Widgets.Label(warNameRect, "MakeWarWindow_WarNameLabel".Translate());
            y             += 22;
            warNameRect.y += 22;
            editBufferName = Widgets.TextField(warNameRect, editBufferName);

            y += 30;

            Rect createWarButtonRect = new Rect(inRect.x, y, inRect.width, 25);

            if (GUIUtils.DrawCustomButton(createWarButtonRect, "MakeWarWindow_DrawWarMode_MakeWar".Translate(interactFaction.Faction.Name), Color.white))
            {
                if (string.IsNullOrEmpty(editBufferName))
                {
                    Messages.Message("MakeWarWindow_EmptyName".Translate(), MessageTypeDefOf.NeutralEvent);
                }
                else
                {
                    War war = WarMaker.MakeWar(editBufferName, warGoalDef, QuestsManager.Communications.FactionManager.GetInteraction(speaker.Faction), interactFaction);

                    QuestsManager.Communications.FactionManager.AddWar(war);

                    war.StartWar();

                    Close();
                }
            }

            Text.Anchor = TextAnchor.UpperLeft;
        }