Exemplo n.º 1
0
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            Faction faction;

            if (CaravanIncidentUtility.CanFireIncidentWhichWantsToGenerateMapAt(parms.target.Tile))
            {
                return(PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(parms.points, out faction));
            }
            return(false);
        }
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            if (!base.CanFireNowSub(parms))
            {
                return(false);
            }
            Faction faction;

            return(PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(parms.points, out faction));
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            parms.points *= IncidentPointsFactorRange.RandomInRange;
            Caravan caravan = (Caravan)parms.target;

            if (!PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(parms.points, out parms.faction))
            {
                return(false);
            }
            List <ThingCount> demands = GenerateDemands(caravan);

            if (demands.NullOrEmpty())
            {
                return(false);
            }
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, parms);

            defaultPawnGroupMakerParms.generateFightersOnly            = true;
            defaultPawnGroupMakerParms.dontUseSingleUseRocketLaunchers = true;
            List <Pawn> attackers = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms).ToList();

            if (attackers.Count == 0)
            {
                Log.Error("Caravan demand incident couldn't generate any enemies even though min points have been checked. faction=" + defaultPawnGroupMakerParms.faction + "(" + ((defaultPawnGroupMakerParms.faction == null) ? "null" : defaultPawnGroupMakerParms.faction.def.ToString()) + ") parms=" + parms);
                return(false);
            }
            CameraJumper.TryJumpAndSelect(caravan);
            DiaNode   diaNode   = new DiaNode(GenerateMessageText(parms.faction, attackers.Count, demands, caravan));
            DiaOption diaOption = new DiaOption("CaravanDemand_Give".Translate());

            diaOption.action = delegate
            {
                ActionGive(caravan, demands, attackers);
            };
            diaOption.resolveTree = true;
            diaNode.options.Add(diaOption);
            DiaOption diaOption2 = new DiaOption("CaravanDemand_Fight".Translate());

            diaOption2.action = delegate
            {
                ActionFight(caravan, attackers);
            };
            diaOption2.resolveTree = true;
            diaNode.options.Add(diaOption2);
            string      text               = "CaravanDemandTitle".Translate(parms.faction.Name);
            WindowStack windowStack        = Find.WindowStack;
            DiaNode     nodeRoot           = diaNode;
            Faction     faction            = parms.faction;
            bool        delayInteractivity = true;
            string      title              = text;

            windowStack.Add(new Dialog_NodeTreeWithFactionInfo(nodeRoot, faction, delayInteractivity, radioMode: false, title));
            Find.Archive.Add(new ArchivedDialog(diaNode.text, text, parms.faction));
            return(true);
        }
Exemplo n.º 4
0
        protected override List <Pawn> GeneratePawns(IncidentParms parms)
        {
            if (!PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(parms.points, out parms.faction, null, false, false, false, true))
            {
                Log.Error("Could not find any valid faction for " + this.def + " incident.", false);
                return(new List <Pawn>());
            }
            PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, parms, false);

            defaultPawnGroupMakerParms.generateFightersOnly            = true;
            defaultPawnGroupMakerParms.dontUseSingleUseRocketLaunchers = true;
            return(PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms, true).ToList <Pawn>());
        }
        protected override bool TryResolveRaidFaction(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (parms.faction != null)
            {
                return(true);
            }
            float num = parms.points;

            if (num <= 0f)
            {
                num = 999999f;
            }
            return(PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(num, out parms.faction, (Faction f) => this.FactionCanBeGroupSource(f, map, false), true, true, true, true) || PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(num, out parms.faction, (Faction f) => this.FactionCanBeGroupSource(f, map, true), true, true, true, true));
        }
        // Token: 0x06000ECD RID: 3789 RVA: 0x0006EC50 File Offset: 0x0006D050
        protected override bool TryResolveRaidFaction(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (this.Def.Faction != null)
            {
                if (Find.FactionManager.FirstFactionOfDef(this.Def.Faction) != null)
                {
                    parms.faction = Find.FactionManager.FirstFactionOfDef(this.Def.Faction);
                }
            }
            if (!this.Def.Factions.NullOrEmpty())
            {
                for (int i = 0; i < this.Def.Factions.Count * 10; i++)
                {
                    Faction faction = Find.FactionManager.AllFactionsListForReading.FindAll(x => this.Def.Factions.Any(y => x.def == y && x.HostileTo(Faction.OfPlayer))).RandomElementByWeight(z => z.def.RaidCommonalityFromPoints(parms.points));
                    if (faction != null && faction.HostileTo(Faction.OfPlayer))
                    {
                        parms.faction = faction;
                        break;
                    }
                }
            }
            if (parms.faction != null)
            {
                if (!parms.faction.HostileTo(Faction.OfPlayer))
                {
                    return(false);
                }
                return(true);
            }
            float num = parms.points;

            if (num <= 0f)
            {
                num = 999999f;
            }
            return(PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(num, out parms.faction, (Faction f) => this.FactionCanBeGroupSource(f, map, false), true, true, true, true) || PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(num, out parms.faction, (Faction f) => this.FactionCanBeGroupSource(f, map, true), true, true, true, true));
        }
