コード例 #1
0
 internal static void Setup() {
     OnMotionControllerUpdated_link = new DelegateHolder<NativeFuncDelegate>(OnMotionControllerUpdated_process_event);
     var uf = Main.GetUFunction("OnMotionControllerUpdated");
     var func = UObject.Make<Function>(uf);
     func.SetFlags(func.GetFlags() | EFunctionFlags.FUNC_Native);
     func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(OnMotionControllerUpdated_link.Delegate));
 }
コード例 #2
0
ファイル: Main.cs プロジェクト: jcoder58/Plugins
        public static int Start(string argument)
        {
            IntPtr ptr = new IntPtr(long.Parse(argument));

            SharedData = (Shared *)ptr.ToPointer();
            SharedData->Validate();

            try {
                PushNameForCpp      = new DelegateHolder <PushNameDelegate>(PushName);
                PushInterfaceForCpp = new DelegateHolder <PushInterfaceDelegate>(PushInterface);
                PushUObjectForCpp   = new DelegateHolder <PushUObjectDelegate>(PushUObject);
                TestForCpp          = new DelegateHolder <TestDelegate>(Test);
                DotNetCallForCpp    = new DelegateHolder <DotNetCallDelegate>(DotNetCall);

                SharedData->SetPushNameFunction(Marshal.GetFunctionPointerForDelegate(PushNameForCpp.Delegate));
                SharedData->SetPushInterfaceFunction(Marshal.GetFunctionPointerForDelegate(PushInterfaceForCpp.Delegate));
                SharedData->SetTestFunction(Marshal.GetFunctionPointerForDelegate(TestForCpp.Delegate));
                SharedData->SetPushUObjectFunction(Marshal.GetFunctionPointerForDelegate(PushUObjectForCpp.Delegate));
                SharedData->SetDotNetCallFunction(Marshal.GetFunctionPointerForDelegate(DotNetCallForCpp.Delegate));
            } catch (Exception ex) {
                Debug.WriteLine(ex.ToString());
            }
            Log.Display("UE4 DotNet Started");
            return(1234);
        }
コード例 #3
0
 static void CacheMethod(Type handler, Type messageType, Type interfaceGenericType, Dictionary<RuntimeTypeHandle, List<DelegateHolder>> cache)
 {
     var handleMethod = GetMethod(handler, messageType, interfaceGenericType);
     if (handleMethod == null)
     {
         return;
     }
     var delegateHolder = new DelegateHolder
         {
             MessageType = messageType,
             MethodDelegate = handleMethod
         };
     List<DelegateHolder> methodList;
     if (cache.TryGetValue(handler.TypeHandle, out methodList))
     {
         if (methodList.Any(x => x.MessageType == messageType))
         {
             return;
         }
         methodList.Add(delegateHolder);
     }
     else
     {
         cache[handler.TypeHandle] = new List<DelegateHolder>
             {
                 delegateHolder
             };
     }
 }
コード例 #4
0
        static void CacheMethod(Type handler, Type messageType, Type interfaceGenericType, Dictionary <RuntimeTypeHandle, List <DelegateHolder> > cache)
        {
            var handleMethod = GetMethod(handler, messageType, interfaceGenericType);

            if (handleMethod == null)
            {
                return;
            }
            var delegateHolder = new DelegateHolder
            {
                MessageType    = messageType,
                MethodDelegate = handleMethod
            };
            List <DelegateHolder> methodList;

            if (cache.TryGetValue(handler.TypeHandle, out methodList))
            {
                if (methodList.Any(x => x.MessageType == messageType))
                {
                    return;
                }
                methodList.Add(delegateHolder);
            }
            else
            {
                cache[handler.TypeHandle] = new List <DelegateHolder>
                {
                    delegateHolder
                };
            }
        }
