private static void DrawString(Rect rect, string message) { var textStyle = AccessUtils.GetTextStyle(rect, TextAnchor.MiddleRight, FontData.defaultFontData.font, message); var color = GUI.color; GUI.color = Color.white; GUI.Label(rect, message, textStyle); GUI.color = color; }
static void Load(UnityModManager.ModEntry entry) { var harmony = HarmonyInstance.Create(entry.Info.Id); harmony.PatchAll(Assembly.GetExecutingAssembly()); entry.OnToggle += (modEntry, b) => Enabled = b; entry.OnUpdate += Update; Enabled = entry.Enabled; Logger = entry.Logger; AccessUtils.Init(); _actionManager = new ActionManager(); ProxyConnectionHandler.StartConnection(); }
public static void ForEachPlayer(Action <PlayerControls> host, Action <PlayerControls> remote) { var controls = Object.FindObjectsOfType <PlayerControls>(); if (controls != null && controls.Length > 0) { foreach (var control in controls) { if (AccessUtils.IsHost()) { host?.Invoke(control); } else { remote?.Invoke(control); } } } }
public void Update() { if (!Main.Enabled) { return; } if (!AccessUtils.InGame()) { return; } string message; if (MessageQueue.TryDequeue(out message)) { Main.Logger.Log($"Message: {message}"); MessageDisplay.Messages.Enqueue(Message.Create(message)); } string ac; if (ActionQueue.TryDequeue(out ac)) { Main.Logger.Log($"Action: {ac}"); var data = JsonMapper.ToObject(ac); IAction action; if (_actions.TryGetValue(data["type"].ToString(), out action)) { if (action.CanRun(AccessUtils.GameState)) { action.Handle(data); } else { ActionQueue.Enqueue(ac); } } } }