Example #1
0
        private string GetCameraName(ECamera cam)
        {
            string mCamName = cam.ToFriendlyString();

            switch (cam)
            {
            case ECamera.Driver_Front:
                mCamName = "Driver Front";
                break;

            case ECamera.Driver_Rear:
                mCamName = "Driver Rear";
                break;

            case ECamera.Passenger_Rear:
                mCamName = "Pass Rear";
                break;

            case ECamera.Passenger_Front:
                mCamName = "Pass Front";
                break;

            default:
                break;
            }

            return(mCamName);
        }
Example #2
0
        public override void Initialize(World world)
        {
            base.Initialize(world);

            //Make it so we can be possesed
            Possesable = true;

            //Create the input controller
            inputController = new InputController();

            //Attach us to the input controller
            bool attached = inputController.Posses(this);

            if (!attached)
            {
                throw new System.InvalidOperationException("Failed to attach input controller to player entity!");
            }

            //Create the camera to represent the player
            PlayerCamera = EntityManager.CreateEntity <ECamera>(OwningWorld, true);
            CameraManager.SetActiveCamera(PlayerCamera);

            //Create the sprite that represents us
            animation = AddComponent <CSpriteAnimation>();
            animation.SetupAnimation(PlayerSprite, 24, 1);
            animation.SetAnimationFrames(animations["idle"]);
            currentAnimation = "idle";
            animation.SetSpeed(2);
            animation.Play();

            transform.Scale = new Vector2(4, 4);

            //CreateSpherePhysics(10);
            PhysicsObject b = CreateSpherePhysics(32, ChipmunkSharp.cpBodyType.DYNAMIC, 10000, 1000000000);
        }
Example #3
0
        public override void Initialize(World world)
        {
            base.Initialize(world);

            //Make it so we can be possesed
            Possesable = true;

            //Create the input controller
            inputController = new InputController();

            //Attach us to the input controller
            bool attached = inputController.Posses(this);

            if (!attached)
            {
                throw new System.InvalidOperationException("Failed to attach input controller to player entity!");
            }

            //Create the camera to represent the player
            PlayerCamera = EntityManager.CreateEntity <ECamera>(OwningWorld, true);
            CameraManager.SetActiveCamera(PlayerCamera);

            //Create the sprite that represents us
            animation = AddComponent <CSpriteAnimation>();
            animation.SetupAnimation(ControllerSprite, 24, 1);
            animation.SetAnimationFrames(new int[] { 1, 2, 3, 4 });
            animation.SetSpeed(2);
            animation.Play();

            transform.Scale = new Vector2(4, 4);
        }
Example #4
0
        internal void ScanPlates()
        {
            if (!Globals.PlayerPed.IsOnFoot && Globals.PlayerVehicle.Exists())
            {
                if (Globals.PlayerVehicle.IsPoliceVehicle && IsActive(Globals.PlayerVehicle))
                {
                    List <Vehicle> mVehicles = World.EnumerateVehicles().ToList();
                    mVehicles = (from x in mVehicles where x.Exists() && !IsVehicleBlacklisted(x) &&
                                 x.DistanceTo(Globals.PlayerPed.Position) <= Config.CameraRange &&
                                 x.DistanceTo(Globals.PlayerPed.Position) >= Config.CameraMinimum
                                 orderby x.DistanceTo(Globals.PlayerPed.Position) select x).ToList();

                    foreach (Vehicle veh in mVehicles)
                    {
                        if (Globals.AlertTimer.IsRunning)
                        {
                            if (Globals.AlertTimer.Elapsed.TotalSeconds < Config.SecondsBetweenAlerts)
                            {
                                break;
                            }
                            else
                            {
                                Globals.AlertTimer.Stop();
                                Globals.AlertTimer.Reset();
                            }
                        }

                        if (veh.Exists())
                        {
                            ECamera cam = GetCapturingCamera(veh);

                            if (cam != ECamera.Null)
                            {
                                //Logger.LogTrivialDebug("Camera -- " + cam.ToFriendlyString());

                                bool mAlertTriggered = RunVehiclePlates(veh, cam);

                                if (mAlertTriggered && !Globals.AlertTimer.IsRunning)
                                {
                                    Globals.AlertTimer.Start();
                                }
                            }
                        }

                        GameFiber.Sleep(250);
                    }

                    List <Vehicle> vehToRemove = mRecentlyScanned.Where(x => Game.GameTime > (x.Value + Config.VehicleRescanBufferInMilliseconds)).Select(x => x.Key).ToList();

                    foreach (Vehicle v in vehToRemove)
                    {
                        mRecentlyScanned.Remove(v);
                    }
                }
            }
        }
 public void GetActiveCameraType(out ECamera outType)
 {
     outType = ECamera.NONE;
     foreach (CameraCC cam in cameras)
     {
         if (cam.isActiveAndEnabled)
         {
             outType = cam.type;
         }
     }
 }