コード例 #5
0
        public void SerializeObjectsWithDelegateToThisObject()
        {
            DelegateHolder proxy =
                (DelegateHolder)generator.CreateClassProxy(typeof(DelegateHolder), new IInterceptor[] { new StandardInterceptor() });

            proxy.DelegateMember    = new EventHandler(proxy.TestHandler);
            proxy.ComplexTypeMember = new ArrayList(new int[] { 1, 2, 3 });

            Assert.IsNotNull(proxy.DelegateMember);
            Assert.AreSame(proxy, proxy.DelegateMember.Target);

            Assert.IsNotNull(proxy.ComplexTypeMember);
            Assert.AreEqual(3, proxy.ComplexTypeMember.Count);
            Assert.AreEqual(1, proxy.ComplexTypeMember[0]);
            Assert.AreEqual(2, proxy.ComplexTypeMember[1]);
            Assert.AreEqual(3, proxy.ComplexTypeMember[2]);

            DelegateHolder otherProxy = (DelegateHolder)(SerializeAndDeserialize(proxy));

            Assert.IsNotNull(otherProxy.DelegateMember);
            Assert.AreSame(otherProxy, otherProxy.DelegateMember.Target);

            Assert.IsNotNull(otherProxy.ComplexTypeMember);
            Assert.AreEqual(3, otherProxy.ComplexTypeMember.Count);
            Assert.AreEqual(1, otherProxy.ComplexTypeMember[0]);
            Assert.AreEqual(2, otherProxy.ComplexTypeMember[1]);
            Assert.AreEqual(3, otherProxy.ComplexTypeMember[2]);
        }
コード例 #6
0
ファイル: RenderTargetsPlugin.cs プロジェクト: tiomke/paradox
        public override void Load()
        {
            base.Load();

            if (OfflineCompilation)
            {
                return;
            }

            if (!Parameters.ContainsKey(EffectPlugin.DepthStencilStateKey))
            {
                DepthStencilState = GraphicsDevice.DepthStencilStates.Default;
            }

            if (EnableSetTargets || EnableClearTarget || EnableClearDepth)
            {
                // Main pre-pass: clear render target & depth buffer, and bind them
                // TODO: Separate prepass from per-rendercontext init
                startPassAction = (threadContext) =>
                {
                    if (threadContext.FirstContext)
                    {
                        if (EnableClearDepth && DepthStencil != null && !UseDepthStencilReadOnly)
                        {
                            threadContext.GraphicsDevice.Clear(DepthStencil, DepthStencilClearOptions.DepthBuffer, ClearDepth, ClearStencil);
                        }
                        if (EnableClearTarget && RenderTarget != null)
                        {
                            threadContext.GraphicsDevice.Clear(RenderTarget, ClearColor);
                        }
                    }

                    if (EnableSetTargets)
                    {
                        // If the Viewport is undefined, use the render target dimension
                        var viewPort = Viewport;
                        if (viewPort == Viewport.Empty)
                        {
                            var desc = RenderTarget != null ? RenderTarget.Description : threadContext.GraphicsDevice.BackBuffer.Description;
                            viewPort = new Viewport(0, 0, desc.Width, desc.Height);
                            Viewport = viewPort;
                        }

                        var depthStencil = UseDepthStencilReadOnly ? DepthStencilReadOnly : DepthStencil;

                        threadContext.GraphicsDevice.SetViewport(viewPort);
                        threadContext.GraphicsDevice.SetRenderTargets(depthStencil, RenderTarget);
                    }
                };
                RenderPass.StartPass += startPassAction;
            }

            // Unbind depth stencil buffer and render targets
            if (EnableSetTargets)
            {
                endPassAction       = (threadContext) => threadContext.GraphicsDevice.UnsetRenderTargets();
                RenderPass.EndPass += endPassAction;
            }
        }
コード例 #7
0
 /// <summary>
 /// Check array bounds
 /// </summary>
 public static T DeserializeSafe <T>(byte[] data) where T : struct
 {
     if (DelegateHolder <T> .SizeInBytes != data.Length)
     {
         throw new ArgumentException(string.Format("Struct size is {0} bytes but array is {1} bytes length", DelegateHolder <T> .SizeInBytes, data.Length));
     }
     return(DelegateHolder <T> .Deserialize(data));
 }
