Exemplo n.º 1
0
 public void CreateSampleData()
 {
     for (var i = 0; i < 20; i++)
     {
         Clamps.Add(GetRandomClamp());
     }
 }
Exemplo n.º 2
0
        private static void SpawnModel(int type, int vehicle)
        {
            var coords = GetEntityCoords(PlayerPedId(), false);

            SetNetworkIdExistsOnAllMachines(VehToNet(vehicle), true);
            if (type == 0)
            {
                RequestModel((uint)GetHashKey("p_car_keys_01"));
                Object = CreateObject(GetHashKey("p_car_keys_01"), coords.X, coords.Y, coords.Z, true, true, true);
                var boneIndex = GetEntityBoneIndexByName(vehicle, "wheel_lf");
                SetEntityHeading(Object, 0f);
                SetEntityRotation(Object, 60f, 20f, 10f, 1, true);
                AttachEntityToEntity(Object, vehicle, boneIndex, -0.10f, 0.15f, -0.30f, 180f, 200f, 90f, true, true, false, false, 2, true);
                SetEntityRotation(Object, 60f, 20f, 10f, 1, true);
                SetEntityAsMissionEntity(Object, true, true);
                FreezeEntityPosition(Object, true);
                TriggerServerEvent("Server:ChangeCarState", VehToNet(vehicle), true);
                Clamps.Add(Object, vehicle);
            }
            else if (type == 1)
            {
                RequestModel((uint)GetHashKey("prop_cs_protest_sign_03"));
                Object = CreateObject(GetHashKey("prop_cs_protest_sign_03"), coords.X, coords.Y, coords.Z, true, true, true);
                var boneIndex = GetEntityBoneIndexByName(vehicle, "interiorlight");
                var model     = GetEntityModel(vehicle);
                var vector1   = new Vector3(0f, 0f, 0f);
                var vector2   = new Vector3(0f, 0f, 0f);
                GetModelDimensions((uint)model, ref vector1, ref vector2);
                FreezeEntityPosition(Object, true);
                SetEntityAsMissionEntity(Object, true, true);
                //AttachEntityToEntity(Object, vehicle, boneIndex, 0f, ((vector2.Y - vector1.Y) / 2), ((vector2.Z - vector1.Z) / 2) - ((vector2.Z - vector1.Z) / 5f), 0f, 0f, 0f, true, true, false, false, 1, true);
                AttachEntityToEntity(Object, vehicle, boneIndex, 0f, -((vector2.Y - vector1.Y) / 2) + 5f, -0.12f, 0f, 0f, 0f, true, true, false, false, 1, true);
                Stickers.Add(Object, vehicle);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Call this regularly to fill the ShirtListBox with shirts. Will automatically already existing shirts (in case of cyclic buffer).
        /// </summary>
        public void ClampChanged(Clamp clamp, ChangeType changeType)
        {
            var existsAlready = Clamps.Any(c => c.ID == clamp.ID);

            if (changeType == ChangeType.ClampDetected)
            {
                // remove ALL
                if (existsAlready)
                {
                    var clamps = Clamps.Where(c => c.ID == clamp.ID);
                    foreach (var clampToRemove in clamps)
                    {
                        ExecuteDeleteSpecificClamp(clampToRemove);
                    }
                }

                Clamps.Add(new Clamp
                {
                    ID           = clamp.ID,
                    TimeStamp    = clamp.CurrentShirt != null ? clamp.CurrentShirt.LastRfidRead : DateTime.Now,
                    CurrentShirt = clamp.CurrentShirt
                });
            }
            else if (changeType == ChangeType.ClampRemoved)
            {
                // remove ALL
                if (existsAlready)
                {
                    var clamps = Clamps.Where(c => c.ID == clamp.ID);
                    foreach (var clampToRemove in clamps)
                    {
                        ExecuteDeleteSpecificClamp(clampToRemove);
                    }
                }
            }
            else if (changeType == ChangeType.ShirtChanged)
            {
                if (existsAlready)
                {
                    var existingClamp = Clamps.First(c => c.ID == clamp.ID);

                    existingClamp.CurrentShirt.RfidReadCounter    = clamp.CurrentShirt.RfidReadCounter;
                    existingClamp.CurrentShirt.LastRfidRead       = clamp.CurrentShirt.LastRfidRead;
                    existingClamp.CurrentShirt.FlaggedComment     = clamp.CurrentShirt.FlaggedComment;
                    existingClamp.CurrentShirt.Route              = clamp.CurrentShirt.Route;
                    existingClamp.CurrentShirt.SelectedRouteIndex = clamp.CurrentShirt.SelectedRouteIndex;
                }
            }
        }