Exemplo n.º 1
0
        public static void MoveToMemory(Entity i)
        {
            var obj = new MapObject()
            {
                Dynamic    = !StaticProps.Contains(i.Handle),
                Hash       = i.Model.Hash,
                Position   = i.Position,
                Quaternion = Quaternion.GetEntityQuaternion(i),
                Rotation   = i.Rotation,
                Type       = ObjectTypes.Prop,
            };

            MemoryObjects.Add(obj);
            StreamedInHandles.Remove(i.Handle);
            StaticProps.Remove(i.Handle);
            i.Delete();
        }
Exemplo n.º 2
0
 internal static void RemoveProp(Prop prop, bool dynamic)
 {
     if (StreamedInHandles.Contains(prop.Handle))
     {
         StreamedInHandles.Remove(prop.Handle);
     }
     if (StaticProps.Contains(prop.Handle))
     {
         StaticProps.Remove(prop.Handle);
     }
     if (MemoryObjects.Contains(new MapObject()
     {
         Dynamic = dynamic, Hash = prop.Model.Hash, Position = prop.Position, Quaternion = Quaternion.GetEntityQuaternion(prop), Rotation = prop.Rotation, Type = ObjectTypes.Prop
     }))
     {
         MemoryObjects.Remove(new MapObject()
         {
             Dynamic = dynamic, Hash = prop.Model.Hash, Position = prop.Position, Quaternion = Quaternion.GetEntityQuaternion(prop), Rotation = prop.Rotation, Type = ObjectTypes.Prop
         });
     }
 }
Exemplo n.º 3
0
        public static MapObject[] GetAllEntities()
        {
            List <MapObject> outList =
                StreamedInHandles.Select(
                    handle =>
                    new MapObject()
            {
                Dynamic    = !StaticProps.Contains(handle),
                Hash       = new Prop(handle).Model.Hash,
                Position   = new Prop(handle).Position,
                Quaternion = Quaternion.GetEntityQuaternion(new Prop(handle)),
                Rotation   = new Prop(handle).Rotation,
                Type       = ObjectTypes.Prop,
                Door       = Doors.Contains(handle),
                Id         = (Identifications.ContainsKey(handle) && !string.IsNullOrWhiteSpace(Identifications[handle])) ? Identifications[handle] : null,
            }).ToList();

            outList.AddRange(MemoryObjects);
            Vehicles.ForEach(
                v =>
                outList.Add(new MapObject()
            {
                Dynamic        = !StaticProps.Contains(v),
                Hash           = new Vehicle(v).Model.Hash,
                Position       = new Vehicle(v).Position,
                Quaternion     = Quaternion.GetEntityQuaternion(new Vehicle(v)),
                Rotation       = new Vehicle(v).Rotation,
                Type           = ObjectTypes.Vehicle,
                Id             = (Identifications.ContainsKey(v) && !string.IsNullOrWhiteSpace(Identifications[v])) ? Identifications[v] : null,
                SirensActive   = ActiveSirens.Contains(v),
                PrimaryColor   = (int)new Vehicle(v).PrimaryColor,
                SecondaryColor = (int)new Vehicle(v).SecondaryColor,
            }));

            Peds.ForEach(v => outList.Add(new MapObject()
            {
                Dynamic      = !StaticProps.Contains(v),
                Hash         = new Ped(v).Model.Hash,
                Position     = new Ped(v).Position,
                Quaternion   = Quaternion.GetEntityQuaternion(new Ped(v)),
                Rotation     = new Ped(v).Rotation,
                Type         = ObjectTypes.Ped,
                Action       = ActiveScenarios[v],
                Id           = (Identifications.ContainsKey(v) && !string.IsNullOrWhiteSpace(Identifications[v])) ? Identifications[v] : null,
                Relationship = ActiveRelationships[v],
                Weapon       = ActiveWeapons[v],
            }));

            Pickups.ForEach(p => outList.Add(new MapObject()
            {
                Dynamic      = p.Dynamic,
                Hash         = p.PickupHash,
                Position     = p.RealPosition,
                Quaternion   = Quaternion.GetEntityQuaternion(new Prop(p.ObjectHandle)),
                Rotation     = new Prop(p.ObjectHandle).Rotation,
                Type         = ObjectTypes.Pickup,
                Amount       = p.Amount,
                RespawnTimer = p.Timeout,
                Flag         = p.Flag,
            }));

            return(outList.ToArray());
        }
Exemplo n.º 4
0
 internal static void AddProp(Prop prop, bool dynamic)
 {
     if (StreamedInHandles.Count > MAX_OBJECTS)
     {
         MemoryObjects.Add(new MapObject()
         {
             Dynamic = dynamic, Hash = prop.Model.Hash, Position = prop.Position, Quaternion = Quaternion.GetEntityQuaternion(prop), Rotation = prop.Rotation, Type = ObjectTypes.Prop
         });
         prop.Delete();
         return;
     }
     StreamedInHandles.Add(prop.Handle);
     if (!dynamic)
     {
         StaticProps.Add(prop.Handle);
     }
 }