Example #1
0
 public IEnumerable <FiringIncident> MakeIncidentsForInterval(StorytellerComp comp, List <IIncidentTarget> targets)
 {
     if (GenDate.DaysPassedFloat <= comp.props.minDaysPassed)
     {
         yield break;
     }
     for (int i = 0; i < targets.Count; i++)
     {
         IIncidentTarget incidentTarget = targets[i];
         bool            flag           = false;
         bool            flag2          = comp.props.allowedTargetTags.NullOrEmpty();
         foreach (IncidentTargetTagDef item in incidentTarget.IncidentTargetTags())
         {
             if (!comp.props.disallowedTargetTags.NullOrEmpty() && comp.props.disallowedTargetTags.Contains(item))
             {
                 flag = true;
                 break;
             }
             if (!flag2 && comp.props.allowedTargetTags.Contains(item))
             {
                 flag2 = true;
             }
         }
         if (!flag && flag2)
         {
             foreach (FiringIncident item2 in comp.MakeIntervalIncidents(incidentTarget))
             {
                 if (Find.Storyteller.difficulty.allowBigThreats || item2.def.category != IncidentCategoryDefOf.ThreatBig)
                 {
                     yield return(item2);
                 }
             }
         }
     }
 }
Example #2
0
 public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
 {
     if (Rand.MTBEventOccurs(this.Props.mtbDays, 60000f, 1000f))
     {
         bool targetIsRaidBeacon = target.IncidentTargetTags().Contains(IncidentTargetTagDefOf.Map_RaidBeacon);
         List <IncidentCategoryDef> triedCategories = new List <IncidentCategoryDef>();
         IncidentDef incDef;
         for (;;)
         {
             IncidentCategoryDef       category = this.ChooseRandomCategory(target, triedCategories);
             IncidentParms             parms    = this.GenerateParms(category, target);
             IEnumerable <IncidentDef> options  = from d in base.UsableIncidentsInCategory(category, target)
                                                  where !d.NeedsParmsPoints || parms.points >= d.minThreatPoints
                                                  select d;
             if (options.TryRandomElementByWeight(new Func <IncidentDef, float>(base.IncidentChanceFinal), out incDef))
             {
                 break;
             }
             triedCategories.Add(category);
             if (triedCategories.Count >= this.Props.categoryWeights.Count)
             {
                 goto Block_6;
             }
         }
         if (!this.Props.skipThreatBigIfRaidBeacon || !targetIsRaidBeacon || incDef.category != IncidentCategoryDefOf.ThreatBig)
         {
             yield return(new FiringIncident(incDef, this, <MakeIntervalIncidents> c__AnonStorey.parms));
         }
         Block_6 :;
     }
     yield break;
 }
Example #3
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (Rand.MTBEventOccurs(Props.mtbDays, 60000f, 1000f))
            {
                bool targetIsRaidBeacon = target.IncidentTargetTags().Contains(IncidentTargetTagDefOf.Map_RaidBeacon);
                List <IncidentCategoryDef> triedCategories = new List <IncidentCategoryDef>();
                IncidentParms parms;
                IncidentDef   incDef;
                while (true)
                {
                    _003CMakeIntervalIncidents_003Ec__Iterator0 _003CMakeIntervalIncidents_003Ec__Iterator = (_003CMakeIntervalIncidents_003Ec__Iterator0) /*Error near IL_007c: stateMachine*/;
                    IncidentCategoryDef category = ChooseRandomCategory(target, triedCategories);
                    parms = GenerateParms(category, target);
                    IEnumerable <IncidentDef> options = from d in UsableIncidentsInCategory(category, target)
                                                        where !d.NeedsParmsPoints || parms.points >= d.minThreatPoints
                                                        select d;
                    if (options.TryRandomElementByWeight(base.IncidentChanceFinal, out incDef))
                    {
                        break;
                    }
                    triedCategories.Add(category);
                    if (triedCategories.Count >= Props.categoryWeights.Count)
                    {
                        yield break;
                    }
                }
                if (!Props.skipThreatBigIfRaidBeacon || !targetIsRaidBeacon || incDef.category != IncidentCategoryDefOf.ThreatBig)
                {
                    yield return(new FiringIncident(incDef, this, parms));

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
        }
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (!Rand.MTBEventOccurs(Props.mtbDays, 60000f, 1000f))
            {
                yield break;
            }
            bool flag = target.IncidentTargetTags().Contains(IncidentTargetTagDefOf.Map_RaidBeacon);
            List <IncidentCategoryDef> list = new List <IncidentCategoryDef>();
            IncidentParms parms;
            IncidentDef   result;

            while (true)
            {
                IncidentCategoryDef incidentCategoryDef = ChooseRandomCategory(target, list);
                parms = GenerateParms(incidentCategoryDef, target);
                if (UsableIncidentsInCategory(incidentCategoryDef, parms).TryRandomElementByWeight(base.IncidentChanceFinal, out result))
                {
                    break;
                }
                list.Add(incidentCategoryDef);
                if (list.Count >= Props.categoryWeights.Count)
                {
                    yield break;
                }
            }
            if (!Props.skipThreatBigIfRaidBeacon || !flag || result.category != IncidentCategoryDefOf.ThreatBig)
            {
                yield return(new FiringIncident(result, this, parms));
            }
        }
