Exemple #1
0
        /// <summary>
        /// Return a string, in LSPDFR Police Scanner Audio file basename format, that describes the passed <paramref name="ped"/>.
        /// </summary>
        /// <param name="ped">The ped to describe</param>
        /// <param name="desiredProperties">Bitwise mask of the desired PedDescriptionPropertyTypes you wish to have described. You may wish to pass fewer than normal if a suspect description is vague, for example</param>
        /// <returns>Space-separated LSDPFR Police Scanner audio file basenames (e.g. "CLOTHING_LIGHT_SNEAKERS")</returns>
        public static string GetAudioDescription(Ped ped, PedDescriptionPropertyType desiredProperties)
        {
            if (!ped)
            {
                Configuration.Log($"Cannot operate on a null or invalid Ped");
                return(null);
            }

            StringBuilder output = new StringBuilder();
            IEnumerable <PedDescriptionProperty> allDescriptionProperties = GetPropertiesToMatch(ped);

            IEnumerable <PedDescriptionProperty> pedDescriptionProperties = allDescriptionProperties as IList <PedDescriptionProperty> ?? allDescriptionProperties.ToList();

            if ((desiredProperties & PedDescriptionPropertyType.RaceSex) != 0)
            {
                IEnumerable <PedDescriptionProperty> raceSexProperties = pedDescriptionProperties.Where(x => x.Type == PedDescriptionPropertyType.RaceSex);
                // we only expect a single RaceSex property, so we will not loop
                output.Append($"A_WITHOUT_HESITATION {raceSexProperties.FirstOrDefault()?.Audio} ");
            }

            if ((desiredProperties & PedDescriptionPropertyType.Build) != 0)
            {
                IEnumerable <PedDescriptionProperty> buildProperties = pedDescriptionProperties.Where(x => x.Type == PedDescriptionPropertyType.Build);
                foreach (PedDescriptionProperty property in buildProperties)
                {
                    output.Append($"200MS_SILENCE {property.Audio} ");
                }
            }

            if ((desiredProperties & PedDescriptionPropertyType.Hair) != 0)
            {
                IEnumerable <PedDescriptionProperty> hairProperties = pedDescriptionProperties.Where(x => x.Type == PedDescriptionPropertyType.Hair);
                foreach (PedDescriptionProperty property in hairProperties)
                {
                    output.Append($"200MS_SILENCE WITH {property.Audio} ");
                }
            }

            if ((desiredProperties & PedDescriptionPropertyType.Clothing) != 0)
            {
                int clothingPropertyCount = pedDescriptionProperties.Count(x => x.Type == PedDescriptionPropertyType.Clothing);

                if (clothingPropertyCount > 0)
                {
                    IEnumerable <PedDescriptionProperty> clothingProperties = pedDescriptionProperties.Where(x => x.Type == PedDescriptionPropertyType.Clothing);

                    output.Append("200MS_SILENCE WEARING ");

                    foreach (PedDescriptionProperty property in clothingProperties)
                    {
                        output.Append($" {property.Audio} 200MS_SILENCE ");
                    }
                }
            }

            return(output.ToString().TrimEnd());
        }
        /// <summary>
        /// Construct a new Property from the specified arguments. Intended to be used as an override where no XML node exists.
        /// </summary>
        /// <param name="type">The type of this Ped description property.</param>
        /// <param name="text">Textual description of this property, e.g. "light sneakers"</param>
        /// <param name="audio">Audio description of this property as an LSDPDR Police Scanner audio file basename (e.g. "CLOTHING_LIGHT_SNEAKERS")</param>
        /// <param name="component">The component index to which this Property pertains, or -1 to apply to all possible variations of this Ped Model.</param>
        /// <param name="drawable">The drawable index to which this Property pertains, or -1 to apply to all possible variations of this Ped Model (**not **just all drawables in this component).</param>
        /// <param name="texture">The texture variation to which this Property pertains, or -1 to apply to all possible variations of this Ped Model  (**not **just all textures in this drawable).</param>
        public PedDescriptionProperty(PedDescriptionPropertyType type, string text, string audio, int component = -1, int drawable = -1, int texture = -1)
        {
            Type = type;

            Text  = text;
            Audio = audio;

            Component = component;
            Drawable  = drawable;
            Texture   = texture;
        }
