Skip to content

Commit

Permalink
v3.3.3 improves forced work handling even more
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Sep 5, 2021
1 parent b4c359c commit 7d4d040
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 9 deletions.
Binary file modified 1.3/Assemblies/AchtungMod.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>net.pardeike.rimworld.mod.achtung</identifier>
<version>3.3.2.0</version>
<version>3.3.3.0</version>
<targetVersions>
<li>1.0.0</li>
<li>1.1.0</li>
Expand Down
4 changes: 4 additions & 0 deletions Languages/Dutch/Keyed/Text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
<WorkMarkersOptionStatic>Stilstaand</WorkMarkersOptionStatic>
<WorkMarkersOptionOff>Uit</WorkMarkersOptionOff>

<MaxForcedItemsTitle>Maximum gedwongen werk</MaxForcedItemsTitle>
<MaxForcedItemsExplained>Beperkt het aantal gedwongen werk voor langzamere computers</MaxForcedItemsExplained>
<MaxForcedItemsUnlimited>Onbeperkt</MaxForcedItemsUnlimited>

<JobInterruptedLabel>Geannuleerd: {0}</JobInterruptedLabel>
<JobInterruptedBreakdown>{0}: {1}</JobInterruptedBreakdown>
<JobInterruptedBadHealth>{0} verkeert in slechte staat</JobInterruptedBadHealth>
Expand Down
4 changes: 4 additions & 0 deletions Languages/English/Keyed/Text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ The formation can be rotated using Q and E</AchtungModifierExplained>
<WorkMarkersOptionStatic>Static</WorkMarkersOptionStatic>
<WorkMarkersOptionOff>Off</WorkMarkersOptionOff>

<MaxForcedItemsTitle>Maximum forced items</MaxForcedItemsTitle>
<MaxForcedItemsExplained>Restricts the number of forced items for slower computers</MaxForcedItemsExplained>
<MaxForcedItemsUnlimited>Unlimited</MaxForcedItemsUnlimited>

<JobInterruptedLabel>Cancelled: {0}</JobInterruptedLabel>
<JobInterruptedBreakdown>{0}: {1}</JobInterruptedBreakdown>
<JobInterruptedBadHealth>{0} is in bad shape</JobInterruptedBadHealth>
Expand Down
4 changes: 4 additions & 0 deletions Languages/German/Keyed/Text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ Die Formation kann während der Bewegung mit Q und E rotiert werden</AchtungModi
<WorkMarkersOptionStatic>Statisch</WorkMarkersOptionStatic>
<WorkMarkersOptionOff>Aus</WorkMarkersOptionOff>

<MaxForcedItemsTitle>Maximale Anzahl erzwungener Sachen</MaxForcedItemsTitle>
<MaxForcedItemsExplained>Begrenzt die Menge erzwungener Arbeit für langsame Computer</MaxForcedItemsExplained>
<MaxForcedItemsUnlimited>Unbegrenzt</MaxForcedItemsUnlimited>

<JobInterruptedLabel>Abgebrochen: {0}</JobInterruptedLabel>
<JobInterruptedBreakdown>{0}: {1}</JobInterruptedBreakdown>
<JobInterruptedBadHealth>{0} ist in schlechter gesundheitlicher Verfassung</JobInterruptedBadHealth>
Expand Down
4 changes: 4 additions & 0 deletions Languages/Spanish/Keyed/Text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ La formación puede rotar usando las teclas Q y E.</AchtungModifierExplained>
<WorkMarkersOptionStatic>Estático</WorkMarkersOptionStatic>
<WorkMarkersOptionOff>Apagado</WorkMarkersOptionOff>

<MaxForcedItemsTitle>Elementos forzados máximos</MaxForcedItemsTitle>
<MaxForcedItemsExplained>Restringe la cantidad de elementos forzados para computadoras más lentas.</MaxForcedItemsExplained>
<MaxForcedItemsUnlimited>Ilimitado</MaxForcedItemsUnlimited>