コード例 #8
0
ファイル: CameraModifier.cs プロジェクト: jcoder58/Plugins
            internal static void Setup()
            {
                BlueprintModifyPostProcess_link = new DelegateHolder <NativeFuncDelegate>(BlueprintModifyPostProcess_process_event);
                var uf   = Main.GetUFunction("BlueprintModifyPostProcess");
                var func = UObject.Make <Function>(uf);

                func.SetFlags(func.GetFlags() | EFunctionFlags.FUNC_Native);
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(BlueprintModifyPostProcess_link.Delegate));
            }
コード例 #9
0
        /// <summary>
        /// Быстрое копирование через expression Tree
        /// </summary>
        public static TTargetClass Cast2 <TSourceInterface, TTargetClass>(this TSourceInterface srcObj) where TTargetClass : class, TSourceInterface, new()
        {
            if (srcObj == null)
            {
                throw new ArgumentNullException(nameof(srcObj));
            }

            return(srcObj as TTargetClass ?? DelegateHolder <TTargetClass, TSourceInterface> .InternalCast(srcObj));
        }
コード例 #10
0
ファイル: UObject.cs プロジェクト: jcoder58/Plugins
            internal static void Setup()
            {
                ExecuteUbergraph_link = new DelegateHolder <NativeFuncDelegate>(ExecuteUbergraph_process_event);
                var uf   = Main.GetUFunction("ExecuteUbergraph");
                var func = UObject.Make <Function>(uf);

                func.SetFlags(func.GetFlags() | EFunctionFlags.FUNC_Native);
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(ExecuteUbergraph_link.Delegate));
            }
コード例 #11
0
            internal static void Setup()
            {
                OnPhotographySessionStart_link = new DelegateHolder <NativeFuncDelegate>(OnPhotographySessionStart_process_event);
                var uf   = Main.GetUFunction("OnPhotographySessionStart");
                var func = UObject.Make <Function>(uf);

                NativeFunction = Marshal.GetDelegateForFunctionPointer <FNativeFuncPtr>(func.GetNativeFunc());
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(OnPhotographySessionStart_link.Delegate));
            }
コード例 #12
0
ファイル: Exporter.cs プロジェクト: jcoder58/Plugins
            internal static void Setup()
            {
                ScriptRunAssetExportTask_link = new DelegateHolder <NativeFuncDelegate>(ScriptRunAssetExportTask_process_event);
                var uf   = Main.GetUFunction("ScriptRunAssetExportTask");
                var func = UObject.Make <Function>(uf);

                func.SetFlags(func.GetFlags() | EFunctionFlags.FUNC_Native);
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(ScriptRunAssetExportTask_link.Delegate));
            }
コード例 #13
0
            internal static void Setup()
            {
                PerformConditionCheckAI_link = new DelegateHolder <NativeFuncDelegate>(PerformConditionCheckAI_process_event);
                var uf   = Main.GetUFunction("PerformConditionCheckAI");
                var func = UObject.Make <Function>(uf);

                func.SetFlags(func.GetFlags() | EFunctionFlags.FUNC_Native);
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(PerformConditionCheckAI_link.Delegate));
            }
コード例 #14
0
            internal static void Setup()
            {
                K2_OnSwapPlayerControllers_link = new DelegateHolder <NativeFuncDelegate>(K2_OnSwapPlayerControllers_process_event);
                var uf   = Main.GetUFunction("K2_OnSwapPlayerControllers");
                var func = UObject.Make <Function>(uf);

                func.SetFlags(func.GetFlags() | EFunctionFlags.FUNC_Native);
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(K2_OnSwapPlayerControllers_link.Delegate));
            }
コード例 #15
0
            internal static void Setup()
            {
                OnAdditionalTestFinishedMessageRequest_link = new DelegateHolder <NativeFuncDelegate>(OnAdditionalTestFinishedMessageRequest_process_event);
                var uf   = Main.GetUFunction("OnAdditionalTestFinishedMessageRequest");
                var func = UObject.Make <Function>(uf);

                func.SetFlags(func.GetFlags() | EFunctionFlags.FUNC_Native);
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(OnAdditionalTestFinishedMessageRequest_link.Delegate));
            }