Example #5
0
        public IEnumerable <FiringIncident> MakeIncidentsForInterval(StorytellerComp comp, IIncidentTarget targ)
        {
            if (GenDate.DaysPassedFloat <= comp.props.minDaysPassed)
            {
                yield break;
            }
            bool flag  = false;
            bool flag2 = comp.props.allowedTargetTags.NullOrEmpty();

            foreach (IncidentTargetTagDef item in targ.IncidentTargetTags())
            {
                if (!comp.props.disallowedTargetTags.NullOrEmpty() && comp.props.disallowedTargetTags.Contains(item))
                {
                    flag = true;
                    break;
                }
                if (!flag2 && comp.props.allowedTargetTags.Contains(item))
                {
                    flag2 = true;
                }
            }
            if (!flag && flag2)
            {
                foreach (FiringIncident fi in comp.MakeIntervalIncidents(targ))
                {
                    if (Find.Storyteller.difficulty.allowBigThreats || (fi.def.category != IncidentCategoryDefOf.ThreatBig))
                    {
                        yield return(fi);
                    }
                }
            }
        }
Example #6
0
 public IEnumerable <FiringIncident> MakeIncidentsForInterval(StorytellerComp comp, List <IIncidentTarget> targets)
 {
     if (GenDate.DaysPassedFloat > comp.props.minDaysPassed)
     {
         for (int i = 0; i < targets.Count; i++)
         {
             IIncidentTarget targ  = targets[i];
             bool            flag  = false;
             bool            flag2 = comp.props.allowedTargetTags.NullOrEmpty <IncidentTargetTagDef>();
             foreach (IncidentTargetTagDef current in targ.IncidentTargetTags())
             {
                 if (!comp.props.disallowedTargetTags.NullOrEmpty <IncidentTargetTagDef>() && comp.props.disallowedTargetTags.Contains(current))
                 {
                     flag = true;
                     break;
                 }
                 if (!flag2 && comp.props.allowedTargetTags.Contains(current))
                 {
                     flag2 = true;
                 }
             }
             if (!flag && flag2)
             {
                 foreach (FiringIncident fi in comp.MakeIntervalIncidents(targ))
                 {
                     if (Find.Storyteller.difficulty.allowBigThreats || (fi.def.category != IncidentCategoryDefOf.ThreatBig && fi.def.category != IncidentCategoryDefOf.RaidBeacon))
                     {
                         yield return(fi);
                     }
                 }
             }
         }
     }
 }
Example #7
0
        public IEnumerable <FiringIncident> MakeIncidentsForInterval(StorytellerComp comp, List <IIncidentTarget> targets)
        {
            if (!(GenDate.DaysPassedFloat <= comp.props.minDaysPassed))
            {
                for (int i = 0; i < targets.Count; i++)
                {
                    IIncidentTarget targ  = targets[i];
                    bool            flag  = false;
                    bool            flag2 = comp.props.allowedTargetTags.NullOrEmpty();
                    foreach (IncidentTargetTagDef item in targ.IncidentTargetTags())
                    {
                        if (!comp.props.disallowedTargetTags.NullOrEmpty() && comp.props.disallowedTargetTags.Contains(item))
                        {
                            flag = true;
                            break;
                        }
                        if (!flag2 && comp.props.allowedTargetTags.Contains(item))
                        {
                            flag2 = true;
                        }
                    }
                    if (!flag && flag2)
                    {
                        foreach (FiringIncident item2 in comp.MakeIntervalIncidents(targ))
                        {
                            if (Find.Storyteller.difficulty.allowBigThreats || (item2.def.category != IncidentCategoryDefOf.ThreatBig && item2.def.category != IncidentCategoryDefOf.RaidBeacon))
                            {
                                yield return(item2);

                                /*Error: Unable to find new state assignment for yield return*/;
                            }
                        }
                    }
                }
            }
            yield break;
IL_023c:
            /*Error near IL_023d: Unexpected return in MoveNext()*/;
        }
