Exemple #1
0
        private void PopulateAnprList()
        {
            ComputerVehicleController.ALPR_Detected
            //.GroupBy(x => x.Vehicle)
            //.Select(x => x.Last())
            .Where(x => x.Vehicle.Exists())
            .Select(x =>
            {
                var data = ComputerVehicleController.LookupVehicle(x.Vehicle);

                if (data == null)
                {
                    Function.Log("ALPR integration issue.. data missing from LookupVehicle");
                    return(null);
                }
                VehiclePersona vehiclePersona = data.VehiclePersona;
                if (!String.IsNullOrWhiteSpace(x.Message))
                {
                    vehiclePersona.Alert = x.Message;
                    data.VehiclePersona  = vehiclePersona;
                }

                return(data);
            })
            //.Where(x => x != null && x.Validate())
            .ToList()
            .ForEach(x =>
            {
                list_collected_tags.AddVehicle(x);
            });
        }
        internal static VehiclePersona CreateVehiclePersona(Vehicle veh)
        {
            VehicleRecords records = Functions.GetVehicleRecords(veh);

            VehiclePersona vehiclePersona = new VehiclePersona();

            vehiclePersona.HasInsurance      = records.Insured;
            vehiclePersona.IsRegistered      = null;
            vehiclePersona.Color             = records.CarColour;
            vehiclePersona.Alert             = new System.Text.RegularExpressions.Regex(@"~\w~").Replace(records.DetermineFlags(), String.Empty);
            vehiclePersona.HasValidEmissions = records.HasMOT;
            vehiclePersona.IsOffroadOnly     = records.HasSORN;
            vehiclePersona.IsTaxed           = records.IsTaxed;
            vehiclePersona.RawPersona        = records;

            return(vehiclePersona);
        }
Exemple #3
0
        internal static ComputerPlusEntity LookupVehicle(Vehicle vehicle)
        {
            if (!vehicle)
            {
                return(null);
            }
            var vehiclePersona = new VehiclePersona();

            if (Function.IsTrafficPolicerRunning())
            {
                vehiclePersona.HasInsurance = TrafficPolicerFunction.GetVehicleInsuranceStatus(vehicle) == EVehicleStatus.Valid ? true : false;
                vehiclePersona.IsRegistered = TrafficPolicerFunction.GetVehicleRegistrationStatus(vehicle) == EVehicleStatus.Valid ? true : false;
            }

            var ownerName = Functions.GetVehicleOwnerName(vehicle);

            var driver = vehicle.HasDriver ? vehicle.Driver : null;
            ComputerPlusEntity owner = ComputerPedController.Instance.LookupPersona(ownerName);

            if (owner == null && driver != null)
            {
                owner = ComputerPedController.Instance.LookupPersona(driver);
            }
            else
            {
                while (owner == null)
                {
                    //Last ditch effort to make C+ happy by just providing any ped as the owner and setting them as the owner
                    Function.Log(String.Format("LookupVehicle owner was null.. driver may no longer exist", ownerName));
                    var ped = FindRandomPed();
                    owner = new ComputerPlusEntity(ped, Functions.GetPersonaForPed(ped));
                }
            }

            if (!owner.Validate())
            {
                Function.Log(String.Format("LookupVehicle owner was null, performing fixup on {0}", ownerName));

                var parts = ownerName.Split(' ');
                while (parts.Length < 2)
                {
                    parts = LSPD_First_Response.Engine.Scripting.Entities.Persona.GetRandomFullName().Split(' ');
                }
                Functions.SetVehicleOwnerName(vehicle, String.Format("{0} {1}", parts[0], parts[1]));
                //Work some magic to fix the fact that the ped hasn't been spawned in game
                //@TODO parse ped model name for age group and randomize other props

                var ped = FindRandomPed();


                Function.Log("Found a new ped for fixup");
                var persona = new Persona(
                    ped,
                    Gender.Random,
                    RandomDay(),
                    3,
                    parts[0],
                    parts[1],
                    ELicenseState.Valid,
                    1,
                    false,
                    false,
                    false
                    );
                Functions.SetPersonaForPed(ped, persona);
            }


            return(new ComputerPlusEntity(owner.Ped, owner.PedPersona, vehicle, vehiclePersona));
        }
Exemple #4
0
 internal ComputerVehicleDetails(Vehicle vehicle, Ped owner, Persona ownerPersona, VehiclePersona vehiclePersona) : base(typeof(ComputerVehicleDetailsTemplate))
 {
     CPEntity = new ComputerPlusEntity(owner, ownerPersona, vehicle, vehiclePersona);
 }