コード例 #1
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 4)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            GameComponentPawns gameComponent = Current.Game.GetComponent <GameComponentPawns>();

            if (!gameComponent.HasUserBeenNamed(viewer.username))
            {
                Toolkit.client.SendMessage($"@{viewer.username} you must be in the colony to use this command.", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[3],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            string          skillKind = command[2].ToLower();
            List <SkillDef> allSkills = DefDatabase <SkillDef> .AllDefs.Where(s =>
                                                                              string.Join("", s.defName.Split(' ')).ToLower() == skillKind ||
                                                                              string.Join("", s.label.Split(' ')).ToLower() == skillKind
                                                                              ).ToList();

            if (allSkills.Count < 1)
            {
                Toolkit.client.SendMessage($"@{viewer.username} skill {skillKind} not found.", separateChannel);
                return(false);
            }

            skill = allSkills[0];
            pawn  = gameComponent.PawnAssignedToUser(viewer.username);

            if (pawn.skills.GetSkill(skill).TotallyDisabled)
            {
                Toolkit.client.SendMessage($"@{viewer.username} skill {skillKind} disabled on your pawn.", separateChannel);
                return(false);
            }

            if (pawn.skills.GetSkill(skill).levelInt >= 20)
            {
                Toolkit.client.SendMessage($"@{viewer.username} skill {skillKind} disabled on your pawn.", separateChannel);
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            ToolkitPatchLogger.Log(incidentDef.defName, "Checking if possible..");
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            ToolkitPatchLogger.Log(incidentDef.defName, $"Got the points wager of '{pointsWager}' and incident of '{storeIncident.abbreviation}:{storeIncident.defName}'");

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            ToolkitPatchLogger.Log(incidentDef.defName, $"Target found '{target.Tile}'");

            parms        = StorytellerUtility.DefaultParmsNow(categoryDef, target);
            parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points);
            if (raidStratDef != null)
            {
                parms.raidStrategy = raidStratDef;
            }
            if (pawnArrivalModeDef != null)
            {
                parms.raidArrivalMode = pawnArrivalModeDef;
            }

            worker     = Activator.CreateInstance <T>();
            worker.def = incidentDef;

            bool success = worker.CanFireNow(parms);

            if (!success)
            {
                WorkerCanFireCheck.CheckDefaultFireNowConditions(worker, parms, incidentDef);
            }

            ToolkitPatchLogger.Log(incidentDef.defName, $"Can fire with params '{parms.ToString()}' on worker {worker.ToString()}? {success}");

            return(success);
        }
コード例 #3
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 4)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[3],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            string animalKind = command[2].ToLower();


            List <PawnKindDef> allAnimals = DefDatabase <PawnKindDef> .AllDefs.Where(
                s => s.RaceProps.Animal &&
                string.Join("", s.defName.Split(' ')).ToLower() == animalKind
                ).ToList();

            if (allAnimals.Count < 1)
            {
                Toolkit.client.SendMessage($"@{viewer.username} no animal {animalKind} found.", separateChannel);
                return(false);
            }

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            float points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, StorytellerUtility.DefaultThreatPointsNow(target));

            pawnKind = allAnimals[0];
            int num = ManhunterPackIncidentUtility.GetAnimalsCount(pawnKind, points);

            worker = new IncidentWorker_SpecificAnimalsWanderIn(null, pawnKind, true, num, false, true);

            worker.def = IncidentDef.Named("FarmAnimalsWanderIn");

            float defaultThreatPoints = StorytellerUtility.DefaultSiteThreatPointsNow();

            parms        = StorytellerUtility.DefaultParmsNow(worker.def.category, target);
            parms.points = points;
            return(worker.CanFireNow(parms));
        }
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                VariablesHelpers.ViewerDidWrongSyntax(viewer.username, storeIncident.syntax, separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                ToolkitPatchLogger.Log(LOGGER_NAME, "Cannot fire custom manhunter. No valid points wagered");
                return(false);
            }

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                ToolkitPatchLogger.Log(LOGGER_NAME, "Cannot fire custom manhunter. No valid tile");
                return(false);
            }

            parms        = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.RaidBeacon, target);
            parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points);

            IEnumerable <string> animals = Settings.AnimalMap.Where(x => x.Value).Select(x => x.Key);

            ToolkitPatchLogger.Log(LOGGER_NAME, $"{animals.Count()}/{Settings.AnimalMap.Count} animals for selection.");

            string animal = animals.RandomElement();

            ToolkitPatchLogger.Log(LOGGER_NAME, $"Chose animal {animal} for the attack beast");

            ThingDef def = ThingDef.Named(animal);

            worker     = new CustomManhunterIncidentWorker(PawnKindDef.Named(animal));
            worker.def = IncidentDef.Named("BeastAttack");

            bool success = worker.CanFireNow(parms);

            if (!success)
            {
                WorkerCanFireCheck.CheckDefaultFireNowConditions(worker, parms, worker.def);
            }

            return(success);
        }