<JobInterruptedLabel>Cancelado: {0}</JobInterruptedLabel>
<JobInterruptedBreakdown>{0}: {1}</JobInterruptedBreakdown>
<JobInterruptedBadHealth>{0} se encuentra mal</JobInterruptedBadHealth>
Expand Down
4 changes: 4 additions & 0 deletions Languages/SpanishLatin/Keyed/Text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ La formación puede rotar usando las teclas Q y E.</AchtungModifierExplained>
<WorkMarkersOptionStatic>Estático</WorkMarkersOptionStatic>
<WorkMarkersOptionOff>Apagado</WorkMarkersOptionOff>

<MaxForcedItemsTitle>Elementos forzados máximos</MaxForcedItemsTitle>
<MaxForcedItemsExplained>Restringe la cantidad de elementos forzados para computadoras más lentas.</MaxForcedItemsExplained>
<MaxForcedItemsUnlimited>Ilimitado</MaxForcedItemsUnlimited>

<JobInterruptedLabel>Cancelado: {0}</JobInterruptedLabel>
<JobInterruptedBreakdown>{0}: {1}</JobInterruptedBreakdown>
<JobInterruptedBadHealth>{0} se encuentra mal</JobInterruptedBadHealth>
Expand Down
4 changes: 4 additions & 0 deletions Languages/Swedish/Keyed/Text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ Höll i för att flytta kolonister i deras formation. Formationen kan roteras me
<WorkMarkersOptionStatic>Statiskt</WorkMarkersOptionStatic>
<WorkMarkersOptionOff>Av</WorkMarkersOptionOff>

<MaxForcedItemsTitle>Maximalt antal påtvingade saker</MaxForcedItemsTitle>
<MaxForcedItemsExplained>Begränsar antalet påtvingade saker för långsammare datorer</MaxForcedItemsExplained>
<MaxForcedItemsUnlimited>Obegränsat</MaxForcedItemsUnlimited>

<JobInterruptedLabel>Avbruten: {0}</JobInterruptedLabel>
<JobInterruptedBreakdown>{0}: {1}</JobInterruptedBreakdown>
<JobInterruptedBadHealth>{0} har låg hälsa</JobInterruptedBadHealth>
Expand Down
2 changes: 1 addition & 1 deletion Source/Achtung.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<OutputPath>..\1.3\Assemblies\</OutputPath>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Version>3.3.2.0</Version>
<Version>3.3.3.0</Version>
<Copyright>© July, 2016</Copyright>
</PropertyGroup>

