private void SpawnPeds() { // ISSUE: method pointer this._peds = ((IEnumerable <Ped>)Enumerable.Where <Ped>((IEnumerable <M0>) this._peds, (Func <M0, bool>) new Func <Ped, bool>((object)null, __methodptr(Exists)))).ToList <Ped>(); if (this._peds.Count >= this._maxZombies) { return; } for (int index = 0; index < this._maxZombies - this._peds.Count; ++index) { Vector3 position = ((Entity)ZombieVehicleSpawner.PlayerPed).get_Position(); Vector3 spawnPoint = ((Vector3) ref position).Around((float)this._spawnDistance); spawnPoint = World.GetNextPositionOnStreet(spawnPoint); if (!this.IsValidSpawn(spawnPoint)) { break; } Vector3 vector3 = ((Vector3) ref spawnPoint).Around(5f); if (vector3.IsOnScreen() || (double)vector3.VDist(ZombieVehicleSpawner.PlayerPosition) < (double)this._minSpawnDistance) { break; } Ped randomPed = World.CreateRandomPed(vector3); if (!Entity.op_Equality((Entity)randomPed, (Entity)null)) { this._peds.Add((Ped)ZombieCreator.InfectPed(randomPed, this._zombieHealth, false)); } } }
public static ZombiePed InfectPed(Ped ped, int health, bool overrideAsFastZombie = false) { ped.set_CanPlayGestures(false); ped.SetCanPlayAmbientAnims(false); ped.SetCanEvasiveDive(false); ped.SetPathCanUseLadders(false); ped.SetPathCanClimb(false); ped.DisablePainAudio(true); ped.ApplyDamagePack(0.0f, 1f, DamagePack.BigHitByVehicle); ped.ApplyDamagePack(0.0f, 1f, DamagePack.ExplosionMed); ped.set_AlwaysDiesOnLowHealth(false); ped.SetAlertness(Alertness.Nuetral); ped.SetCombatAttributes(CombatAttributes.AlwaysFight, true); Function.Call((Hash)8116279360099375049L, new InputArgument[3] { InputArgument.op_Implicit(((Entity)ped).get_Handle()), InputArgument.op_Implicit(0), InputArgument.op_Implicit(0) }); ped.SetConfigFlag(281, true); ped.get_Task().WanderAround(((Entity)ped).get_Position(), ZombiePed.WanderRadius); ped.set_AlwaysKeepTask(true); ped.set_BlockPermanentEvents(true); ((Entity)ped).set_IsPersistent(false); ((Entity)ped).get_CurrentBlip()?.Remove(); ((Entity)ped).set_IsPersistent(true); ped.set_RelationshipGroup(Relationships.InfectedRelationship); float num1 = 0.055f; if (ZombieCreator.IsNightFall()) { num1 = 0.5f; } TimeSpan currentDayTime = World.get_CurrentDayTime(); if (currentDayTime.Hours >= 20 || currentDayTime.Hours <= 3) { num1 = 0.4f; } if (Database.Random.NextDouble() < (double)num1 | overrideAsFastZombie && ZombieCreator.Runners) { return((ZombiePed) new Runner(((Entity)ped).get_Handle())); } Ped ped1 = ped; int num2; ((Entity)ped).set_MaxHealth(num2 = health); int num3 = num2; ((Entity)ped1).set_Health(num3); return((ZombiePed) new Walker(((Entity)ped).get_Handle())); }
private void OnTick(object sender, EventArgs e) { if (this.Spawn) { if (!MenuConrtoller.MenuPool.IsAnyMenuOpen()) { if (ZombieCreator.IsNightFall() && !this._nightFall) { UiExtended.DisplayHelpTextThisFrame("Nightfall approaches. Zombies are far more ~r~aggressive~s~ at night.", false); this._nightFall = true; } else if (!ZombieCreator.IsNightFall()) { this._nightFall = false; } } this.SpawnVehicles(); this.SpawnPeds(); } else { this.ClearAll(); } }