Example #6
0
        private API.ALPRScanResult CreateScanResult(Vehicle veh, EAlertType alert, ECamera cam)
        {
            API.ALPRScanResult r = null;

            switch (alert)
            {
            case EAlertType.Stolen_Vehicle:
                r = CreateStolenVehResult(veh);
                break;

            case EAlertType.Owner_Wanted:
                r = CreateWantedResult(veh);
                break;

            case EAlertType.Owner_License_Suspended:
                r = CreateLicSuspendedResult(veh);
                break;

            case EAlertType.Owner_License_Expired:
                r = CreateLicExpiredResult(veh);
                break;

            case EAlertType.Registration_Expired:
                r = CreateRegExpiredResult(veh);
                break;

            case EAlertType.Unregistered_Vehicle:
                r = CreateRegNotValidResult(veh);
                break;

            case EAlertType.No_Insurance:
                r = CreateInsNotValidResult(veh);
                break;

            case EAlertType.Insurance_Expired:
                r = CreateInsExpiredResult(veh);
                break;
            }

            API.Functions.RaiseALPRFlagGenerated(veh, new ALPREventArgs(r, cam));
            return(r);
        }
 public void ActiveCamera(ECamera type)
 {
     activeCamera = type;
     foreach (CameraCC cam in cameras)
     {
         if (cam.isActiveAndEnabled)
         {
             if (cam.type != activeCamera)
             {
                 cam.enabled = false;
             }
         }
         else
         {
             if (cam.type == activeCamera)
             {
                 cam.enabled = true;
             }
         }
     }
 }
 public void GetActiveCameraScript(ECamera type, out CameraCC outCam)
 {
     outCam = typedCameras[type];
 }
Example #9
0
 internal ALPREventArgs(ALPRScanResult res, ECamera cam)
 {
     mResult = res;
     mCamera = cam;
 }
