コード例 #1
0
        private static ArrestReport generateRandomArrestReport(ComputerPlusEntity entity)
        {
            ArrestReport newArrest     = ArrestReport.CreateForPed(entity);
            int          randomSeconds = Globals.Random.Next(SECONDS_IN_A_DAY * 7, SECONDS_IN_A_DAY * 1200) * -1;

            newArrest.ArrestTimeDate = DateTime.Now.AddSeconds(randomSeconds);
            Vector3 randomLocation = Rage.World.GetRandomPositionOnStreet();

            newArrest.ArrestStreetAddress = Rage.World.GetStreetName(randomLocation);
            newArrest.ArrestCity          = Functions.GetZoneAtPosition(randomLocation).RealAreaName;
            newArrest.Details             = String.Empty;

            string randomChargeName = ComputerPedController.GetRandomWantedReason();
            bool   isFelony         = false;

            randomChargeName = randomChargeName.Substring(randomChargeName.LastIndexOf("=>") + 3);
            if (randomChargeName.EndsWith("(F)"))
            {
                isFelony         = true;
                randomChargeName = randomChargeName.Substring(0, randomChargeName.Length - 3);
            }
            ArrestChargeLineItem newCharge = new ArrestChargeLineItem();

            newCharge.id       = new Guid();
            newCharge.Charge   = randomChargeName;
            newCharge.IsFelony = isFelony;
            newCharge.Note     = String.Empty;
            newArrest.Charges.Add(newCharge);

            return(SaveArrestRecord(newArrest));
        }
コード例 #2
0
 internal ArrestReportContainer(ArrestReport arrestReport, ComputerPlusEntity entity) : base(typeof(ArrestReportContainerTemplate))
 {
     Report       = arrestReport;
     reportEntity = entity;
     pedDetailsPage.SetErrorSubscription(this);
     pedDetailsPage.SetActionSubscription(this);
 }
コード例 #3
0
        public static List <ArrestReport> GetArrestReportsForPed(ComputerPlusEntity entity)
        {
            // check if ped has past arrest reports
            List <ArrestReport> pastArrestFromDB = GetArrestReportsForPed(entity.FirstName, entity.LastName, entity.DOBString);

            return(pastArrestFromDB.OrderByDescending(o => o.ArrestTimeDate).ToList());
        }
コード例 #4
0
        private static ComputerPlusEntity generateVehicleOwner(string ownerName)
        {
            Ped ped = null;

            while (ped == null)
            {
                //Last ditch effort to make C+ happy by just providing any ped as the owner and setting them as the owner
                ped = FindRandomPed();
                if (ped != null && !ped.IsValid())
                {
                    ped = null;
                }
            }
            var parts = ownerName.Split(' ');

            while (parts.Length < 2)
            {
                parts = Persona.GetRandomFullName().Split(' ');
            }
            int timesStopped = Globals.Random.Next(0, 4);
            var persona      = new Persona(ped, Gender.Random, RandomDay(), Globals.Random.Next(0, timesStopped + 1),
                                           parts[0], parts[1], ELicenseState.Valid, timesStopped, false, false, false);

            Functions.SetPersonaForPed(ped, persona);
            return(ComputerPlusEntity.CreateFrom(ped));
        }
コード例 #5
0
        public static TrafficCitation CreateForPedInVehicle(ComputerPlusEntity entity)
        {
            var citation = new TrafficCitation()
            {
                FirstName        = entity.FirstName,
                LastName         = entity.LastName,
                DOB              = entity.DOBString,
                HomeAddress      = entity.Address,
                CitationTimeDate = DateTime.Now.ToUniversalTime()
            };

            if (entity.Vehicle && !entity.Vehicle.IsPoliceVehicle)
            {
                citation.VehicleModel = entity.Vehicle.Model.Name;
                citation.VehicleTag   = entity.VehicleTag;
                citation.VehicleColor = entity.Vehicle.GetVehicleColorName();
            }
            else if (entity.Ped && entity.Ped.LastVehicle && !entity.Ped.LastVehicle.IsPoliceVehicle)
            {
                citation.VehicleModel = entity.Ped.LastVehicle.Model.Name;
                citation.VehicleTag   = entity.Ped.LastVehicle.LicensePlate;
                citation.VehicleColor = entity.Ped.LastVehicle.GetVehicleColorName();
            }
            else
            {
                citation.VehicleModel = "N/A";
                citation.VehicleTag   = "N/A";
                citation.VehicleColor = "N/A";
            }
            return(citation);
        }
