コード例 #1
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (Props.minDanger != 0)
            {
                Map map = target as Map;
                if (map == null || (int)map.dangerWatcher.DangerRating < (int)Props.minDanger)
                {
                    yield break;
                }
            }
            float num = StorytellerUtility.AllyIncidentFraction(Props.fullAlliesOnly);

            if (num <= 0f)
            {
                yield break;
            }
            int incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), Props.minDaysPassed, 60f, 0f, Props.minSpacingDays, Props.baseIncidentsPerYear, Props.baseIncidentsPerYear, num);

            for (int i = 0; i < incCount; i++)
            {
                IncidentParms parms = GenerateParms(Props.incident.category, target);
                if (Props.incident.Worker.CanFireNow(parms))
                {
                    yield return(new FiringIncident(Props.incident, this, parms));
                }
            }
        }
コード例 #2
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            float num = 1f;

            if (Props.acceptFractionByDaysPassedCurve != null)
            {
                num *= Props.acceptFractionByDaysPassedCurve.Evaluate(GenDate.DaysPassedFloat);
            }
            if (Props.acceptPercentFactorPerThreatPointsCurve != null)
            {
                num *= Props.acceptPercentFactorPerThreatPointsCurve.Evaluate(StorytellerUtility.DefaultThreatPointsNow(target));
            }
            if (Props.acceptPercentFactorPerProgressScoreCurve != null)
            {
                num *= Props.acceptPercentFactorPerProgressScoreCurve.Evaluate(StorytellerUtility.GetProgressScore(target));
            }
            int incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), Props.minDaysPassed, Props.onDays, Props.offDays, Props.minSpacingDays, Props.numIncidentsRange.min, Props.numIncidentsRange.max, num);

            for (int i = 0; i < incCount; i++)
            {
                FiringIncident firingIncident = GenerateIncident(target);
                if (firingIncident != null)
                {
                    yield return(firingIncident);
                }
            }
        }
コード例 #3
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (this.Props.minDanger != StoryDanger.None)
            {
                Map map = target as Map;
                if (map == null || map.dangerWatcher.DangerRating < this.Props.minDanger)
                {
                    return;
                }
            }
            float allyIncidentFraction = StorytellerUtility.AllyIncidentFraction(this.Props.fullAlliesOnly);

            if (allyIncidentFraction > 0f)
            {
                int incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), this.Props.minDaysPassed, 60f, 0f, this.Props.minSpacingDays, this.Props.baseIncidentsPerYear, this.Props.baseIncidentsPerYear, allyIncidentFraction);
                for (int i = 0; i < incCount; i++)
                {
                    IncidentParms parms = this.GenerateParms(this.Props.incident.category, target);
                    if (this.Props.incident.Worker.CanFireNow(parms, false))
                    {
                        yield return(new FiringIncident(this.Props.incident, this, parms));
                    }
                }
            }
        }
コード例 #4
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (Props.minDanger != 0)
            {
                Map map = target as Map;
                if (map == null || (int)map.dangerWatcher.DangerRating < (int)Props.minDanger)
                {
                    yield break;
                }
            }
            float allyIncidentFraction = StorytellerUtility.AllyIncidentFraction(Props.fullAlliesOnly);

            if (!(allyIncidentFraction <= 0f))
            {
                int           incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), Props.minDaysPassed, 60f, 0f, Props.minSpacingDays, Props.baseIncidentsPerYear, Props.baseIncidentsPerYear, allyIncidentFraction);
                int           i        = 0;
                IncidentParms parms;
                while (true)
                {
                    if (i >= incCount)
                    {
                        yield break;
                    }
                    parms = GenerateParms(Props.incident.category, target);
                    if (Props.incident.Worker.CanFireNow(parms))
                    {
                        break;
                    }
                    i++;
                }
                yield return(new FiringIncident(Props.incident, this, parms));

                /*Error: Unable to find new state assignment for yield return*/;
            }
        }
コード例 #5
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            float difficultyFactor = (!Props.applyRaidBeaconThreatMtbFactor) ? 1f : Find.Storyteller.difficulty.raidBeaconThreatCountFactor;
            float acceptFraction   = 1f;

            if (Props.acceptFractionByDaysPassedCurve != null)
            {
                acceptFraction *= Props.acceptFractionByDaysPassedCurve.Evaluate(GenDate.DaysPassedFloat);
            }
            if (Props.acceptPercentFactorPerThreatPointsCurve != null)
            {
                acceptFraction *= Props.acceptPercentFactorPerThreatPointsCurve.Evaluate(StorytellerUtility.DefaultThreatPointsNow(target));
            }
            int            incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), Props.minDaysPassed, Props.onDays, Props.offDays, Props.minSpacingDays, Props.numIncidentsRange.min * difficultyFactor, Props.numIncidentsRange.max * difficultyFactor, acceptFraction);
            int            i        = 0;
            FiringIncident fi;

            while (true)
            {
                if (i >= incCount)
                {
                    yield break;
                }
                fi = GenerateIncident(target);
                if (fi != null)
                {
                    break;
                }
                i++;
            }
            yield return(fi);

            /*Error: Unable to find new state assignment for yield return*/;
        }