Example #8
0
 public bool TargetAllowed(IIncidentTarget target)
 {
     return(targetTags.Intersect(target.IncidentTargetTags()).Any());
 }
        public IEnumerable <FiringIncident> MakeIntervalIncidentsThread()
        {
            if (Rand.MTBEventOccurs(Props.mtbDays, 60000f, 1000f) && !ToolkitSettings.TimedStorytelling)
            {
                bool targetIsRaidBeacon = incidentTarget.IncidentTargetTags().Contains(IncidentTargetTagDefOf.Map_RaidBeacon);
                List <IncidentCategoryDef> triedCategories = new List <IncidentCategoryDef>();
                IncidentDef               incDef;
                List <IncidentDef>        pickedoptions = new List <IncidentDef>();
                IEnumerable <IncidentDef> options;
                for (; ;)
                {
                    IncidentCategoryDef category = this.ChooseRandomCategory(incidentTarget, triedCategories);
                    Helper.Log($"Trying Category {category}");
                    parms   = this.GenerateParms(category, incidentTarget);
                    options = from d in base.UsableIncidentsInCategory(category, incidentTarget)
                              where !d.NeedsParmsPoints || parms.points >= d.minThreatPoints
                              select d;


                    if (options.TryRandomElementByWeight(new Func <IncidentDef, float>(base.IncidentChanceFinal), out incDef))
                    {
                        break;
                    }
                    triedCategories.Add(category);
                    if (triedCategories.Count >= this.Props.categoryWeights.Count)
                    {
                        goto Block_6;
                    }
                    Thread.Sleep(0);
                }

                Helper.Log($"Events Possible: {options.Count()}");

                if (options.Count() > 1)
                {
                    options = options.Where(k => k != incDef);
                    pickedoptions.Add(incDef);
                    for (int x = 0; x < ToolkitSettings.VoteOptions - 1 && x < options.Count(); x++)
                    {
                        options.TryRandomElementByWeight(new Func <IncidentDef, float>(base.IncidentChanceFinal), out IncidentDef picked);
                        if (picked != null)
                        {
                            options = options.Where(k => k != picked);
                            pickedoptions.Add(picked);
                            Thread.Sleep(0);
                        }
                    }

                    Dictionary <int, IncidentDef> incidents = new Dictionary <int, IncidentDef>();
                    for (int i = 0; i < pickedoptions.Count(); i++)
                    {
                        incidents.Add(i, pickedoptions.ToList()[i]);
                    }
                    incidentOptions = new VoteIncidentDef(incidents, this, parms);
                    Helper.Log("Events created");
                    yield return(null);
                }
                else if (options.Count() == 1)
                {
                    yield return(new FiringIncident(incDef, this, parms));
                }

                if (!this.Props.skipThreatBigIfRaidBeacon || !targetIsRaidBeacon || incDef.category != IncidentCategoryDefOf.ThreatBig)
                {
                    // yield return new FiringIncident(incDef, this, parms);
                    // _twitchstories.StartVote(options, this, parms);
                }

                Block_6 :;
                Thread.Sleep(0);
            }
        }
        public void MakeRandomVoteEvent(IIncidentTarget target)
        {
            Helper.Log("Forcing vote event");
            if (!VoteHandler.voteActive)
            {
                if (ToolkitSettings.TimedStorytelling)
                {
                    bool targetIsRaidBeacon = target.IncidentTargetTags().Contains(IncidentTargetTagDefOf.Map_RaidBeacon);
                    List <IncidentCategoryDef> triedCategories = new List <IncidentCategoryDef>();
                    IncidentDef               incDef;
                    List <IncidentDef>        pickedoptions = new List <IncidentDef>();
                    IEnumerable <IncidentDef> options;

                    IncidentCategoryDef category = this.ChooseRandomCategory(target, triedCategories);
                    Helper.Log($"Trying Category{category}");
                    parms   = this.GenerateParms(category, target);
                    options = from d in base.UsableIncidentsInCategory(category, target)
                              where !d.NeedsParmsPoints || parms.points >= d.minThreatPoints
                              select d;


                    if (options.TryRandomElementByWeight(new Func <IncidentDef, float>(base.IncidentChanceFinal), out incDef))
                    {
                    }
                    triedCategories.Add(category);

                    if (triedCategories.Count >= this.Props.categoryWeights.Count)
                    {
                    }


                    Helper.Log($"Events Possible: {options.Count()}");

                    if (options.Count() > 1)
                    {
                        options = options.Where(k => k != incDef);
                        pickedoptions.Add(incDef);
                        for (int x = 0; x < ToolkitSettings.VoteOptions - 1 && x < options.Count(); x++)
                        {
                            options.TryRandomElementByWeight(new Func <IncidentDef, float>(base.IncidentChanceFinal), out IncidentDef picked);
                            if (picked != null)
                            {
                                options = options.Where(k => k != picked);
                                pickedoptions.Add(picked);
                            }
                        }

                        Dictionary <int, IncidentDef> incidents = new Dictionary <int, IncidentDef>();
                        for (int i = 0; i < pickedoptions.Count(); i++)
                        {
                            incidents.Add(i, pickedoptions.ToList()[i]);
                        }
                        if (incidents.Count > 1)
                        {
                            VoteHandler.QueueVote(new VoteIncidentDef(incidents, this, parms));
                            Helper.Log("Events created");
                        }
                    }
                }
            }
        }
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (Rand.MTBEventOccurs(this.Props.mtbDays, 60000f, 1000f))
            {
                bool targetIsRaidBeacon = target.IncidentTargetTags().Contains(IncidentTargetTagDefOf.Map_RaidBeacon);
                List <IncidentCategoryDef> triedCategories = new List <IncidentCategoryDef>();
                IncidentDef               incDef;
                List <IncidentDef>        pickedoptions = new List <IncidentDef>();
                IEnumerable <IncidentDef> options;
                for (; ;)
                {
                    IncidentCategoryDef category = this.ChooseRandomCategory(target, triedCategories);
                    Helper.Log($"Trying Category{category}");
                    parms   = this.GenerateParms(category, target);
                    options = from d in base.UsableIncidentsInCategory(category, target)
                              where !d.NeedsParmsPoints || parms.points >= d.minThreatPoints
                              select d;


                    if (options.TryRandomElementByWeight(new Func <IncidentDef, float>(base.IncidentChanceFinal), out incDef))
                    {
                        break;
                    }
                    triedCategories.Add(category);
                    if (triedCategories.Count >= this.Props.categoryWeights.Count)
                    {
                        goto Block_6;
                    }
                }

                Helper.Log($"Events Possible: {options.Count()}");

                if (options.Count() > 1)
                {
                    options = options.Where(k => k != incDef);
                    pickedoptions.Add(incDef);
                    for (int x = 0; x < (Settings.VoteOptions > options.Count() ? options.Count() - 1 : Settings.VoteOptions - 1); x++)
                    {
                        options.TryRandomElementByWeight(new Func <IncidentDef, float>(base.IncidentChanceFinal), out IncidentDef picked);
                        if (picked != null)
                        {
                            options = options.Where(k => k != picked);
                            pickedoptions.Add(picked);
                        }
                    }

                    VoteEvent evt = new VoteEvent(pickedoptions, this, parms);
                    Ticker.VoteEvents.Enqueue(evt);
                    Helper.Log("Events created");
                    yield break;
                }
                else if (options.Count() == 1)
                {
                    yield return(new FiringIncident(incDef, this, parms));
                }

                if (!this.Props.skipThreatBigIfRaidBeacon || !targetIsRaidBeacon || incDef.category != IncidentCategoryDefOf.ThreatBig)
                {
                    // yield return new FiringIncident(incDef, this, parms);
                    // _twitchstories.StartVote(options, this, parms);
                }
                Block_6 :;
            }
            yield break;
        }