コード例 #6
0
        internal static ListBoxRow AddPed(this ListBox listBox, ComputerPlusEntity entry)
        {
            if (listBox == null)
            {
                return(null);
            }
            String alert          = entry.IsWanted ? "(ALERT) " : String.Empty;
            String pedInVehStatus = getPedInVehicleStatus(entry.Ped);

            String rowId = String.Format("{0}_{1}_{2}",
                                         entry.FirstName,
                                         entry.LastName,
                                         entry.Ped.Model.Name
                                         );
            var previousRow = listBox.FindChildByName(rowId);

            if (previousRow == null)
            {
                var row = listBox.AddRow(
                    String.Format("{0}({1}){2} | {3}", alert, entry.GenderId, pedInVehStatus, entry.FullName),
                    rowId,
                    entry
                    );
                return(row);
            }
            return(previousRow as ListBoxRow);
        }
コード例 #7
0
        public static void ShowTrafficCitationCreate(TrafficCitation citation, ComputerPlusEntity entity = null, TrafficCitationView.TrafficCitationActionEvent callbackDelegate = null)
        {
            TrafficCitation mCitation = null;

            if (citation == null && entity == null)
            {
                mCitation = Globals.PendingTrafficCitation != null ? Globals.PendingTrafficCitation : new TrafficCitation();
            }
            else if (citation == null && entity.Validate())
            {
                Function.Log("Creating Traffic Citation for ped in vehicle");
                mCitation = TrafficCitation.CreateForPedInVehicle(entity);
                Globals.PendingTrafficCitation = mCitation;
                Function.Log("Created Traffic Citation for ped  " + mCitation.FirstName);
            }
            else if (citation != null && citation == Globals.PendingTrafficCitation && !citation.FullName.Equals(entity.FullName))
            {
                if (entity.Validate())
                {
                    mCitation = TrafficCitation.CreateForPedInVehicle(entity);
                }
                else
                {
                    mCitation = new TrafficCitation();
                }
                Globals.PendingTrafficCitation = mCitation;
            }
            else
            {
                mCitation = citation;
            }
            Globals.Navigation.Push(new TrafficCitationCreateContainer(mCitation, TrafficCitationView.ViewTypes.CREATE, callbackDelegate));
        }
コード例 #8
0
        public static DetailedEntity GetAllReportsForPed(ComputerPlusEntity entity)
        {
            var arrests = GetArrestReportsForPed(entity);
            var traffic = GetTrafficCitationsForPed(entity);

            return(new DetailedEntity(entity, arrests, traffic));
        }
コード例 #9
0
        public static List <TrafficCitation> GetTrafficCitationsForPed(ComputerPlusEntity entity)
        {
            // check if ped has past citations
            List <TrafficCitation> pastCitationFromDB = GetTrafficCitationsForPed(entity.FirstName, entity.LastName, entity.DOBString);

            return(pastCitationFromDB.OrderByDescending(o => o.CitationTimeDate).ToList());
        }
コード例 #10
0
        public static void generateRandomHistory(ComputerPlusEntity entity)
        {
            if (Configs.RandomHistoryRecords && entity.Ped != null && entity.Ped.Metadata.randomReportsGenerated == null)
            {
                entity.Ped.Metadata.randomReportsGenerated = true;

                // generate random Citation history
                if (entity.PedPersona.Citations > 0)
                {
                    for (var i = 0; i < entity.PedPersona.Citations; i++)
                    {
                        generateRandomCitation(entity);
                    }
                }

                // generate random Arrest history
                generatePastArrestNum(entity);
                if (entity.Ped.Metadata.pastArrestNum > 0)
                {
                    // generate past arrest history
                    for (var i = 0; i < entity.Ped.Metadata.pastArrestNum; i++)
                    {
                        generateRandomArrestReport(entity);
                    }
                }
            }
        }
