Exemple #1
0
        private static IDelayHolder CalculateDelay(IncidentParms parms)
        {
            if (parms.target == null)
            {
                return((IDelayHolder)Activator.CreateInstance(SpottedSettings.GetDelayType(), 0));
            }

            var spottersCounter = new SpottersCounter((Map)parms.target);

            float modifier;

            try
            {
                modifier = SpottedSettings.GetModifiersDictionary()[parms.raidArrivalMode.defName];
            }
            catch
            {
                modifier = 1f;
            }

            var watchtowerPower = spottersCounter.WatchtowersCount() *
                                  ThingDefOf.Watchtower.GetStatValueAbstract(StatDefOf.SpottingRange);
            var scannerPower = spottersCounter.PoweredMotionScannersCount() *
                               ThingDefOf.MotionScanner.GetStatValueAbstract(StatDefOf.SpottingRange);
            var satellitePower = spottersCounter.PoweredSatelliteController() *
                                 ThingDefOf.SatelliteController.GetStatValueAbstract(StatDefOf.SpottingRange);

            var delay = (SpottedSettings.allowedTimeRange.RandomInRange + watchtowerPower + scannerPower +
                         satellitePower) * modifier * GenDate.TicksPerHour;

            return((IDelayHolder)Activator.CreateInstance(SpottedSettings.GetDelayType(), (int)delay));
        }
Exemple #2
0
        private static float CalculateSpottingPower(Map map)
        {
            if (map == null)
            {
                return(0);
            }
            SpottersCounter spottersCounter = new SpottersCounter(map);

            float colonistPower   = spottersCounter.ActiveColonistsCount() * ColonistSpottingPower;
            float watchtowerPower = spottersCounter.WatchtowersCount() * ThingDefOf.Watchtower.GetStatValueAbstract(StatDefOf.SpottingPower);
            float scannerPower    = spottersCounter.PoweredMotionScannersCount() * ThingDefOf.MotionScanner.GetStatValueAbstract(StatDefOf.SpottingPower);
            float satellitePower  = spottersCounter.PoweredSatelliteController() * ThingDefOf.SatelliteController.GetStatValueAbstract(StatDefOf.SpottingPower);

            float discoveryPower = (colonistPower + watchtowerPower + scannerPower + satellitePower) / (float)Math.Sqrt(GetThreatScale());

            return(discoveryPower);
        }