Пример #1
0
        /// <summary>
        /// Checks if a key in the map matches the specified key
        /// </summary>
        /// <param name="inBaseAddress">The base address of the map</param>
        /// <param name="inKeyValue">The key to find within the map</param>
        /// <returns>True if the key is found, false otherwise</returns>
        public bool HasKey(IntPtr inBaseAddress, string inKeyValue)
        {
            for (int index = 0, itemsLeft = Num(); itemsLeft > 0; ++index)
            {
                if (IsValidIndex(index))
                {
                    --itemsLeft;

                    IntPtr pairPtr = GetPairPtr(index);
                    IntPtr keyPtr  = Native_UProperty.ContainerVoidPtrToValuePtr(keyProp, pairPtr, 0);

                    using (FStringUnsafe keyValueUnsafe = new FStringUnsafe())
                    {
                        if (keyPtr != inBaseAddress && Native_UProperty.ExportText_Direct(keyProp, ref keyValueUnsafe.Array,
                                                                                          keyPtr, keyPtr, IntPtr.Zero, 0, IntPtr.Zero))
                        {
                            // Should this be case insensitive? (FString by default is case insensitive)
                            if ((Native_UObjectBaseUtility.IsA(keyProp, Classes.UObjectProperty) &&
                                 keyValueUnsafe.Value.Contains(inKeyValue)) || inKeyValue == keyValueUnsafe.Value)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Пример #2
0
        /// <summary>
        /// Checks if an element has already been added to the set
        /// </summary>
        /// <param name="inBaseAddress">The base address of the set</param>
        /// <param name="inElementValue">The element value to check for</param>
        /// <returns>True if the element is found in the set, false otherwise</returns>
        public bool HasElement(IntPtr inBaseAddress, string inElementValue)
        {
            for (int index = 0, itemsLeft = Num(); itemsLeft > 0; ++index)
            {
                if (IsValidIndex(index))
                {
                    --itemsLeft;

                    IntPtr element = GetElementPtr(index);

                    using (FStringUnsafe keyValueUnsafe = new FStringUnsafe())
                    {
                        if (element != inBaseAddress && Native_UProperty.ExportText_Direct(elementProp, ref keyValueUnsafe.Array,
                                                                                           element, element, IntPtr.Zero, 0, IntPtr.Zero))
                        {
                            // Should this be case insensitive? (FString by default is case insensitive)
                            if ((Native_UObjectBaseUtility.IsA(elementProp, Classes.UObjectProperty) &&
                                 keyValueUnsafe.Value.Contains(inElementValue)) || inElementValue == keyValueUnsafe.Value)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        /// Copies the value from a property into the string OutForm. DirectValue is the raw memory address of the property value
        ///
        /// <para/>This is a copy of FBlueprintEditorUtils::PropertyValueToString_Direct()
        /// </summary>
        public bool ValueToString_Direct(IntPtr directValue, out string result)
        {
            // TODO: Handle the special case math structs like in FBlueprintEditorUtils::PropertyValueToString_Direct

            using (FStringUnsafe resultUnsafe = new FStringUnsafe())
            {
                IntPtr defaultValue = directValue;
                bool   succeeded    = Native_UProperty.ExportText_Direct(Address, ref resultUnsafe.Array,
                                                                         directValue, defaultValue, IntPtr.Zero, (int)EPropertyPortFlags.SerializedAsImportText, IntPtr.Zero);
                result = resultUnsafe.Value;
                return(succeeded);
            }
        }