コード例 #1
0
ファイル: StaticVar.cs プロジェクト: yimengfan/USharp
        private static void OnPostWorldCleanup(IntPtr world, bool sessionEnded, bool cleanupResources)
        {
            // At this point UGameInstance::WorldContext should have been set to nullptr. While WorldContext being nullptr
            // doesn't mean the UGameInstance is nessesarily "destroyed" but there isn't any code which reinitializes
            // UGameInstance by calling UGameInstance::InitializeStandalone / UGameInstance::InitializeForMinimalNetRPC
            //
            // UEditorEngine::TeardownPlaySession()
            // {
            //     UGameInstance::Shutdown(); - sets this->WorldContext = nullptr
            //     PlayWorld->CleanupWorld(); - called shortly after Shutdown()
            //     {
            //         // These delegates are the first available delegates we can use after UGameInstance state is invalidated
            //         FWorldDelegates::OnWorldCleanup
            //         FWorldDelegates::OnPostWorldCleanup
            //     }
            // }

            // TODO: Only call this on types which override this function
            IntPtr gameInstance = Native_UWorld.GetGameInstance(world);

            foreach (StaticVar staticVar in Vars)
            {
                if (gameInstance != IntPtr.Zero)
                {
                    staticVar.OnGameInstanceShutdown(gameInstance);
                }
                staticVar.OnWorldDestroyed(world);
            }
        }
コード例 #2
0
ファイル: StaticVar.cs プロジェクト: yimengfan/USharp
        public virtual bool TryGetValue(UObject worldContextObject, out T value)
        {
            IntPtr world = Native_UObject.GetWorld(worldContextObject.Address);

            if (worldTypeFlags == 0)
            {
                if (values.TryGetValue(world, out value))
                {
                    return(true);
                }
            }
            else if (world != IntPtr.Zero)
            {
                int worldType = (1 << (int)Native_UWorld.Get_WorldType(world));
                if ((worldTypeFlags & worldType) == worldType)
                {
                    if (values.TryGetValue(world, out value))
                    {
                        return(true);
                    }
                }
            }
            value = default(T);
            return(false);
        }
コード例 #3
0
ファイル: WorldTimeHelper.cs プロジェクト: yimengfan/USharp
 internal static void OnNativeFunctionsRegistered()
 {
     timeSecondsOffset         = Native_UWorld.Offset_TimeSeconds();
     unpausedTimeSecondsOffset = Native_UWorld.Offset_UnpausedTimeSeconds();
     realTimeSecondsOffset     = Native_UWorld.Offset_RealTimeSeconds();
     deltaTimeSecondsOffset    = Native_UWorld.Offset_DeltaTimeSeconds();
     pauseDelayOffset          = Native_UWorld.Offset_PauseDelay();
 }
コード例 #4
0
ファイル: StaticVar.cs プロジェクト: zwywilliam/USharp
        public T Set(UObject worldContextObject, T value)
        {
            IntPtr gameInstance = Native_UWorld.GetGameInstance(worldContextObject.Address);

            if (gameInstance != IntPtr.Zero)
            {
                values[gameInstance] = value;
            }
            return(value);
        }
コード例 #5
0
ファイル: StaticVar.cs プロジェクト: zwywilliam/USharp
        public virtual bool Clear(UObject worldContextObject)
        {
            IntPtr gameInstance = Native_UWorld.GetGameInstance(worldContextObject.Address);

            if (gameInstance != IntPtr.Zero)
            {
                return(values.Remove(gameInstance));
            }
            return(false);
        }
コード例 #6
0
ファイル: StaticVar.cs プロジェクト: zwywilliam/USharp
        public virtual bool HasValue()
        {
            IntPtr world = GetDefaultWorld();

            if (world != IntPtr.Zero)
            {
                IntPtr gameInstance = Native_UWorld.GetGameInstance(world);
                return(gameInstance != IntPtr.Zero && values.ContainsKey(gameInstance));
            }
            return(false);
        }
コード例 #7
0
ファイル: StaticVar.cs プロジェクト: zwywilliam/USharp
        public virtual bool TryGetValue(UObject worldContextObject, out T value)
        {
            IntPtr gameInstance = Native_UWorld.GetGameInstance(worldContextObject.Address);

            if (gameInstance != IntPtr.Zero)
            {
                if (values.TryGetValue(gameInstance, out value))
                {
                    return(true);
                }
            }
            value = default(T);
            return(false);
        }
コード例 #8
0
ファイル: StaticVar.cs プロジェクト: zwywilliam/USharp
        public T Set(T value)
        {
            IntPtr world = GetDefaultWorld();

            if (world != IntPtr.Zero)
            {
                IntPtr gameInstance = Native_UWorld.GetGameInstance(world);
                if (gameInstance != IntPtr.Zero)
                {
                    values[gameInstance] = value;
                }
            }
            return(value);
        }
