示例#1
0
        IEnumerator TickTasks()
        {
            var sw = new Stopwatch();

            sw.Start();
            RepositionColonists();
            yield return(null);

            HandleIncidents();
            yield return(null);

            FetchAvoidGrid();
            yield return(null);

            RecalculateVisibleMap();
            yield return(null);

            IncreaseZombiePopulation();
            yield return(null);

            UpdateZombieAvoider();
            yield return(null);

            ExecuteExplosions();
            yield return(null);

            var volume = 0f;

            if (allZombiesCached.Any())
            {
                var hour = GenLocalDate.HourFloat(Find.CurrentMap);
                if (hour < 12f)
                {
                    hour += 24f;
                }
                if (hour > Constants.HOUR_START_OF_NIGHT && hour < Constants.HOUR_END_OF_NIGHT)
                {
                    volume = 1f;
                }
                else if (hour >= Constants.HOUR_START_OF_DUSK && hour <= Constants.HOUR_START_OF_NIGHT)
                {
                    volume = GenMath.LerpDouble(Constants.HOUR_START_OF_DUSK, Constants.HOUR_START_OF_NIGHT, 0f, 1f, hour);
                }
                else if (hour >= Constants.HOUR_END_OF_NIGHT && hour <= Constants.HOUR_START_OF_DAWN)
                {
                    volume = GenMath.LerpDouble(Constants.HOUR_END_OF_NIGHT, Constants.HOUR_START_OF_DAWN, 1f, 0f, hour);
                }
            }
            yield return(null);

            if (Constants.USE_SOUND && ZombieSettings.Values.playCreepyAmbientSound)
            {
                if (zombiesAmbientSound == null)
                {
                    zombiesAmbientSound = CustomDefs.ZombiesClosingIn.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.None));
                }

                if (volume < zombiesAmbientSoundVolume)
                {
                    zombiesAmbientSoundVolume -= 0.0001f;
                }
                else if (volume > zombiesAmbientSoundVolume)
                {
                    zombiesAmbientSoundVolume += 0.0001f;
                }
                zombiesAmbientSound.info.volumeFactor = zombiesAmbientSoundVolume;
            }
            else
            {
                if (zombiesAmbientSound != null)
                {
                    zombiesAmbientSound.End();
                    zombiesAmbientSound = null;
                }
            }
            yield return(null);

            if (colonistsConverter.Count > 0)
            {
                var pawn = colonistsConverter.Dequeue();
                Tools.ConvertToZombie(pawn);
            }
            yield return(null);
        }
示例#2
0
        protected override void DoListingItems()
        {
            base.DoListingItems();

            if (Current.ProgramState != ProgramState.Playing)
            {
                return;
            }

            var map = Find.CurrentMap;

            if (map == null)
            {
                return;
            }

            DoGap();
            DoLabel("Tools - Zombies");

            DebugToolMap("Spawn: Zombie (dig out)", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.Normal, false);
            });
            DebugToolMap("Spawn: Zombie (standing)", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.Normal, true);
            });
            DebugToolMap("Spawn: Suicide bomber", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.SuicideBomber, true);
            });
            DebugToolMap("Spawn: Toxic Splasher", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.ToxicSplasher, true);
            });
            DebugToolMap("Spawn: Tanky Operator", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.TankyOperator, true);
            });
            DebugToolMap("Spawn: Miner", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.Miner, true);
            });
            DebugToolMap("Spawn: Random zombie", delegate
            {
                SpawnZombie(ZombieGenerator.ZombieType.Random, true);
            });
            DebugToolMap("Spawn: Zombie incident (4)", delegate
            {
                ZombiesRising.TryExecute(map, 4, UI.MouseCell(), true);
            });
            DebugToolMap("Spawn: Zombie incident (25)", delegate
            {
                ZombiesRising.TryExecute(map, 25, UI.MouseCell(), true);
            });
            DebugToolMap("Spawn: Zombie incident (100)", delegate
            {
                ZombiesRising.TryExecute(map, 100, UI.MouseCell(), true);
            });
            DebugToolMap("Spawn: Zombie incident (200)", delegate
            {
                ZombiesRising.TryExecute(map, 200, UI.MouseCell(), true);
            });
            DebugToolMap("Convert: Make Zombie", delegate
            {
                foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()))
                {
                    var pawn = thing as Pawn;
                    if (pawn == null || pawn is Zombie)
                    {
                        continue;
                    }
                    Tools.ConvertToZombie(pawn, true);
                }
            });
            DebugToolMap("Apply: Trigger rotting", delegate
            {
                foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()))
                {
                    var compRottable = thing.TryGetComp <CompRottable>();
                    if (compRottable != null)
                    {
                        compRottable.RotProgress = compRottable.PropsRot.TicksToRotStart;
                    }
                }
            });
            DebugToolMap("Apply: Add infection", delegate
            {
                foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()))
                {
                    var pawn = thing as Pawn;
                    if (pawn == null || pawn is Zombie)
                    {
                        continue;
                    }

                    var bodyPart = pawn.health.hediffSet
                                   .GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined)
                                   .FirstOrDefault(part => part.IsCorePart == false);
                    if (bodyPart == null)
                    {
                        bodyPart = pawn.health.hediffSet
                                   .GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined).RandomElement();
                    }

                    var def  = HediffDef.Named("ZombieBite");
                    var bite = (Hediff_Injury_ZombieBite)HediffMaker.MakeHediff(def, pawn, bodyPart);

                    bite.mayBecomeZombieWhenDead = true;
                    bite.TendDuration.ZombieInfector.MakeHarmfull();
                    var damageInfo = new DamageInfo(Tools.ZombieBiteDamageDef, 2);
                    pawn.health.AddHediff(bite, bodyPart, damageInfo);
                }
            });
            DebugToolMap("Apply: Remove infection", delegate
            {
                foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()))
                {
                    var pawn = thing as Pawn;
                    if (pawn == null || pawn is Zombie)
                    {
                        continue;
                    }
                    pawn.health.hediffSet
                    .GetHediffs <Hediff_Injury_ZombieBite>()
                    .Do(bite =>
                    {
                        bite.mayBecomeZombieWhenDead = false;
                        var tendDuration             = bite.TryGetComp <HediffComp_Zombie_TendDuration>();
                        tendDuration.ZombieInfector.MakeHarmless();
                    });
                }
            });
            DebugToolMap("Apply: Zombie raging", delegate
            {
                foreach (var thing in Find.CurrentMap.thingGrid.ThingsAt(UI.MouseCell()))
                {
                    var zombie = thing as Zombie;
                    if (zombie == null)
                    {
                        continue;
                    }
                    ZombieStateHandler.StartRage(zombie);
                }
            });
        }