Exemplo n.º 7
0
        protected override bool TryResolveRaidFaction(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (parms.faction != null)
            {
                return(true);
            }
            float num = parms.points;

            if (num <= 0f)
            {
                num = 999999f;
            }
            if (PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(num, out parms.faction, (Faction f) => FactionCanBeGroupSource(f, map), allowNonHostileToPlayer: true, allowHidden: true, allowDefeated: true))
            {
                return(true);
            }
            if (PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(num, out parms.faction, (Faction f) => FactionCanBeGroupSource(f, map, desperate: true), allowNonHostileToPlayer: true, allowHidden: true, allowDefeated: true))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 8
0
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            Faction faction;

            return(base.CanFireNowSub(parms) && PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(parms.points, out faction, null, false, false, false, true));
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            parms.points *= 1.5f;
            Caravan caravan = (Caravan)parms.target;
            bool    result;

            if (!PawnGroupMakerUtility.TryGetRandomFactionForCombatPawnGroup(parms.points, out parms.faction, null, false, false, false, true))
            {
                result = false;
            }
            else
            {
                PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, parms, false);
                defaultPawnGroupMakerParms.generateFightersOnly            = true;
                defaultPawnGroupMakerParms.dontUseSingleUseRocketLaunchers = true;
                List <Pawn> attackers = PawnGroupMakerUtility.GeneratePawns(defaultPawnGroupMakerParms, true).ToList <Pawn>();
                if (attackers.Count == 0)
                {
                    Log.Error(string.Concat(new object[]
                    {
                        "Caravan demand incident couldn't generate any enemies even though min points have been checked. faction=",
                        defaultPawnGroupMakerParms.faction,
                        "(",
                        (defaultPawnGroupMakerParms.faction == null) ? "null" : defaultPawnGroupMakerParms.faction.def.ToString(),
                        ") parms=",
                        parms
                    }), false);
                    result = false;
                }
                else
                {
                    List <Thing> demands = this.GenerateDemands(caravan);
                    if (demands.Count == 0)
                    {
                        result = false;
                    }
                    else
                    {
                        CameraJumper.TryJumpAndSelect(caravan);
                        DiaNode   diaNode   = new DiaNode(this.GenerateMessageText(parms.faction, attackers.Count, demands, caravan));
                        DiaOption diaOption = new DiaOption("CaravanDemand_Give".Translate());
                        diaOption.action = delegate()
                        {
                            this.ActionGive(caravan, demands, attackers);
                        };
                        diaOption.resolveTree = true;
                        diaNode.options.Add(diaOption);
                        DiaOption diaOption2 = new DiaOption("CaravanDemand_Fight".Translate());
                        diaOption2.action = delegate()
                        {
                            this.ActionFight(caravan, attackers);
                        };
                        diaOption2.resolveTree = true;
                        diaNode.options.Add(diaOption2);
                        string text = "CaravanDemandTitle".Translate(new object[]
                        {
                            parms.faction.Name
                        });
                        WindowStack windowStack        = Find.WindowStack;
                        DiaNode     nodeRoot           = diaNode;
                        Faction     faction            = parms.faction;
                        bool        delayInteractivity = true;
                        string      title = text;
                        windowStack.Add(new Dialog_NodeTreeWithFactionInfo(nodeRoot, faction, delayInteractivity, false, title));
                        Find.Archive.Add(new ArchivedDialog(diaNode.text, text, parms.faction));
                        result = true;
                    }
                }
            }
            return(result);
        }