コード例 #5
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 4)
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}");
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[3],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            string diseaseLabel = command[2].ToLower();

            worker = new IncidentWorker_DiseaseHuman();
            List <IncidentDef> allDiseases = DefDatabase <IncidentDef> .AllDefs.Where(s =>
                                                                                      s.category == IncidentCategoryDefOf.DiseaseHuman &&
                                                                                      string.Join("", s.LabelCap.RawText.Split(' ')).ToLower() == diseaseLabel
                                                                                      ).ToList();

            if (allDiseases.Count < 1)
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} no disease {diseaseLabel} found.");
                return(false);
            }

            allDiseases.Shuffle();
            worker.def = allDiseases[0];

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            float defaultThreatPoints = StorytellerUtility.DefaultSiteThreatPointsNow();

            parms        = StorytellerUtility.DefaultParmsNow(worker.def.category, target);
            parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, StorytellerUtility.DefaultThreatPointsNow(target));
            return(worker.CanFireNow(parms));
        }
コード例 #6
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            Log.Warning("found target");

            parms        = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatBig, target);
            parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, StorytellerUtility.DefaultThreatPointsNow(target));
            parms.forced = true;

            Log.Warning("genned parms");

            worker     = new IncidentWorker_Infestation();
            worker.def = IncidentDef.Named("Infestation");

            bool canFire = worker.CanFireNow(parms);

            if (!canFire)
            {
                Toolkit.client.SendMessage($"@{viewer.username} Found no place for infestation to occur.", separateChannel);
            }

            return(canFire);
        }
コード例 #7
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            Log.Warning("Finding target");

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            parms                 = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.RaidBeacon, target);
            parms.points          = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points);
            parms.raidStrategy    = RaidStrategyDefOf.ImmediateAttack;
            parms.raidArrivalMode = PawnsArrivalModeDefOf.CenterDrop;
            parms.faction         = Find.FactionManager.RandomEnemyFaction(false, false, false, TechLevel.Industrial);

            worker     = new Incidents.IncidentWorker_RaidEnemy();
            worker.def = IncidentDefOf.RaidEnemy;

            return(worker.CanFireNow(parms));
        }
コード例 #8
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                TwitchWrapper.SendChatMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}");
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            parms              = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatSmall, target);
            parms.points       = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points);
            parms.raidStrategy = DefDatabase <RaidStrategyDef> .GetNamed("Siege");

            //parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeDrop;
            parms.faction = Find.FactionManager.RandomEnemyFaction(false, false, false, TechLevel.Industrial);

            worker     = new Incidents.IncidentWorker_RaidEnemy();
            worker.def = IncidentDefOf.RaidEnemy;

            return(worker.CanFireNow(parms));
        }
コード例 #9
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            worker = new IncidentWorker_DiseaseHuman();
            List <IncidentDef> allDiseases = DefDatabase <IncidentDef> .AllDefs.Where(s => s.workerClass == typeof(IncidentWorker_DiseaseHuman)).ToList();

            allDiseases.Shuffle();
            worker.def = allDiseases[0];

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            float defaultThreatPoints = StorytellerUtility.DefaultSiteThreatPointsNow();

            parms        = StorytellerUtility.DefaultParmsNow(worker.def.category, target);
            parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, StorytellerUtility.DefaultThreatPointsNow(target));
            return(worker.CanFireNow(parms));
        }