コード例 #16
0
            internal static void Setup()
            {
                HandleStartingNewPlayer_link = new DelegateHolder <NativeFuncDelegate>(HandleStartingNewPlayer_process_event);
                var uf   = Main.GetUFunction("HandleStartingNewPlayer");
                var func = UObject.Make <Function>(uf);

                NativeFunction = Marshal.GetDelegateForFunctionPointer <FNativeFuncPtr>(func.GetNativeFunc());
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(HandleStartingNewPlayer_link.Delegate));
            }
コード例 #17
0
            internal static void Setup()
            {
                OnFunctionalTestingComplete_link = new DelegateHolder <NativeFuncDelegate>(OnFunctionalTestingComplete_process_event);
                var uf   = Main.GetUFunction("OnFunctionalTestingComplete");
                var func = UObject.Make <Function>(uf);

                func.SetFlags(func.GetFlags() | EFunctionFlags.FUNC_Native);
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(OnFunctionalTestingComplete_link.Delegate));
            }
コード例 #18
0
            internal static void Setup()
            {
                ProvideSingleLocation_link = new DelegateHolder <NativeFuncDelegate>(ProvideSingleLocation_process_event);
                var uf   = Main.GetUFunction("ProvideSingleLocation");
                var func = UObject.Make <Function>(uf);

                func.SetFlags(func.GetFlags() | EFunctionFlags.FUNC_Native);
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(ProvideSingleLocation_link.Delegate));
            }
コード例 #19
0
            internal static void Setup()
            {
                IsReady_link = new DelegateHolder <NativeFuncDelegate>(IsReady_process_event);
                var uf   = Main.GetUFunction("IsReady");
                var func = UObject.Make <Function>(uf);

                NativeFunction = Marshal.GetDelegateForFunctionPointer <FNativeFuncPtr>(func.GetNativeFunc());
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(IsReady_link.Delegate));
            }
コード例 #20
0
ファイル: Character.cs プロジェクト: jcoder58/Plugins
            internal static void Setup()
            {
                K2_UpdateCustomMovement_link = new DelegateHolder <NativeFuncDelegate>(K2_UpdateCustomMovement_process_event);
                var uf   = Main.GetUFunction("K2_UpdateCustomMovement");
                var func = UObject.Make <Function>(uf);

                func.SetFlags(func.GetFlags() | EFunctionFlags.FUNC_Native);
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(K2_UpdateCustomMovement_link.Delegate));
            }
コード例 #21
0
            internal static void Setup()
            {
                ReceiveTick_link = new DelegateHolder <NativeFuncDelegate>(ReceiveTick_process_event);
                var uf   = Main.GetUFunction("ReceiveTick");
                var func = UObject.Make <Function>(uf);

                func.SetFlags(func.GetFlags() | EFunctionFlags.FUNC_Native);
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(ReceiveTick_link.Delegate));
            }
コード例 #22
0
            internal static void Setup()
            {
                BP_OnItemSelectionChanged_link = new DelegateHolder <NativeFuncDelegate>(BP_OnItemSelectionChanged_process_event);
                var uf   = Main.GetUFunction("BP_OnItemSelectionChanged");
                var func = UObject.Make <Function>(uf);

                func.SetFlags(func.GetFlags() | EFunctionFlags.FUNC_Native);
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(BP_OnItemSelectionChanged_link.Delegate));
            }
コード例 #23
0
            internal static void Setup()
            {
                GetDefaultPawnClassForController_link = new DelegateHolder <NativeFuncDelegate>(GetDefaultPawnClassForController_process_event);
                var uf   = Main.GetUFunction("GetDefaultPawnClassForController");
                var func = UObject.Make <Function>(uf);

                NativeFunction = Marshal.GetDelegateForFunctionPointer <FNativeFuncPtr>(func.GetNativeFunc());
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(GetDefaultPawnClassForController_link.Delegate));
            }