コード例 #11
0
        internal static ListBoxRow AddVehicle(this ListBox listBox, ComputerPlusEntity entry)
        {
            if (listBox == null)
            {
                return(null);
            }
            String alert = (entry.PedPersona.Wanted ||
                            (entry.VehiclePersona.HasInsurance.HasValue && !entry.VehiclePersona.HasInsurance.Value) ||
                            (entry.VehiclePersona.IsRegistered.HasValue && !entry.VehiclePersona.IsRegistered.Value)) ?
                           "(ALERT) " : String.Empty;

            if (!String.IsNullOrWhiteSpace(alert))
            {
                //alert = String.Format(alert, String.IsNullOrWhiteSpace(entry.Item4.Alert) ? String.Empty : entry.Item4.Alert);
            }
            String rowId = String.Format("{0}_{1}_{2}",
                                         entry.PedPersona.FullName,
                                         entry.PedPersona.Surname,
                                         entry.Ped.Model.Name
                                         );
            var previousRow = listBox.FindChildByName(rowId);

            if (previousRow == null)
            {
                var row = listBox.AddRow(
                    String.Format("{0}{1} | {2}", alert, entry.Vehicle.Model.Name, entry.Vehicle.LicensePlate),
                    rowId,
                    entry);
                return(row);
            }
            return(previousRow as ListBoxRow);
        }
コード例 #12
0
 private static void generatePastArrestNum(ComputerPlusEntity entity)
 {
     if (entity.Ped.Metadata.pastArrestNum == null)
     {
         int randomNum = Globals.Random.Next(1, 12);
         int pastArrestNum;
         if (entity.PedPersona.Wanted)
         {
             if (randomNum > 5)
             {
                 pastArrestNum = 0;
             }
             else
             {
                 pastArrestNum = randomNum;
             }
         }
         else
         {
             if (randomNum > 2)
             {
                 pastArrestNum = 0;
             }
             else
             {
                 pastArrestNum = randomNum;
             }
         }
         entity.Ped.Metadata.pastArrestNum = pastArrestNum;
     }
 }
コード例 #13
0
        public static async Task <DetailedEntity> GetAllReportsForPedAsync(ComputerPlusEntity entity)
        {
            var arrests = await GetArrestReportsForPedAsync(entity);

            var traffic = await GetTrafficCitationsForPedAsync(entity);

            return(new DetailedEntity(entity, arrests, traffic));
        }
コード例 #14
0
 internal static ArrestReportContainer CreateForPed(ComputerPlusEntity entity, out ArrestReport report)
 {
     report = ArrestReport.CreateForPed(entity);
     return(new ArrestReportContainer(report)
     {
         LockArresteePedDetails = true
     });
 }
コード例 #15
0
 internal ComputerPlusEntity LookupPersona(Ped ped)
 {
     if (ped == null || (ped != null && !ped.Exists()))
     {
         return(null);
     }
     return(insertEntityToRecentSearches(ComputerPlusEntity.CreateFrom(ped)));
 }
コード例 #16
0
ファイル: ArrestReport.cs プロジェクト: waski35/ComputerPlus
 public static ArrestReport CreateForPed(ComputerPlusEntity entity)
 {
     return(!entity ? new ArrestReport() : new ArrestReport()
     {
         FirstName = entity.FirstName,
         LastName = entity.LastName,
         DOB = entity.DOBString,
         HomeAddress = entity.Address,
     });
 }
コード例 #17
0
        internal ComputerPlusEntity LookupPersona(Ped ped)
        {
            if (ped == null)
            {
                return(null);
            }
            var entity = ComputerPlusEntity.CreateFrom(ped);

            RecentSearches.Add(entity);
            return(entity);
        }
コード例 #18
0
        public static void ShowArrestReportCreate(ComputerPlusEntity entity, ArrestReportContainer.ArrestReportActionEvent callbackDelegate)
        {
            ArrestReport report;
            var          container = ArrestReportContainer.CreateForPed(entity, out report);

            if (callbackDelegate != null)
            {
                container.OnArrestReportAction += callbackDelegate;
            }
            Globals.PendingArrestReport = report;
            Globals.Navigation.Push(container);
        }