コード例 #10
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                Toolkit.client.SendMessage($"@{viewer.username} syntax is {this.storeIncident.syntax}", separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            parms         = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.RaidBeacon, target);
            parms.points  = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points);
            parms         = StorytellerUtility.DefaultParmsNow(worker.def.category, target);
            parms.faction = Find.FactionManager.OfInsects;

            worker     = new IncidentWorker_Infestation();
            worker.def = IncidentDef.Named("Infestation");


            return(worker.CanFireNow(parms));
        }
コード例 #11
0
        public override bool CanHappen(string msg, Viewer viewer)
        {
            if (!Data.TryGetValue(storeIncident.defName, out _data))
            {
                return(false);
            }

            if (!_data.UseStoryteller)
            {
                string rawPoints = CommandFilter.Parse(msg).Skip(2).FirstOrDefault();

                if (rawPoints.NullOrEmpty() || !VariablesHelpers.PointsWagerIsValid(rawPoints, viewer, ref _wager, ref storeIncident))
                {
                    return(false);
                }
            }

            Map map = Find.RandomPlayerHomeMap;

            _worker = Activator.CreateInstance(_data.WorkerClass) as IncidentWorker;

            if (_worker == null || map == null)
            {
                return(false);
            }

            _params = StorytellerUtility.DefaultParmsNow(_data.ResolveCategory(_worker, storeIncident), map);

            if (!_data.UseStoryteller)
            {
                _params.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, _wager, _params.points);
            }

            _params.forced = true;
            _data.DoExtraSetup(_worker, _params, storeIncident);

            return(_worker.CanFireNow(_params));
        }
コード例 #12
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                VariablesHelpers.ViewerDidWrongSyntax(viewer.username, storeIncident.syntax, separateChannel);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            parms        = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.RaidBeacon, target);
            parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points);

            worker     = new IncidentWorker_ManhunterPack();
            worker.def = IncidentDefOf.RaidEnemy;

            return(worker.CanFireNow(parms));
        }
コード例 #13
0
        public override bool IsPossible(string message, Viewer viewer, bool separateChannel = false)
        {
            this.separateChannel = separateChannel;
            this.Viewer          = viewer;
            string[] command = message.Split(' ');
            if (command.Length < 3)
            {
                VariablesHelpers.ViewerDidWrongSyntax(viewer.username, storeIncident.syntax);
                return(false);
            }

            if (!VariablesHelpers.PointsWagerIsValid(
                    command[2],
                    viewer,
                    ref pointsWager,
                    ref storeIncident,
                    separateChannel
                    ))
            {
                return(false);
            }

            target = Current.Game.AnyPlayerHomeMap;
            if (target == null)
            {
                return(false);
            }

            parms        = StorytellerUtility.DefaultParmsNow(IncidentCategoryDefOf.ThreatSmall, target);
            parms.points = IncidentHelper_PointsHelper.RollProportionalGamePoints(storeIncident, pointsWager, parms.points);

            List <string> animals = new List <string>()
            {
                "Bear_Grizzly", "Bear_Polar", "Rhinoceros", "Elephant", "Megasloth", "Thrumbo"
            };

            animals.Shuffle();

            ThingDef def          = ThingDef.Named(animals[0]);
            float    averagePower = 0;

            if (def != null && def.race != null)
            {
                foreach (Tool t in def.tools)
                {
                    averagePower += t.power;
                }
                averagePower = averagePower / def.tools.Count;
            }

            float animalCount = 2.5f;

            if (averagePower > 18)
            {
                animalCount = 2.0f;
            }

            worker     = new IncidentWorker_SpecificAnimalsWanderIn("TwitchStoriesLetterLabelPredators", PawnKindDef.Named(animals[0]), false, (int)animalCount, true, true);
            worker.def = IncidentDef.Named("HerdMigration");

            return(worker.CanFireNow(parms));
        }