Beispiel #1
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (!(target is World))
            {
                List <IncidentDef> allIncidents = DefDatabase <IncidentDef> .AllDefsListForReading;
                int           i = 0;
                IncidentDef   inc;
                IncidentParms parms;
                while (true)
                {
                    if (i >= allIncidents.Count)
                    {
                        yield break;
                    }
                    inc = allIncidents[i];
                    if (inc.category == Props.category)
                    {
                        _003CMakeIntervalIncidents_003Ec__Iterator0 _003CMakeIntervalIncidents_003Ec__Iterator = (_003CMakeIntervalIncidents_003Ec__Iterator0) /*Error near IL_0095: stateMachine*/;
                        BiomeDef biome = Find.WorldGrid[target.Tile].biome;
                        if (inc.mtbDaysByBiome != null)
                        {
                            MTBByBiome entry = inc.mtbDaysByBiome.Find((MTBByBiome x) => x.biome == biome);
                            if (entry != null)
                            {
                                float mtb = entry.mtbDays;
                                if (Props.applyCaravanVisibility)
                                {
                                    Caravan caravan = target as Caravan;
                                    if (caravan != null)
                                    {
                                        mtb /= caravan.Visibility;
                                    }
                                    else
                                    {
                                        Map map = target as Map;
                                        if (map != null && map.Parent.def.isTempIncidentMapOwner)
                                        {
                                            IEnumerable <Pawn> pawns = map.mapPawns.SpawnedPawnsInFaction(Faction.OfPlayer).Concat(map.mapPawns.PrisonersOfColonySpawned);
                                            mtb /= CaravanVisibilityCalculator.Visibility(pawns, caravanMovingNow: false);
                                        }
                                    }
                                }
                                if (Rand.MTBEventOccurs(mtb, 60000f, 1000f))
                                {
                                    parms = GenerateParms(inc.category, target);
                                    if (inc.Worker.CanFireNow(parms))
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    i++;
                }
                yield return(new FiringIncident(inc, this, parms));

                /*Error: Unable to find new state assignment for yield return*/;
            }
        }
Beispiel #2
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (!(target is World))
            {
                List <IncidentDef> allIncidents = DefDatabase <IncidentDef> .AllDefsListForReading;
                int         i = 0;
                IncidentDef inc;
                while (true)
                {
                    if (i < allIncidents.Count)
                    {
                        inc = allIncidents[i];
                        if (inc.category == this.Props.category)
                        {
                            _003CMakeIntervalIncidents_003Ec__Iterator0 _003CMakeIntervalIncidents_003Ec__Iterator = (_003CMakeIntervalIncidents_003Ec__Iterator0) /*Error near IL_0095: stateMachine*/;
                            BiomeDef biome = Find.WorldGrid[target.Tile].biome;
                            if (inc.mtbDaysByBiome != null)
                            {
                                MTBByBiome entry = inc.mtbDaysByBiome.Find((MTBByBiome x) => x.biome == biome);
                                if (entry != null)
                                {
                                    float mtb = entry.mtbDays;
                                    if (this.Props.applyCaravanStealthFactor)
                                    {
                                        Caravan caravan = target as Caravan;
                                        if (caravan != null)
                                        {
                                            mtb *= CaravanIncidentUtility.CalculateCaravanStealthFactor(caravan.PawnsListForReading.Count);
                                        }
                                        else
                                        {
                                            Map map = target as Map;
                                            if (map != null && map.info.parent.def.isTempIncidentMapOwner)
                                            {
                                                int pawnCount = map.mapPawns.SpawnedPawnsInFaction(Faction.OfPlayer).Count + map.mapPawns.PrisonersOfColonySpawnedCount;
                                                mtb *= CaravanIncidentUtility.CalculateCaravanStealthFactor(pawnCount);
                                            }
                                        }
                                    }
                                    if (Rand.MTBEventOccurs(mtb, 60000f, 1000f) && inc.Worker.CanFireNow(target))
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                        i++;
                        continue;
                    }
                    yield break;
                }
                yield return(new FiringIncident(inc, this, this.GenerateParms(inc.category, target)));

                /*Error: Unable to find new state assignment for yield return*/;
            }
        }
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (target is World)
            {
                yield break;
            }
            List <IncidentDef> allIncidents = DefDatabase <IncidentDef> .AllDefsListForReading;
            int i = 0;

            while (i < allIncidents.Count)
            {
                IncidentDef inc = allIncidents[i];
                if (inc.category == this.Props.category)
                {
                    BiomeDef biome = Find.WorldGrid[target.Tile].biome;
                    if (inc.mtbDaysByBiome != null)
                    {
                        MTBByBiome entry = inc.mtbDaysByBiome.Find((MTBByBiome x) => x.biome == biome);
                        if (entry != null)
                        {
                            float mtb = entry.mtbDays;
                            if (this.Props.applyCaravanVisibility)
                            {
                                Caravan caravan = target as Caravan;
                                if (caravan != null)
                                {
                                    mtb /= caravan.Visibility;
                                }
                                else
                                {
                                    Map map = target as Map;
                                    if (map != null && map.Parent.def.isTempIncidentMapOwner)
                                    {
                                        IEnumerable <Pawn> pawns = map.mapPawns.SpawnedPawnsInFaction(Faction.OfPlayer).Concat(map.mapPawns.PrisonersOfColonySpawned);
                                        mtb /= CaravanVisibilityCalculator.Visibility(pawns, false, null);
                                    }
                                }
                            }
                            if (Rand.MTBEventOccurs(mtb, 60000f, 1000f))
                            {
                                IncidentParms parms = this.GenerateParms(inc.category, target);
                                if (inc.Worker.CanFireNow(parms))
                                {
                                    yield return(new FiringIncident(inc, this, parms));
                                }
                            }
                        }
                    }
                }
IL_24E:
                i++;
                continue;
                goto IL_24E;
            }
            yield break;
        }
Beispiel #4
0
        public override IEnumerable <FiringIncident> MakeIntervalIncidents(IIncidentTarget target)
        {
            if (target is World)
            {
                yield break;
            }
            List <IncidentDef> allIncidents = DefDatabase <IncidentDef> .AllDefsListForReading;

            for (int i = 0; i < allIncidents.Count; i++)
            {
                IncidentDef incidentDef = allIncidents[i];
                if (incidentDef.category != Props.category)
                {
                    continue;
                }
                BiomeDef biome = Find.WorldGrid[target.Tile].biome;
                if (incidentDef.mtbDaysByBiome == null)
                {
                    continue;
                }
                MTBByBiome mTBByBiome = incidentDef.mtbDaysByBiome.Find((MTBByBiome x) => x.biome == biome);
                if (mTBByBiome == null)
                {
                    continue;
                }
                float num = mTBByBiome.mtbDays;
                if (Props.applyCaravanVisibility)
                {
                    Caravan caravan = target as Caravan;
                    if (caravan != null)
                    {
                        num /= caravan.Visibility;
                    }
                    else
                    {
                        Map map = target as Map;
                        if (map != null && map.Parent.def.isTempIncidentMapOwner)
                        {
                            IEnumerable <Pawn> pawns = map.mapPawns.SpawnedPawnsInFaction(Faction.OfPlayer).Concat(map.mapPawns.PrisonersOfColonySpawned);
                            num /= CaravanVisibilityCalculator.Visibility(pawns, caravanMovingNow: false);
                        }
                    }
                }
                if (Rand.MTBEventOccurs(num, 60000f, 1000f))
                {
                    IncidentParms parms = GenerateParms(incidentDef.category, target);
                    if (incidentDef.Worker.CanFireNow(parms))
                    {
                        yield return(new FiringIncident(incidentDef, this, parms));
                    }
                }
            }
        }