예제 #1
0
 public void Deserialize()
 {
     if (_peds == null)
     {
         PedCollection des = Serializer.Deserialize <PedCollection>("./scripts/Guards.dat");
         if (des == null)
         {
             des = new PedCollection();
         }
         _peds              = des;
         _peds.ListChanged += delegate
         {
             Serializer.Serialize("./scripts/Guards.dat", _peds);
         };
         _peds.ToList().ForEach(delegate(PedData data)
         {
             Ped ped = World.CreatePed(data.Hash, data.Position);
             if (!(ped == null))
             {
                 ped.Rotation = data.Rotation;
                 ped.Recruit(PlayerPed);
                 data.Weapons.ForEach(delegate(Weapon w)
                 {
                     ped.Weapons.Give(w.Hash, w.Ammo, true, true);
                 });
                 data.Handle = ped.Handle;
                 SetTask(ped, data.Task);
             }
         });
     }
 }
 public void Deserialize()
 {
     if (this._peds != null)
     {
         return;
     }
     this._peds              = Serializer.Deserialize <PedCollection>("./scripts/Guards.dat") ?? new PedCollection();
     this._peds.ListChanged += (PedCollection.ListChangedEvent)(count => Serializer.Serialize <PedCollection>("./scripts/Guards.dat", this._peds));
     this._peds.ToList <PedData>().ForEach((Action <PedData>)(data =>
     {
         Ped ped = World.CreatePed(Model.op_Implicit(data.Hash), data.Position);
         if (Entity.op_Equality((Entity)ped, (Entity)null))
         {
             return;
         }
         ((Entity)ped).set_Rotation(data.Rotation);
         ped.Recruit(this.PlayerPed);
         data.Weapons.ForEach((Action <Weapon>)(w => ped.get_Weapons().Give(w.Hash, w.Ammo, true, true)));
         data.Handle = ((Entity)ped).get_Handle();
         this.SetTask(ped, data.Task);
     }));
 }
예제 #3
0
        public void RandomEventsPedestrians()
        {
            if (scripton)
            {
                revent = !revent;
                if (revent)
                {
                    Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", "Streetwar Starting...", debugTime, 1);
                }
                else
                {
                    Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", "Streetwar Over. Total spawned: " + totalSpawned, debugTime, 1);
                    if (debug)
                    {
                        Wait(debugTime);
                    }

                    int pedsKilled = 0;

                    //Do some clean up

                    //kill all pedestrians
                    foreach (Ped ped in peds)
                    {
                        if (ped.Exists())
                        {
                            ped.Health = 0;
                            ped.AlwaysDiesOnLowHealth = true;
                            ped.Die();
                            pedsKilled++;
                        }

                        //remove all blips on living pedestrians
                        if (blips.ContainsKey(ped))
                        {
                            if (blips[ped].Exists())
                            {
                                blips[ped].Delete();
                                blips.Remove(ped);
                            }
                        }
                    }

                    //remove any dead blips if there are any
                    foreach (Blip blip in blips.Values)
                    {
                        if (blip.Exists())
                        {
                            blip.Delete();
                        }
                    }

                    if (debug)
                    {
                        Function.Call("PRINT_STRING_WITH_LITERAL_STRING_NOW", "STRING", "Killed off " + pedsKilled + " peds", debugTime, 1);
                    }
                    peds        = new PedCollection();
                    blips       = new Dictionary <Ped, Blip>();
                    currentWave = 0;
                    //reinit lists and reset counters
                }
            }
        }