コード例 #19
0
        private static TrafficCitation generateRandomCitation(ComputerPlusEntity entity)
        {
            TrafficCitation newCitation = TrafficCitation.CreateForPedInVehicle(entity);

            newCitation.VehicleType = "N/A";
            int randomSeconds = Globals.Random.Next(SECONDS_IN_A_DAY * 7, SECONDS_IN_A_DAY * 1200) * -1;

            newCitation.CitationTimeDate      = DateTime.Now.ToUniversalTime().AddSeconds(randomSeconds);
            newCitation.CitationPos           = Rage.World.GetRandomPositionOnStreet();
            newCitation.CitationStreetAddress = Rage.World.GetStreetName(newCitation.CitationPos);
            newCitation.CitationCity          = Functions.GetZoneAtPosition(newCitation.CitationPos).RealAreaName;
            newCitation.Citation = ComputerPedController.GetRandomCitation();
            return(SaveTrafficCitation(newCitation));
        }
コード例 #20
0
        internal ComputerPlusEntity LookupPersona(String name)
        {
            List <Ped> peds = World.GetAllPeds().ToList();

            peds.RemoveAll(p => !p || !p.Exists());
            peds.OrderBy(p => p.DistanceTo(Game.LocalPlayer.Character.Position));
            var ped = peds.Where(p => p &&
                                 Functions.GetPersonaForPed(p).FullName.ToLower().Equals(name, StringComparison.CurrentCultureIgnoreCase))
                      .FirstOrDefault();

            if (ped == null)
            {
                return(null);
            }
            return(ComputerPlusEntity.CreateFrom(ped));
        }
コード例 #21
0
        internal ComputerPlusEntity LookupPersona(Ped ped)
        {
            if (ped == null)
            {
                return(null);
            }
            var persona = Functions.GetPersonaForPed(ped);

            if (persona == null)
            {
                return(null);
            }
            var entity = new ComputerPlusEntity(ped, persona);

            RecentSearches.Add(entity);
            return(entity);
        }
コード例 #22
0
        internal static ComputerPlusEntity insertEntityToRecentSearches(ComputerPlusEntity entity)
        {
            bool found = false;

            foreach (var ent in RecentSearches)
            {
                if (ent.FullName.Equals(entity.FullName) && ent.DOBString.Equals(entity.DOBString))
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                RecentSearches.Add(entity);
            }
            return(entity);
        }
コード例 #23
0
        internal static ComputerPlusEntity LookupVehicle(Vehicle vehicle)
        {
            if (!vehicle)
            {
                return(null);
            }
            var vehiclePersona = ComputerPlusEntity.GetPersonaForVehicle(vehicle);

            string             ownerName = Functions.GetVehicleOwnerName(vehicle);
            ComputerPlusEntity owner     = null;
            var driver = vehicle.HasDriver ? vehicle.Driver : null;

            if (driver != null)
            {
                Persona driverPersona = Functions.GetPersonaForPed(driver);
                if (!driverPersona.FullName.Equals(ownerName))
                {
                    owner = ComputerPedController.Instance.LookupPersona(ownerName);
                    if (owner == null)
                    {
                        owner = generateVehicleOwner(ownerName);
                    }
                }
                else
                {
                    owner = ComputerPedController.Instance.LookupPersona(driver);
                }
            }
            else
            {
                owner = ComputerPedController.Instance.LookupPersona(ownerName);
                if (owner == null)
                {
                    owner = generateVehicleOwner(ownerName);
                }
            }
            return(ComputerPlusEntity.CloneFrom(owner, vehicle, vehiclePersona));
        }
