diff --git a/1.4/Assemblies/AchtungMod.dll b/1.4/Assemblies/AchtungMod.dll index 82d517f..a962ca3 100644 Binary files a/1.4/Assemblies/AchtungMod.dll and b/1.4/Assemblies/AchtungMod.dll differ diff --git a/Source/Controller.cs b/Source/Controller.cs index e85cb07..e3454df 100644 --- a/Source/Controller.cs +++ b/Source/Controller.cs @@ -55,14 +55,14 @@ public static void InstallDefs() .DoIf(def => DefDatabase.GetNamedSilentFail(def.defName) == null, DefDatabase.Add); } - bool ShowMenu(MultiActions actions, bool forceMenu, Map map, IntVec3 cell) + bool ShowMenu(MultiActions actions, bool forceMenu, Map map, IntVec3 cell, Action gotoAction) { if (actions == null) return true; var menuAdded = false; + var optionTaken = false; if (actions.Count(false) > 0) { - var optionTaken = false; if (cell.InBounds(map) && forceMenu == false) { var autoTakableOptions = actions.GetAutoTakeableActions(); @@ -82,6 +82,12 @@ bool ShowMenu(MultiActions actions, bool forceMenu, Map map, IntVec3 cell) } if (menuAdded) EndDragging(); + if (optionTaken == false && menuAdded == false && actions.EveryoneHasGoto && gotoAction != null) + { + actions.allPawns.Do(pawn => Tools.SetDraftStatus(pawn, true, false)); + gotoAction(); + return true; + } if (menuAdded == false && Achtung.Settings.positioningEnabled == false) return true; Event.current.Use(); @@ -99,10 +105,7 @@ public bool MouseDown(Vector3 pos, int button, bool longPress) colonists = Tools.GetSelectedColonists(); if (colonists.Count == 0) - { - suppressMenu = true; return true; - } if (isDragging && button == (int)Button.left && groupMovement == false) { @@ -112,10 +115,7 @@ public bool MouseDown(Vector3 pos, int button, bool longPress) } if (button != (int)Button.right) - { - suppressMenu = true; return true; - } var actions = doForceMenu ? new MultiActions(colonists, UI.MouseMapPosition()) : null; var achtungPressed = Tools.IsModKeyPressed(Achtung.Settings.achtungKey); @@ -149,7 +149,7 @@ public bool MouseDown(Vector3 pos, int button, bool longPress) { if (actions == null) return true; - return ShowMenu(actions, forceMenu, map, cell); + return ShowMenu(actions, forceMenu, map, cell, null); } if (achtungPressed) @@ -162,7 +162,7 @@ public bool MouseDown(Vector3 pos, int button, bool longPress) return true; } - return ShowMenu(actions, forceMenu, map, cell); + return ShowMenu(actions, forceMenu, map, cell, () => StartDragging(pos, achtungPressed)); } private void StartDragging(Vector3 pos, bool asGroup) @@ -199,7 +199,6 @@ private void EndDragging() Event.current.Use(); } isDragging = false; - suppressMenu = false; } public void MouseDrag(Vector3 pos) @@ -420,7 +419,9 @@ public bool HandleEvents() switch (Event.current.rawType) { case EventType.MouseDown: - longPressThreshold = Environment.TickCount + Achtung.Settings.menuDelay; + if (Event.current.button == (int)Button.right) + suppressMenu = false; + longPressThreshold = Event.current.button == (int)Button.right ? Environment.TickCount + Achtung.Settings.menuDelay : -1; runOriginal = MouseDown(pos, Event.current.button, false); MouseDrag(pos); break; diff --git a/Source/Main.cs b/Source/Main.cs index cb6117c..9b11c8c 100644 --- a/Source/Main.cs +++ b/Source/Main.cs @@ -88,8 +88,9 @@ static class Game_UpdatePlay_Patch // static readonly TimeSlice timeSlicer = new(3f, 0, 1000000, () => it.MoveNext()); - static float maxDeltaTime = 0.04f; const int iterations = 5000; + const int minTfpsLimit = 2; + static float maxDeltaTime = 0.04f; static int prevFrames = 0, tfps = 6; static int prevTenthSecond = -1; @@ -162,11 +163,11 @@ public static void Postfix() tfps = prevFrames; prevFrames = 0; } - if (tfps >= 5) + if (tfps >= minTfpsLimit + 1) maxDeltaTime += 0.001f; - else if (tfps == 4) + else if (tfps == minTfpsLimit) maxDeltaTime -= 0.001f; - else if (tfps < 4) + else if (tfps < minTfpsLimit) maxDeltaTime = 0.04f; var n = (maxDeltaTime - Time.deltaTime) * iterations; diff --git a/Source/MultiActions.cs b/Source/MultiActions.cs index 0ffd923..0aeff32 100644 --- a/Source/MultiActions.cs +++ b/Source/MultiActions.cs @@ -10,20 +10,26 @@ namespace AchtungMod public class MultiActions { public Vector3 clickPos; + public readonly List allPawns; readonly List allActions; - int totalColonistsInvolved = 0; + readonly bool everyoneHasGoto = false; + readonly int totalColonistsInvolved = 0; + int gotoActionCount = 0; public MultiActions(IEnumerable colonists, Vector3 clickPos) { this.clickPos = clickPos; + allPawns = colonists.Select(colonist => colonist.pawn).ToList(); allActions = new List(); - colonists.Do(colonist => - { - AddColonist(colonist); - totalColonistsInvolved++; - }); + totalColonistsInvolved = colonists.Count(); + colonists.Do(AddColonist); + if (gotoActionCount == totalColonistsInvolved) + if (colonists.Any(colonist => colonist.pawn.Drafted)) + everyoneHasGoto = true; } + public bool EveryoneHasGoto => everyoneHasGoto; + public void AddColonist(Colonist colonist) { var existingLabels = new HashSet(); @@ -45,8 +51,11 @@ public void AddColonist(Colonist colonist) public void AddMultiAction(Colonist colonist, bool draftMode, FloatMenuOption option) { + var action = new MultiAction(colonist, draftMode, option); if (Tools.IsGoHereOption(option) == false) - allActions.Add(new MultiAction(colonist, draftMode, option)); + allActions.Add(action); + else + gotoActionCount++; } public int Count(bool onlyActive)