コード例 #9
0
ファイル: StaticVar.cs プロジェクト: zwywilliam/USharp
        public virtual bool Clear()
        {
            IntPtr world = GetDefaultWorld();

            if (world != IntPtr.Zero)
            {
                IntPtr gameInstance = Native_UWorld.GetGameInstance(world);
                if (gameInstance != IntPtr.Zero)
                {
                    return(values.Remove(gameInstance));
                }
            }
            return(false);
        }
コード例 #10
0
ファイル: World_Injected.cs プロジェクト: iainmckay/USharp
        public AActor SpawnActor(UClass unrealClass, ref FVector location, ref FRotator rotation, ref FActorSpawnParameters parameters)
        {
            FActorSpawnParametersInterop interopParams = new FActorSpawnParametersInterop()
            {
                Name          = parameters.Name,
                Template      = parameters.Template == null ? IntPtr.Zero : parameters.Template.Address,
                Owner         = parameters.Owner == null ? IntPtr.Zero : parameters.Owner.Address,
                Instigator    = parameters.Instigator == null ? IntPtr.Zero : parameters.Instigator.Address,
                OverrideLevel = parameters.OverrideLevel == null ? IntPtr.Zero : parameters.OverrideLevel.Address,
                SpawnCollisionHandlingOverride = parameters.SpawnCollisionHandlingOverride,
                PackedBools = parameters.PackedBools,
                ObjectFlags = parameters.ObjectFlags
            };

            return(GCHelper.Find <AActor>(Native_UWorld.SpawnActor(Address, unrealClass.Address, ref location, ref rotation, ref interopParams)));
        }
コード例 #11
0
ファイル: StaticVar.cs プロジェクト: yimengfan/USharp
        public virtual bool HasValue(UObject worldContextObject)
        {
            IntPtr world = Native_UObject.GetWorld(worldContextObject.Address);

            if (worldTypeFlags == 0)
            {
                return(values.ContainsKey(world));
            }
            else if (world != IntPtr.Zero)
            {
                int worldType = (1 << (int)Native_UWorld.Get_WorldType(world));
                if ((worldTypeFlags & worldType) == worldType)
                {
                    return(values.ContainsKey(world));
                }
            }
            return(false);
        }
コード例 #12
0
ファイル: StaticVar.cs プロジェクト: zwywilliam/USharp
        public virtual bool TryGetValue(out T value)
        {
            IntPtr world = GetDefaultWorld();

            if (world != IntPtr.Zero)
            {
                IntPtr gameInstance = Native_UWorld.GetGameInstance(world);
                if (gameInstance != IntPtr.Zero)
                {
                    if (values.TryGetValue(gameInstance, out value))
                    {
                        return(true);
                    }
                }
            }
            value = default(T);
            return(false);
        }
コード例 #13
0
ファイル: StaticVar.cs プロジェクト: yimengfan/USharp
        public virtual bool Set(UObject worldContextObject, T value)
        {
            IntPtr world = Native_UObject.GetWorld(worldContextObject.Address);

            if (worldTypeFlags == 0)
            {
                values[world] = value;
                return(true);
            }
            else if (world != IntPtr.Zero)
            {
                int worldType = (1 << (int)Native_UWorld.Get_WorldType(world));
                if ((worldTypeFlags & worldType) == worldType)
                {
                    values[world] = value;
                    return(true);
                }
            }
            return(false);
        }
コード例 #14
0
ファイル: FTimerManager.cs プロジェクト: yimengfan/USharp
        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));
            }
        }
コード例 #15
0
ファイル: World_Injected.cs プロジェクト: yimengfan/USharp
 public FLatentActionManager GetLatentActionManager()
 {
     return(new FLatentActionManager(Native_UWorld.GetLatentActionManager(Address)));
 }
コード例 #16
0
ファイル: StaticVar.cs プロジェクト: zwywilliam/USharp
        public virtual bool HasValue(UObject worldContextObject)
        {
            IntPtr gameInstance = Native_UWorld.GetGameInstance(worldContextObject.Address);

            return(gameInstance != IntPtr.Zero && values.ContainsKey(gameInstance));
        }
コード例 #17
0
ファイル: World_Injected.cs プロジェクト: iainmckay/USharp
        public AActor SpawnActor(UClass unrealClass, ref FVector location, ref FRotator rotation)
        {
            FActorSpawnParametersInterop parameters = default(FActorSpawnParametersInterop);

            return(GCHelper.Find <AActor>(Native_UWorld.SpawnActor(Address, unrealClass.Address, ref location, ref rotation, ref parameters)));
        }
コード例 #18
0
ファイル: World_Injected.cs プロジェクト: yimengfan/USharp
 public APlayerController GetFirstPlayerController()
 {
     return(GCHelper.Find <APlayerController>(Native_UWorld.GetFirstPlayerController(Address)));
 }