static void Prefix(MainButtonWorker __instance, Rect rect, ref Rect?__state)
        {
            if (Multiplayer.Client == null)
            {
                return;
            }
            if (__instance.def != MainButtonDefOf.World)
            {
                return;
            }
            if (__instance.Disabled)
            {
                return;
            }
            if (Find.CurrentMap == null)
            {
                return;
            }
            if (!Multiplayer.WorldComp.asyncTime)
            {
                return;
            }

            Rect button = new Rect(rect.xMax - TimeControls.TimeButSize.x - 5f, rect.y + (rect.height - TimeControls.TimeButSize.y) / 2f, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y);

            __state = button;

            if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseUp)
            {
                TimeControl.TimeControlButton(__state.Value, Multiplayer.WorldComp, 0.5f);
            }
        }
        static void Postfix(MainButtonWorker __instance, Rect?__state)
        {
            if (__state == null)
            {
                return;
            }

            if (Event.current.type == EventType.Repaint)
            {
                TimeControl.TimeControlButton(__state.Value, Multiplayer.WorldComp, 0.5f);
            }
        }
        static void DrawButtons()
        {
            if (Multiplayer.Client == null)
            {
                return;
            }

            ColonistBar bar = Find.ColonistBar;

            if (bar.Entries.Count == 0)
            {
                return;
            }

            int curGroup = -1;

            foreach (var entry in bar.Entries)
            {
                if (entry.map == null || curGroup == entry.group)
                {
                    continue;
                }

                float alpha = 1.0f;
                if (entry.map != Find.CurrentMap || WorldRendererUtility.WorldRenderedNow)
                {
                    alpha = 0.75f;
                }

                Rect rect      = bar.drawer.GroupFrameRect(entry.group);
                Rect button    = new Rect(rect.x - TimeControls.TimeButSize.x / 2f, rect.yMax - TimeControls.TimeButSize.y / 2f, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y);
                var  asyncTime = entry.map.AsyncTime();

                if (Multiplayer.WorldComp.asyncTime)
                {
                    TimeControl.TimeControlButton(button, asyncTime, alpha);
                }
                else if (asyncTime.TickRateMultiplier(TimeSpeed.Normal) == 0f) // Blocking pause
                {
                    Widgets.DrawRectFast(button, new Color(1f, 0.5f, 0.5f, 0.4f * alpha));
                    Widgets.ButtonImage(button, TexButton.SpeedButtonTextures[0]);
                }

                curGroup = entry.group;
            }
        }
Example #4
0
        static void DrawButtons()
        {
            if (Multiplayer.Client == null)
            {
                return;
            }

            ColonistBar bar = Find.ColonistBar;

            if (bar.Entries.Count == 0 || bar.Entries.Last().group == 0)
            {
                return;
            }

            int curGroup = -1;

            foreach (var entry in bar.Entries)
            {
                if (entry.map == null || curGroup == entry.group)
                {
                    continue;
                }

                float alpha = 1.0f;
                if (entry.map != Find.CurrentMap || WorldRendererUtility.WorldRenderedNow)
                {
                    alpha = 0.75f;
                }

                Rect rect = bar.drawer.GroupFrameRect(entry.group);

                Rect button = new Rect(rect.x - TimeControls.TimeButSize.x / 2f, rect.yMax - TimeControls.TimeButSize.y / 2f, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y);
                TimeControl.TimeControlButton(button, entry.map.AsyncTime(), alpha);

                curGroup = entry.group;
            }
        }