public static void Prepopulate() { lock (Locker) { if (_prepopulated == null) { _prepopulated = new BaseHook(nameof(ScreenSizeHook), new Dictionary <string, object>() { { "width", Screen.safeArea.width }, { "height", Screen.safeArea.height } }); } else { if (_prepopulated.Value["width"].Equals(Screen.safeArea.width) && _prepopulated.Value["height"].Equals(Screen.safeArea.height)) { return; } _prepopulated.Value["width"] = Screen.safeArea.width; _prepopulated.Value["height"] = Screen.safeArea.height; HookComponentRegistration.InvalidateHooks(hook => hook.Name == nameof(ScreenSizeHook)); } } }
public static void Prepopulate() { lock (Locker) { if (_prepopulated == null) { _prepopulated = new BaseHook(nameof(MousePositionHook), new Dictionary <string, object>() { { "x", Input.mousePosition.x }, { "y", Input.mousePosition.y } }); } else { if (_prepopulated.Value["x"].Equals(Input.mousePosition.x) && _prepopulated.Value["y"].Equals(Input.mousePosition.y)) { return; } _prepopulated.Value["x"] = Input.mousePosition.x; _prepopulated.Value["y"] = Input.mousePosition.y; HookComponentRegistration.InvalidateHooks(hook => hook.Name == nameof(MousePositionHook)); } } }
void OnMessage(Message msg) { MessageChat msgChat = JsonReader.Deserialize <MessageChat>(msg.rawString); string strName = string.Format("<color=#ff00ffff>{0}: </color>", msgChat.nickName); //if (Game.Instance.player.UID != msgChat.uid) { bool bShow = Game.Instance.level.bForbidChat; if (Game.Instance.level.uIDHookMap.ContainsKey(msgChat.uid) && !bShow) { BaseHook bh = Game.Instance.level.uIDHookMap[msgChat.uid]; if (bh != null) { if (bh.hookPos == HookPos.right) { UIManager.Instance.ShowWindow <ChatPaopao>("ChatPaopao", ArgList.Create(msgChat.message, new Vector3(200f, 300f, 0f), 180f), false); } else { UIManager.Instance.ShowWindow <ChatPaopao>("ChatPaopao", ArgList.Create(msgChat.message, new Vector3(-200f, 300f, 0f), 0f), false); } } } } if (Game.Instance.player.UID == msgChat.uid) { string strMessage = "<color=#00ff00ff>ÎÒ: </color>" + msgChat.message; AddMessage(strMessage); } else { AddMessage(strName + msgChat.message); } }
/// <summary> /// PrePatches this hook into the target weaver /// </summary> /// <param name="weaver"></param> /// <param name="oxidemodule"></param> /// <param name="original"></param> /// <param name="console"></param> public bool PreparePatch(MethodDefinition original, ILWeaver weaver, AssemblyDefinition oxidemodule, bool console) { if (BaseHook != null) { return(BaseHook.PreparePatch(original, weaver, oxidemodule, console) && BaseHook.ApplyPatch(original, weaver, oxidemodule, console)); } return(true); }
/// <summary> /// PrePatches this hook into the target weaver /// </summary> /// <param name="weaver"></param> /// <param name="oxidemodule"></param> /// <param name="original"></param> /// <param name="patcher"></param> public bool PreparePatch(MethodDefinition original, ILWeaver weaver, AssemblyDefinition oxidemodule, Patching.Patcher patcher = null) { if (BaseHook != null) { return(BaseHook.PreparePatch(original, weaver, oxidemodule, patcher) && BaseHook.ApplyPatch(original, weaver, oxidemodule, patcher)); } return(true); }
public static IDictionary <string, object> Use(object initialValue) { var hook = new BaseHook(nameof(StateHook), new Dictionary <string, object> { { "value", initialValue } }); var currentElement = HookComponentRegistration.CurrentContainer; hook.Value.Add("change", (Action <object>)((value) => { hook.Value["value"] = value; currentElement.Invalidated = true; RenderQueue.Instance.Enqueue(new RenderQueueItem { elementToUpdate = currentElement }); })); return(HookComponentRegistration.GetOrRegisterHook(hook).Value); }
public static IDictionary <string, object> Use(string systemName) { lock (Locker) { var system = ConnectedSystemRegistry.Instance.Get(systemName); if (system == null) { return(null); } if (_usedSystems.ContainsKey(systemName)) { return(HookComponentRegistration.GetOrRegisterHook(_usedSystems[systemName]).Value); } var hook = new BaseHook($"{nameof(ScreenSizeHook)}_{systemName}", new Dictionary <string, object>(system.Props)); _usedSystems.Add(systemName, hook); return(HookComponentRegistration.GetOrRegisterHook(_usedSystems[systemName]).Value); } }