Example #10
0
        private bool RunVehiclePlates(Vehicle veh, ECamera cam)
        {
            if (veh.Exists() && !IsVehicleBlacklisted(veh))
            {
                if (!mRecentlyScanned.ContainsKey(veh))
                {
                    mRecentlyScanned.Add(veh, Game.GameTime);

                    if (Config.PlayScanSound)
                    {
                        Audio.PlaySound(Audio.ESounds.PinButton);
                        //GameFiber.Sleep(500);
                    }

                    if (Globals.ScanResults.Keys.Contains(veh))
                    {
                        TimeSpan ts = DateTime.Now - Globals.ScanResults[veh].LastDisplayed;
                        if (ts.TotalSeconds < Config.VehicleRescanBuffer)
                        {
                            return(false);
                        }

                        EAlertType mPrevAlert = Globals.ScanResults[veh].AlertType;

                        if (mPrevAlert != EAlertType.Null)
                        {
                            DisplayAlert(veh, cam, Globals.ScanResults[veh]);
                            return(true);
                        }
                        else
                        {
                            if (Globals.ScanResults[veh].IsCustomFlag == true && Globals.ScanResults[veh].Result != "")
                            {
                                DisplayAlert(veh, cam, Globals.ScanResults[veh]);
                                return(true);
                            }
                        }

                        return(false);
                    }
                    else
                    {
                        int mAlertFactor = mRand.Next(0, 100);

                        if (mAlertFactor < Config.ProbabilityOfAlerts)
                        {
                            EAlertType mGeneratedFlag = GenerateFlag(veh);

                            if (mGeneratedFlag != EAlertType.Null)
                            {
                                API.ALPRScanResult r = CreateScanResult(veh, mGeneratedFlag, cam);
                                DisplayAlert(veh, cam, r);
                                return(true);
                            }
                            else
                            {
                                if (!Globals.ScanResults.ContainsKey(veh))
                                {
                                    API.ALPRScanResult r = new API.ALPRScanResult(veh, EAlertType.Null);
                                    Globals.ScanResults.Add(veh, r);
                                    return(false);
                                }
                            }
                        }
                        else
                        {
                            if (!Globals.ScanResults.ContainsKey(veh))
                            {
                                API.ALPRScanResult r = new API.ALPRScanResult(veh, EAlertType.Null);
                                Globals.ScanResults.Add(veh, r);
                                return(false);
                            }
                        }

                        return(false);
                    }
                }
            }

            return(false);
        }
Example #11
0
        private void DisplayAlert(Vehicle veh, ECamera cam, API.ALPRScanResult r)
        {
            if (veh.Exists())
            {
                if (r.AlertType == EAlertType.Null)
                {
                    return;
                }

                r.LastDisplayed = DateTime.Now;

                if (!Globals.ScanResults.ContainsKey(veh))
                {
                    Globals.ScanResults.Add(veh, r);
                }
                else
                {
                    Globals.ScanResults[veh].LastDisplayed = DateTime.Now;
                }

                if (r.Persona != null)
                {
                    if (veh.HasDriver && veh.Driver.Exists())
                    {
                        Logger.LogTrivialDebug(String.Format("DisplayAlert() -- Setting Persona for driver (lic: {0}), (name: {1})", veh.LicensePlate, r.Persona.FullName));
                        Functions.SetPersonaForPed(veh.Driver, r.Persona);
                    }
                }

                if (r.RegisteredOwner != "")
                {
                    Functions.SetVehicleOwnerName(veh, r.RegisteredOwner);
                }

                string subtitle = "";

                switch (r.AlertType)
                {
                case EAlertType.Stolen_Vehicle:
                    subtitle = "~r~Stolen Vehicle";
                    break;

                case EAlertType.Owner_Wanted:
                    subtitle = "~r~Outstanding Warrant";
                    break;

                case EAlertType.Owner_License_Suspended:
                    subtitle = "~r~License Suspended";
                    break;

                case EAlertType.Owner_License_Expired:
                    subtitle = "~y~License Expired";
                    break;

                case EAlertType.Registration_Expired:
                    subtitle = "~y~Registration Expired";
                    break;

                case EAlertType.Unregistered_Vehicle:
                    subtitle = "~r~Unregistered Vehicle";
                    break;

                case EAlertType.No_Insurance:
                    subtitle = "~r~No Insurance";
                    break;

                case EAlertType.Insurance_Expired:
                    subtitle = "~y~Insurance Expired";
                    break;
                }

                if (r.IsCustomFlag)
                {
                    subtitle = r.Result;
                }

                string mColorName = "";
                try
                {
                    VehicleColor mColor = Stealth.Common.Natives.Vehicles.GetVehicleColors(veh);
                    mColorName = mColor.PrimaryColorName;
                }
                catch
                {
                    mColorName = "";
                }

                if (mColorName != "")
                {
                    mColorName = mColorName + " ";
                }

                string mTitle    = String.Format("ALPR+ [{0}]", GetCameraName(cam));
                string mVehModel = String.Format("{0}{1}", veh.Model.Name.Substring(0, 1).ToUpper(), veh.Model.Name.Substring(1).ToLower());
                string mText     = String.Format("Plate: ~b~{0} ~n~~w~{1}{2}", veh.LicensePlate, mColorName, mVehModel);

                Funcs.DisplayNotification(mTitle, subtitle, mText);

                if (Config.PlayAlertSound)
                {
                    Audio.PlaySound(Audio.ESounds.TimerStop);
                }

                API.Functions.RaiseALPRResultDisplayed(veh, new ALPREventArgs(r, cam));
            }
        }
