예제 #1
0
        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;
        }
예제 #2
0
        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();
        }
예제 #3
0
        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);
                    }
                }
            }
        }
예제 #4
0
        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);
                    }
                }
            }
        }