コード例 #24
0
            internal static void Setup()
            {
                HandleTravelError_link = new DelegateHolder <NativeFuncDelegate>(HandleTravelError_process_event);
                var uf   = Main.GetUFunction("HandleTravelError");
                var func = UObject.Make <Function>(uf);

                func.SetFlags(func.GetFlags() | EFunctionFlags.FUNC_Native);
                func.SetNativeFunc(Marshal.GetFunctionPointerForDelegate(HandleTravelError_link.Delegate));
            }
コード例 #25
0
        public static void ReadPointerLCG <T>(byte[] data, int offset, out T value)
        {
            ReadDelegate <T> del = DelegateHolder <T> .Value;

            if (del == null)
            {
                del = DelegateHolder <T> .CreateDelegate();
            }
            del(data, offset, out value);
        }
コード例 #26
0
ファイル: InputComponent.cs プロジェクト: jcoder58/Plugins
 static Local()
 {
     NativeInput = (InputNative *)Interfaces.Get(Core.Name.Make("Input")).ToPointer();
     Debug.Assert(NativeInput != null);
     NativeInput->Validate();
     AxisEventHandler = new DelegateHolder <AxisEventFunction>(OnAxisEvent);
     NativeInput->AxisEventFunction   = Marshal.GetFunctionPointerForDelegate(AxisEventHandler.Delegate);
     ActionEventHandler               = new DelegateHolder <ActionEventFunction>(OnActionEvent);
     NativeInput->ActionEventFunction = Marshal.GetFunctionPointerForDelegate(ActionEventHandler.Delegate);
 }
コード例 #27
0
    /// <summary>
    /// Add delegate to list
    /// </summary>
    /// <param name="value"></param>
    public void Add(Delegate value)
    {
        var holder = new DelegateHolder(value);

        if (!delegates.TryAdd(value, holder))
        {
            return;
        }
        listLocker.EnterWriteLock();
        delegatesList.AddLast(holder);
        listLocker.ExitWriteLock();
    }
コード例 #28
0
    /// <summary>
    /// Raise an event
    /// </summary>
    /// <param name="args"></param>
    public void Raise(params object[] args)
    {
        DelegateHolder holder = null;

        try
        {
            // get root element
            listLocker.EnterReadLock();
            var cursor = delegatesList.First;
            listLocker.ExitReadLock();
            while (cursor != null)
            {
                // get its value and a next node
                listLocker.EnterReadLock();
                holder = cursor.Value;
                var next = cursor.Next;
                listLocker.ExitReadLock();
                // lock holder and invoke if it is not removed
                Monitor.Enter(holder);
                if (!holder.IsDeleted)
                {
                    holder.Action.DynamicInvoke(args);
                }
                else if (!holder.IsDeletedFromList)
                {
                    listLocker.EnterWriteLock();
                    delegatesList.Remove(cursor);
                    holder.IsDeletedFromList = true;
                    listLocker.ExitWriteLock();
                }
                Monitor.Exit(holder);
                cursor = next;
            }
        }
        catch
        {
            // clean up
            if (listLocker.IsReadLockHeld)
            {
                listLocker.ExitReadLock();
            }
            if (listLocker.IsWriteLockHeld)
            {
                listLocker.ExitWriteLock();
            }
            if (holder != null && Monitor.IsEntered(holder))
            {
                Monitor.Exit(holder);
            }
            throw;
        }
    }
コード例 #29
0
ファイル: Threading.cs プロジェクト: songoku141/net7mma_core
        /// <summary>
        /// Add delegate to list
        /// </summary>
        /// <param name="value"></param>
        public void Add(System.Delegate value)
        {
            DelegateHolder Holder = new DelegateHolder(value);

            if (false == DelegateDictionary.TryAdd(value, Holder))
            {
                return;
            }

            ReadWriteLock.EnterWriteLock();

            DelegateList.AddLast(Holder);

            ReadWriteLock.ExitWriteLock();
        }
コード例 #30
0
ファイル: RenderTargetsPlugin.cs プロジェクト: tiomke/paradox
        public override void Unload()
        {
            base.Unload();

            if (OfflineCompilation)
            {
                return;
            }

            RenderPass.StartPass -= startPassAction;
            startPassAction       = null;

            RenderPass.EndPass -= endPassAction;
            endPassAction       = null;
        }
