Ejemplo n.º 1
0
        private IntPtr GetDefaultWorld()
        {
#if WITH_EDITORONLY_DATA
            FWorldContext worldContext = new FWorldContext(Native_UEditorEngine.GetPIEWorldContext(FGlobals.GEditor));
            return(worldContext.IsNull ? IntPtr.Zero : worldContext.CurrentWorld);
#else
            return(Native_UObject.GetWorld(FGlobals.GEngine));
#endif
        }
Ejemplo n.º 2
0
        public GameStaticVar(GetDefaultValueHandler getDefaultValue)
        {
            GetDefaultValue = getDefaultValue;
            if (GetDefaultValue != null)
            {
#if WITH_EDITOR
                IntPtr pieWorldContext = Native_UEditorEngine.GetPIEWorldContext(FGlobals.GEditor);
                if (pieWorldContext != IntPtr.Zero)
                {
                    Value = GetDefaultValue();
                }
#else
                Value = GetDefaultValue();
#endif
            }
        }
Ejemplo n.º 3
0
        public static FTimerManager GetManager(IntPtr address)
        {
            if (address == IntPtr.Zero)
            {
                return(null);
            }

            TimerManagerInfo timerManagerInfo;

            if (timerManagers.TryGetValue(address, out timerManagerInfo))
            {
                return(timerManagerInfo.TimeManager);
            }

            UpdateOwnerClasses();

            IntPtr owner = IntPtr.Zero;

            if (owner == IntPtr.Zero && worldClass != IntPtr.Zero)
            {
                foreach (IntPtr world in new NativeReflection.NativeObjectIterator(worldClass))
                {
                    IntPtr timerManager = Native_UWorld.GetTimerManager(world);
                    if (timerManager == address)
                    {
                        IntPtr gameInstance = Native_UWorld.GetGameInstance(world);
                        if (gameInstance != IntPtr.Zero && Native_UGameInstance.GetTimerManager(gameInstance) == address)
                        {
                            owner = gameInstance;
                            break;
                        }
                        else
                        {
                            owner = world;
                            break;
                        }
                    }
                }
            }

            if (owner == IntPtr.Zero && gameInstanceClass != IntPtr.Zero)
            {
                foreach (IntPtr gameInstance in new NativeReflection.NativeObjectIterator(gameInstanceClass))
                {
                    if (Native_UGameInstance.GetTimerManager(gameInstance) == address)
                    {
                        owner = gameInstance;
                        break;
                    }
                }
            }

            if (owner == IntPtr.Zero && editorEngineClass != IntPtr.Zero)
            {
                foreach (IntPtr editorEngine in new NativeReflection.NativeObjectIterator(editorEngineClass))
                {
                    if (Native_UEditorEngine.GetTimerManager(editorEngine) == address)
                    {
                        owner = editorEngine;
                        break;
                    }
                }
            }

            if (owner != IntPtr.Zero)
            {
                FWeakObjectPtr ownerWeakObjPtr = new FWeakObjectPtr();
                ownerWeakObjPtr.Set(owner);
                timerManagerInfo             = new TimerManagerInfo();
                timerManagerInfo.Owner       = ownerWeakObjPtr;
                timerManagerInfo.TimeManager = new FTimerManager(address);

                timerManagers.Add(address, timerManagerInfo);
                timerManagerOwners[ownerWeakObjPtr] = address;

                return(timerManagerInfo.TimeManager);
            }
            else
            {
                return(new FTimerManager(address));
            }
        }