Example #12
0
        internal void ScanPlates()
        {
            while (true)
            {
                GameFiber.Yield();

                if (!IsActive(Globals.PlayerVehicle) || Functions.IsPoliceComputerActive())
                {
                    continue;
                }

                if (!Globals.PlayerPed.IsOnFoot && Globals.PlayerVehicle)
                {
                    if (Globals.PlayerVehicle.IsPoliceVehicle && IsActive(Globals.PlayerVehicle) && !Globals.CurrentlyCollectingClosestWorldVehicles)
                    {
                        /*List<Vehicle> mVehicles = World.EnumerateVehicles().ToList();
                         * mVehicles = (from x in mVehicles where x.Exists() && !IsVehicleBlacklisted(x) &&
                         *          x.DistanceTo(Globals.PlayerPed.Position) <= Config.CameraRange &&
                         *          x.DistanceTo(Globals.PlayerPed.Position) >= Config.CameraMinimum
                         *          orderby x.DistanceTo(Globals.PlayerPed.Position) select x).ToList();*/
                        Globals.CurrentlyProcessingClosestWorldVehicles = true;
                        foreach (Vehicle veh in Globals.ClosestWorldVehicles)
                        {
                            GameFiber.Yield();
                            //TODO: Change this to milliseconds

                            /*if (Globals.AlertTimer.IsRunning)
                             * {
                             *  if (Globals.AlertTimer.Elapsed.TotalSeconds < Config.SecondsBetweenAlerts)
                             *  {
                             *      break;
                             *  }
                             *  else
                             *  {
                             *      Globals.AlertTimer.Stop();
                             *      Globals.AlertTimer.Reset();
                             *  }
                             * }*/

                            if (veh && !IsVehicleBlacklisted(veh) && veh.DistanceTo(Globals.PlayerPed.Position) <= Config.CameraRange && veh.DistanceTo(Globals.PlayerPed.Position) >= Config.CameraMinimum)
                            {
                                ECamera cam = GetCapturingCamera(veh);

                                if (cam != ECamera.Null)
                                {
                                    //Logger.LogTrivialDebug("Camera -- " + cam.ToFriendlyString());

                                    bool mAlertTriggered = RunVehiclePlates(veh, cam);

                                    /*if (mAlertTriggered && !Globals.AlertTimer.IsRunning)
                                     * {
                                     *  Globals.AlertTimer.Start();
                                     * }*/
                                }
                            }
                        }
                        Globals.CurrentlyProcessingClosestWorldVehicles = false;

                        List <Vehicle> vehToRemove = mRecentlyScanned.Where(x => Game.GameTime > (x.Value + Config.VehicleRescanBufferInMilliseconds)).Select(x => x.Key).ToList();

                        foreach (Vehicle v in vehToRemove)
                        {
                            mRecentlyScanned.Remove(v);
                        }
                    }
                }
            }
        }
Example #13
0
 /// <summary>
 /// Changes the active rendering camera
 /// </summary>
 /// <param name="c">The camera to change it to</param>
 public static void SetActiveCamera(ECamera c)
 {
     ActiveCamera = c;
 }