コード例 #31
0
        public override void Unload()
        {
            base.Unload();

            if (OfflineCompilation)
                return;

            if (EnableSetTargets)
            {
                RenderPass.StartPass -= startPassAction;
                RenderPass.EndPass -= endPassAction;

                startPassAction = null;
                endPassAction = null;
            }
        }
コード例 #32
0
        public override void Load()
        {
 	        base.Load();

            if (OfflineCompilation)
                return;

            if (EnableSetTargets)
            {
                startPassAction = (threadContext) => threadContext.GraphicsDevice.SetStreamTargets(StreamTarget);
                endPassAction = (threadContext) => threadContext.GraphicsDevice.SetStreamTargets(null);

                RenderPass.StartPass += startPassAction;
                RenderPass.EndPass += endPassAction;
            }
        }
コード例 #33
0
        static void CacheMethod(Type handler, Type messageType, Type interfaceGenericType, ICollection <DelegateHolder> methodList)
        {
            var handleMethod = GetMethod(handler, messageType, interfaceGenericType);

            if (handleMethod == null)
            {
                return;
            }

            var delegateHolder = new DelegateHolder
            {
                MessageType    = messageType.TypeHandle,
                MethodDelegate = handleMethod
            };

            methodList.Add(delegateHolder);
        }
コード例 #34
0
ファイル: RenderTargetsPlugin.cs プロジェクト: cg123/xenko
        public override void Load()
        {
            base.Load();

            if (OfflineCompilation)
                return;

            if (!Parameters.ContainsKey(EffectPlugin.DepthStencilStateKey))
                DepthStencilState = GraphicsDevice.DepthStencilStates.Default;

            if (EnableSetTargets || EnableClearTarget || EnableClearDepth)
            {
                // Main pre-pass: clear render target & depth buffer, and bind them
                // TODO: Separate prepass from per-rendercontext init
                startPassAction = (threadContext) =>
                    {
                        if (threadContext.FirstContext)
                        {
                            if (EnableClearDepth && DepthStencil != null && !UseDepthStencilReadOnly)
                                threadContext.GraphicsDevice.Clear(DepthStencil, DepthStencilClearOptions.DepthBuffer, ClearDepth, ClearStencil);
                            if (EnableClearTarget && RenderTarget != null)
                                threadContext.GraphicsDevice.Clear(RenderTarget, ClearColor);
                        }

                        if (EnableSetTargets)
                        {
                            // If the Viewport is undefined, use the render target dimension
                            var viewPort = Viewport;
                            if (viewPort == Viewport.Empty)
                            {
                                var desc = RenderTarget != null ? RenderTarget.Description : threadContext.GraphicsDevice.BackBuffer.Description;
                                viewPort = new Viewport(0, 0, desc.Width, desc.Height);
                                Viewport = viewPort;
                            }

                            var depthStencil = UseDepthStencilReadOnly ? DepthStencilReadOnly : DepthStencil;

                            threadContext.GraphicsDevice.SetViewport(viewPort);
                            threadContext.GraphicsDevice.SetRenderTargets(depthStencil, RenderTarget);
                        }
                    };
                RenderPass.StartPass += startPassAction;
            }

            // Unbind depth stencil buffer and render targets
            if (EnableSetTargets)
            {
                endPassAction = (threadContext) => threadContext.GraphicsDevice.UnsetRenderTargets();
                RenderPass.EndPass += endPassAction;
            }
        }
コード例 #35
0
        static void CacheMethod(Type handler, Type messageType, Type interfaceGenericType, ICollection<DelegateHolder> methodList, bool isTimeoutHandler)
        {
            var handleMethod = GetMethod(handler, messageType, interfaceGenericType);
            if (handleMethod == null)
            {
                return;
            }
            Log.DebugFormat("Associated '{0}' message with '{1}' handler.", messageType, handler);

            var delegateHolder = new DelegateHolder
            {
                MessageType = messageType,
                MethodDelegate = handleMethod,
                IsTimeoutHandler = isTimeoutHandler
            };
            methodList.Add(delegateHolder);
        }