コード例 #24
0
        internal static ListBoxRow AddPed(this ListBox listBox, ComputerPlusEntity entry)
        {
            if (listBox == null)
            {
                return(null);
            }
            String alert = entry.PedPersona.Wanted ? "(ALERT) " : String.Empty;
            String rowId = String.Format("{0}_{1}_{2}",
                                         entry.PedPersona.FullName,
                                         entry.PedPersona.Surname,
                                         entry.Ped.Model.Name
                                         );
            var previousRow = listBox.FindChildByName(rowId);

            if (previousRow == null)
            {
                var row = listBox.AddRow(
                    String.Format("{0}({1}) | {2}", alert, entry.PedPersona.Gender.ToFriendlyString().First(), entry.PedPersona.FullName),
                    rowId,
                    entry);
                return(row);
            }
            return(previousRow as ListBoxRow);
        }
コード例 #25
0
 internal ComputerPedView(ComputerPlusEntity entity) : base(typeof(ComputerPedViewTemplate))
 {
     this.Ped     = entity.Ped;
     this.Persona = entity.PedPersona;
 }
コード例 #26
0
ファイル: PedReport.cs プロジェクト: wilson212/ComputerPlus
 internal DetailedEntity(ComputerPlusEntity entity, List <ArrestReport> arrests = null, List <TrafficCitation> citations = null)
 {
     Entity           = entity;
     Arrests          = arrests != null ? arrests : new List <ArrestReport>();
     TrafficCitations = citations != null ? citations : new List <TrafficCitation>();
 }
コード例 #27
0
        public static void createCourtCaseForArrest(ArrestReport report, ComputerPlusEntity entity)
        {
            if (Configs.EnableLSPDFRPlusIntegration && Function.IsLSPDFRPlusRunning() && entity != null)
            {
                string crimeStr             = String.Empty;
                string courtVerdictStr      = String.Empty;
                int    guiltyChance         = Globals.Random.Next(75, 101);
                int    verdictMonths        = 0;
                int    verdictYears         = 0;
                bool   trafficFelonyCharged = false;

                foreach (var charge in report.Charges)
                {
                    if (crimeStr.Equals(String.Empty))
                    {
                        crimeStr = charge.Charge;
                    }
                    else
                    {
                        crimeStr += ", " + charge.Charge;
                    }

                    if (charge.IsTraffic)
                    {
                        if (charge.IsFelony)
                        {
                            if (!trafficFelonyCharged)
                            {
                                courtVerdictStr      = "License revoked";
                                verdictMonths        = Globals.Random.Next(3, 13);
                                trafficFelonyCharged = true;
                            }
                        }
                        else
                        {
                            if (!trafficFelonyCharged)
                            {
                                courtVerdictStr = "Fined $" + Globals.Random.Next(500, 1001) + ". License suspended for " + Globals.Random.Next(6, 13) + " months";
                            }
                        }
                    }
                    else
                    {
                        if (charge.IsFelony)
                        {
                            verdictYears += Globals.Random.Next(4, 11);
                        }
                        else
                        {
                            verdictYears += Globals.Random.Next(1, 4);
                        }
                    }
                }

                if (verdictYears > 0 && verdictMonths > 0)
                {
                    verdictYears++;
                }
                string sentencePrisonStr = String.Empty;

                if (verdictYears > 0)
                {
                    sentencePrisonStr = "Sentenced to " + verdictYears + " years in prison";
                }
                else if (verdictMonths > 0)
                {
                    sentencePrisonStr = "Sentenced to " + verdictMonths + " months in prison";
                }

                if (courtVerdictStr.Equals(String.Empty))
                {
                    courtVerdictStr = sentencePrisonStr;
                }
                else
                {
                    courtVerdictStr += ". " + sentencePrisonStr;
                }

                LSPDFRPlusFunctions.CreateNewCourtCase(entity.PedPersona, crimeStr, guiltyChance, courtVerdictStr);
            }
        }
コード例 #28
0
 public static async Task <List <ArrestReport> > GetArrestReportsForPedAsync(ComputerPlusEntity entity)
 {
     return(await GetArrestReportsForPedAsync(entity.FirstName, entity.LastName, entity.DOBString));
 }
コード例 #29
0
 public static async Task <List <TrafficCitation> > GetTrafficCitationsForPedAsync(ComputerPlusEntity entity)
 {
     return(await GetTrafficCitationsForPedAsync(entity.FirstName, entity.LastName, entity.DOBString));
 }
コード例 #30
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));
        }