コード例 #6
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            float difficultyFactor = (!this.Props.applyRaidBeaconThreatMtbFactor) ? 1f : Find.Storyteller.difficulty.raidBeaconThreatCountFactor;
            float acceptFraction   = 1f;

            if (this.Props.acceptFractionByDaysPassedCurve != null)
            {
                acceptFraction *= this.Props.acceptFractionByDaysPassedCurve.Evaluate(GenDate.DaysPassedFloat);
            }
            if (this.Props.acceptPercentFactorPerThreatPointsCurve != null)
            {
                acceptFraction *= this.Props.acceptPercentFactorPerThreatPointsCurve.Evaluate(StorytellerUtility.DefaultThreatPointsNow(target));
            }
            int incCount = IncidentCycleUtility.IncidentCountThisInterval(target, Find.Storyteller.storytellerComps.IndexOf(this), this.Props.minDaysPassed, this.Props.onDays, this.Props.offDays, this.Props.minSpacingDays, this.Props.numIncidentsRange.min * difficultyFactor, this.Props.numIncidentsRange.max * difficultyFactor, acceptFraction);

            for (int i = 0; i < incCount; i++)
            {
                FiringIncident fi = this.GenerateIncident(target);
                if (fi != null)
                {
                    yield return(fi);
                }
            }
            yield break;
        }
コード例 #7
0
        public static IEnumerable <FiringIncident> MakeIntervalIncidents(ThreatsGeneratorParams parms, IIncidentTarget target, int startTick)
        {
            float threatsGeneratorThreatCountFactor = Find.Storyteller.difficulty.threatsGeneratorThreatCountFactor;
            int   incCount = IncidentCycleUtility.IncidentCountThisInterval(target, parms.randSeed, (float)startTick / 60000f, parms.onDays, parms.offDays, parms.minSpacingDays, parms.numIncidentsRange.min * threatsGeneratorThreatCountFactor, parms.numIncidentsRange.max * threatsGeneratorThreatCountFactor);

            for (int i = 0; i < incCount; i++)
            {
                FiringIncident firingIncident = MakeThreat(parms, target);
                if (firingIncident != null)
                {
                    yield return(firingIncident);
                }
            }
        }
コード例 #8
0
        public static int IncidentCountThisInterval(IIncidentTarget target, int randSeedSalt, float minDaysPassed, float onDays, float offDays, float minSpacingDays, float minIncidents, float maxIncidents, float acceptFraction = 1f)
        {
            int num  = IncidentCycleUtility.DaysToIntervals(minDaysPassed);
            int num2 = IncidentCycleUtility.QueueIntervalsPassed - num;

            if (num2 < 0)
            {
                return(0);
            }
            int num3 = IncidentCycleUtility.DaysToIntervals(onDays);
            int num4 = IncidentCycleUtility.DaysToIntervals(offDays);
            int minSpacingIntervals = IncidentCycleUtility.DaysToIntervals(minSpacingDays);
            int num5     = num3 + num4;
            int num6     = num2 / num5;
            int fixedHit = -9999999;

            for (int i = 0; i <= num6; i++)
            {
                int seed  = Gen.HashCombineInt(Find.World.info.persistentRandomValue, target.ConstantRandSeed, randSeedSalt, i);
                int start = i * num5;
                if (IncidentCycleUtility.hits.Count > 0)
                {
                    fixedHit = IncidentCycleUtility.hits[IncidentCycleUtility.hits.Count - 1];
                }
                IncidentCycleUtility.hits.Clear();
                IncidentCycleUtility.GenerateHitList(seed, start, num3, minIncidents, maxIncidents, minSpacingIntervals, acceptFraction, fixedHit);
            }
            int num7 = 0;

            for (int j = 0; j < IncidentCycleUtility.hits.Count; j++)
            {
                int num8 = IncidentCycleUtility.hits[j];
                if (num8 == num2)
                {
                    num7++;
                }
            }
            IncidentCycleUtility.hits.Clear();
            return(num7);
        }
コード例 #9
0
        private static void GenerateHitList(int seed, int start, int length, float minIncidents, float maxIncidents, int minSpacingIntervals, float acceptFraction, int fixedHit)
        {
            if (IncidentCycleUtility.hits.Count > 0)
            {
                throw new Exception();
            }
            Rand.PushState();
            Rand.Seed = seed;
            int num  = GenMath.RoundRandom(Rand.Range(minIncidents, maxIncidents));
            int num2 = 0;

            for (;;)
            {
                IncidentCycleUtility.hits.Clear();
                if (num2++ > 100)
                {
                    break;
                }
                for (int i = 0; i < num; i++)
                {
                    int item = Rand.Range(0, length) + start;
                    IncidentCycleUtility.hits.Add(item);
                }
                IncidentCycleUtility.hits.Sort();
                if (IncidentCycleUtility.RelaxToSatisfyMinDiff(IncidentCycleUtility.hits, minSpacingIntervals, fixedHit, start + length))
                {
                    goto IL_A3;
                }
            }
            Log.ErrorOnce("Too many tries finding incident time. minSpacingDays is too high.", 12612131, false);
IL_A3:
            if (acceptFraction < 1f)
            {
                int num3 = GenMath.RoundRandom((float)IncidentCycleUtility.hits.Count * acceptFraction);
                IncidentCycleUtility.hits.Shuffle <int>();
                IncidentCycleUtility.hits.RemoveRange(num3, IncidentCycleUtility.hits.Count - num3);
            }
            Rand.PopState();
        }