Expand Down
19 changes: 12 additions & 7 deletions Source/ForcedJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,16 @@ public IEnumerator ExpandThingTargets()
{
while (targets.Count > 0)
{
var thingGrid = pawn.Map.thingGrid;
yield return null;
if (Achtung.Settings.maxForcedItems < AchtungSettings.UnlimitedForcedItems && targets.Count > Achtung.Settings.maxForcedItems)
continue;

var visitedNeighbours = new HashSet<Thing>();
var neighbours = targets.Select(target => target.item.Thing).ToList();
while (neighbours.Count > 0)
while (neighbours.Count > 0 && (Achtung.Settings.maxForcedItems >= AchtungSettings.UnlimitedForcedItems || neighbours.Count < Achtung.Settings.maxForcedItems))
{
var newNeighbours = new List<Thing>();
var thingGrid = pawn.Map.thingGrid;
for (var i = 0; i < neighbours.Count; i++)
{
var neighbour = neighbours[i];
Expand Down Expand Up @@ -410,9 +413,13 @@ public IEnumerator ExpandCellTargets()
{
while (targets.Count > 0)
{
yield return null;
if (Achtung.Settings.maxForcedItems < AchtungSettings.UnlimitedForcedItems && targets.Count > Achtung.Settings.maxForcedItems)
continue;

var visitedNeighbours = new HashSet<IntVec3>();
var neighbours = targets.Select(target => target.item.Cell).ToList();
while (neighbours.Count > 0)
while (neighbours.Count > 0 && (Achtung.Settings.maxForcedItems >= AchtungSettings.UnlimitedForcedItems || neighbours.Count < Achtung.Settings.maxForcedItems))
{
var newNeighbours = new List<IntVec3>();
for (var i = 0; i < neighbours.Count; i++)
Expand Down Expand Up @@ -447,8 +454,7 @@ public IEnumerator ContractThingTargets()
{
while (targets.Count > 0)
{
var allThings = targets.Select(target => target.item.Thing).ToHashSet();
var enumerator = allThings.GetEnumerator();
var enumerator = targets.Select(target => target.item.Thing).GetEnumerator();
yield return null;
var counter = 0;
while (enumerator.MoveNext())
Expand All @@ -468,8 +474,7 @@ public IEnumerator ContractCellTargets()
{
while (targets.Count > 0)
{
var allCells = targets.Select(target => target.item.Cell).ToHashSet();
var enumerator = allCells.GetEnumerator();
var enumerator = targets.Select(target => target.item.Cell).GetEnumerator();
yield return null;
var counter = 0;
while (enumerator.MoveNext())
Expand Down
6 changes: 6 additions & 0 deletions Source/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public class AchtungSettings : ModSettings
public bool ignoreAssignments = false;
public WorkMarkers workMarkers = WorkMarkers.Animated;
public bool buildingSmartDefault = false;
public int maxForcedItems = 64;

public static readonly int UnlimitedForcedItems = 2000;

public override void ExposeData()
{
Expand All @@ -72,6 +75,7 @@ public override void ExposeData()
Scribe_Values.Look(ref ignoreAssignments, "ignoreAssignments", false, true);
Scribe_Values.Look(ref workMarkers, "workMarkers", WorkMarkers.Animated, true);
Scribe_Values.Look(ref buildingSmartDefault, "buildingSmartDefault", false, true);
Scribe_Values.Look(ref maxForcedItems, "maxForcedItems", 64, true);
}

public static void DoWindowContents(Rect canvas)
Expand Down Expand Up @@ -107,6 +111,8 @@ public static void DoWindowContents(Rect canvas)
list.CheckboxEnhanced("BuildingSmartDefault", ref Achtung.Settings.buildingSmartDefault);
list.Gap(10);
list.ValueLabeled("WorkMarkers", ref Achtung.Settings.workMarkers);
list.Gap(10);
list.SliderLabeled("MaxForcedItems", ref Achtung.Settings.maxForcedItems, 0, UnlimitedForcedItems, (n) => n >= UnlimitedForcedItems ? "MaxForcedItemsUnlimited".Translate().ToString() : $"{n}");

list.End();

Expand Down
43 changes: 43 additions & 0 deletions Source/Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,49 @@ public static void CheckboxEnhanced(this Listing_Standard listing, string name,
listing.Gap(6);
}

public static void SliderLabeled(this Listing_Standard listing, string name, ref int value, int min, int max, Func<int, string> converter, string tooltip = null)
{
var startHeight = listing.CurHeight;

var rect = listing.GetRect(Text.LineHeight + listing.verticalSpacing);

Text.Font = GameFont.Small;
GUI.color = Color.white;

var savedAnchor = Text.Anchor;

Text.Anchor = TextAnchor.MiddleLeft;
Widgets.Label(rect, (name + "Title").Translate());

Text.Anchor = TextAnchor.MiddleRight;
Widgets.Label(rect, converter(value));

Text.Anchor = savedAnchor;

var key = name + "Explained";
if (key.CanTranslate())
{
Text.Font = GameFont.Tiny;
listing.ColumnWidth -= 34;
GUI.color = Color.gray;
_ = listing.Label(key.Translate());
listing.ColumnWidth += 34;
Text.Font = GameFont.Small;
}

value = (int)listing.Slider(value, min, max);
rect = listing.GetRect(0);
rect.height = listing.CurHeight - startHeight;
rect.y -= rect.height;
if (Mouse.IsOver(rect))
{
Widgets.DrawHighlight(rect);
if (!tooltip.NullOrEmpty()) TooltipHandler.TipRegion(rect, tooltip);
}

listing.Gap(6);
}

public static void ValueLabeled<T>(this Listing_Standard listing, string name, ref T value, string tooltip = null)
{
var startHeight = listing.CurHeight;
Expand Down

0 comments on commit 7d4d040

Please sign in to comment.