Exemple #1
0
        private void UpdateAvailableTypes(UField field)
        {
            if (field == null)
            {
                return;
            }

            System.Diagnostics.Debug.Assert(!field.IsA <UProperty>(), "Shouldn't have UProperty here");

            if (field.IsA <UStruct>() || field.IsA <UEnum>())
            {
                bool isNewElement = availableTypes.Add(field);
                if (!isNewElement)
                {
                    return;
                }
            }

            if (Settings.ExportMode != CodeGeneratorSettings.CodeExportMode.Referenced)
            {
                return;
            }

            // Get all of the references from this struct
            UStruct unrealStruct = field as UStruct;

            if (unrealStruct != null)
            {
                bool isBlueprintType = unrealStruct.IsA <UUserDefinedStruct>() || unrealStruct.IsA <UBlueprintGeneratedClass>();

                // Get struct references from parent class chain
                UStruct parentStruct = unrealStruct.GetSuperStruct();
                while (parentStruct != null)
                {
                    UpdateAvailableTypes(parentStruct);
                    parentStruct = parentStruct.GetSuperStruct();
                }

                // Get references from interfaces
                UClass unrealClass = field as UClass;
                if (unrealClass != null)
                {
                    foreach (FImplementedInterface implementedInterface in unrealClass.Interfaces)
                    {
                        UpdateAvailableTypes(implementedInterface.InterfaceClass);
                    }
                }

                // Get struct references from members
                foreach (UProperty property in unrealStruct.GetFields <UProperty>(false))
                {
                    if (CanExportProperty(property, unrealStruct, isBlueprintType))
                    {
                        UpdateAvailableTypesProp(property);
                    }
                }

                // Get struct references from function params (and return type)
                foreach (UFunction unrealFunction in unrealStruct.GetFields <UFunction>(false))
                {
                    if (CanExportFunction(unrealFunction, isBlueprintType))
                    {
                        foreach (UProperty parameter in unrealFunction.GetFields <UProperty>())
                        {
                            UpdateAvailableTypesProp(parameter);
                        }
                    }
                }
            }

            // This should be for global functions only (delegates)
            UFunction function = field as UFunction;

            if (function != null)
            {
                if (CanExportFunction(function, false))
                {
                    UStruct functionOwner = function.GetOuter() as UStruct;
                    if (functionOwner != null)
                    {
                        UpdateAvailableTypes(functionOwner);
                    }

                    foreach (UProperty parameter in function.GetFields <UProperty>())
                    {
                        UpdateAvailableTypesProp(parameter);
                    }
                }
            }
        }