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.GameComp.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, ColonistBarTimeControl.normalBgColor, Multiplayer.WorldComp); } }
static void Postfix(MainButtonWorker __instance, Rect?__state) { if (__state == null) { return; } if (Event.current.type == EventType.Repaint) { TimeControl.TimeControlButton(__state.Value, ColonistBarTimeControl.normalBgColor, Multiplayer.WorldComp); } }
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 (curGroup == entry.group) { continue; } ITickable entryTickable = entry.map?.AsyncTime(); if (entryTickable == null) { entryTickable = Multiplayer.WorldComp; } Rect groupBar = bar.drawer.GroupFrameRect(entry.group); float drawXPos = groupBar.x; Color bgColor = (entryTickable.ActualRateMultiplier(TimeSpeed.Normal) == 0f) ? pauseBgColor : normalBgColor; if (Multiplayer.GameComp.asyncTime) { Rect button = new Rect(drawXPos, groupBar.yMax, btnWidth, btnHeight); if (entry.map != null) { TimeControl.TimeControlButton(button, bgColor, entryTickable); drawXPos += TimeControls.TimeButSize.x; } else if (entryTickable.ActualRateMultiplier(TimeSpeed.Normal) == 0f) { TimeControl.TimeIndicateBlockingPause(button, bgColor); drawXPos += TimeControls.TimeButSize.x; } } else if (entryTickable.TickRateMultiplier(TimeSpeed.Normal) == 0f) { Rect button = new Rect(drawXPos, groupBar.yMax, btnWidth, btnHeight); TimeControl.TimeIndicateBlockingPause(button, bgColor); drawXPos += TimeControls.TimeButSize.x; } List <FloatMenuOption> options = GetBlockingWindowOptions(entry, entryTickable); if (!options.NullOrEmpty()) { DrawWindowShortcuts(new Rect(drawXPos, groupBar.yMax, 70, btnHeight), bgColor, options); } curGroup = entry.group; } }