Exemple #3
0
        /// <summary>
        /// Return a string that describes the passed <paramref name="ped"/>.
        /// </summary>
        /// <param name="ped">The ped to describe</param>
        /// <param name="desiredProperties">Bitwise mask of the desired PedDescriptionPropertyTypes you wish to have described. You may wish to pass fewer than normal if a suspect description is vague, for example</param>
        /// <returns>human-readable description of ped</returns>
        public static string GetTextDescription(Ped ped, PedDescriptionPropertyType desiredProperties)
        {
            if (!ped)
            {
                Configuration.Log($"Cannot operate on a null or invalid Ped");
                return(null);
            }

            StringBuilder output = new StringBuilder();
            IEnumerable <PedDescriptionProperty> allDescriptionProperties = GetPropertiesToMatch(ped);

            IEnumerable <PedDescriptionProperty> pedDescriptionProperties = allDescriptionProperties as IList <PedDescriptionProperty> ?? allDescriptionProperties.ToList();

            if ((desiredProperties & PedDescriptionPropertyType.RaceSex) != 0)
            {
                IEnumerable <PedDescriptionProperty> raceSexProperties = pedDescriptionProperties.Where(x => x.Type == PedDescriptionPropertyType.RaceSex);
                // we only expect a single RaceSex property, so we will not loop
                if (raceSexProperties.FirstOrDefault() != null)
                {
                    if (raceSexProperties.FirstOrDefault().Text.Contains("hispanic") || raceSexProperties.FirstOrDefault().Text.Contains("asian"))
                    {
                        // title case
                        output.Append(raceSexProperties.FirstOrDefault().Text.Substring(0, 1).ToUpperInvariant() + raceSexProperties.FirstOrDefault().Text.Substring(1) + " ");
                    }
                    else
                    {
                        output.Append(raceSexProperties.FirstOrDefault().Text + " ");
                    }
                }
            }

            if ((desiredProperties & PedDescriptionPropertyType.Build) != 0)
            {
                IEnumerable <PedDescriptionProperty> buildProperties = pedDescriptionProperties.Where(x => x.Type == PedDescriptionPropertyType.Build);
                foreach (PedDescriptionProperty property in buildProperties)
                {
                    // trim last space
                    if (output.Length > 0 && output.ToString().Substring(output.Length - 1, 1) == " ")
                    {
                        output.Remove(output.Length - 1, 1);
                    }

                    output.Append($", {property.Text}, ");
                }
            }

            if ((desiredProperties & PedDescriptionPropertyType.Hair) != 0)
            {
                IEnumerable <PedDescriptionProperty> hairProperties = pedDescriptionProperties.Where(x => x.Type == PedDescriptionPropertyType.Hair);
                foreach (PedDescriptionProperty property in hairProperties)
                {
                    output.Append($"with {property.Text} ");
                }
            }

            if ((desiredProperties & PedDescriptionPropertyType.Clothing) != 0)
            {
                int clothingPropertyCount = pedDescriptionProperties.Count(x => x.Type == PedDescriptionPropertyType.Clothing);

                if (clothingPropertyCount > 0)
                {
                    IEnumerable <PedDescriptionProperty> clothingProperties = pedDescriptionProperties.Where(x => x.Type == PedDescriptionPropertyType.Clothing);

                    output.Append("wearing ");

                    foreach (PedDescriptionProperty property in clothingProperties)
                    {
                        if (!property.Text.ToLowerInvariant().Contains("pants") &&
                            !property.Text.ToLowerInvariant().Contains("shorts") &&
                            !property.Text.ToLowerInvariant().Contains("jeans") &&
                            !property.Text.ToLowerInvariant().Contains("sneakers") &&
                            !property.Text.ToLowerInvariant().Contains("shoes") &&
                            !property.Text.ToLowerInvariant().StartsWith("no") &&
                            !property.Text.ToLowerInvariant().Contains("boots") &&
                            !property.Text.ToLowerInvariant().Contains("tracksuit"))
                        {
                            output.Append("a ");
                        }
                        output.Append($"{property.Text}, ");
                    }
                }
            }

            return(output.ToString().TrimEnd(',', ' '));
        }