Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Syrchalis committed Oct 25, 2021
1 parent 6e7910c commit fb429ac
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
Binary file modified 1.3/Assemblies/ProcessorFramework.dll
Binary file not shown.
5 changes: 4 additions & 1 deletion 1.3/Defs/ThingDefs_Buildings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<comps>
<li Class="ProcessorFramework.CompProperties_Processor">
<capacity>25</capacity>
<independentProcesses>true</independentProcesses>
<independentProcesses>false</independentProcesses>
<parallelProcesses>false</parallelProcesses>
<dropIngredients>false</dropIngredients>
<showProductIcon>true</showProductIcon>
Expand Down Expand Up @@ -96,6 +96,9 @@
<color>(255, 255, 255)</color> <!-- 0-255 or 0.0-1.0 -->
<customLabel></customLabel>
<destroyChance>0.0</destroyChance>
<bonusOutputs><!--
<thingDef>(1.0, 1.0)</thingDef> -->
</bonusOutputs>
</ProcessorFramework.ProcessDef>

<!--<ProcessorFramework.ProcessDef>
Expand Down
Binary file modified About/preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Languages/English/Keyed/PF_Keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
<!-- ITab Process Selection -->
<PF_ITab_ItemSelection>Processes</PF_ITab_ItemSelection>
<PF_ApplySettings>Apply settings</PF_ApplySettings>
<PF_DestroyChanceTooltip>Chance processor will be destroyed when this product is retrieved</PF_DestroyChanceTooltip>
<PF_EfficiencyTooltip>Amount of ingredient needed for one product</PF_EfficiencyTooltip>

<!-- ITab Process Contents -->
<PF_TabProductFilter>Product</PF_TabProductFilter>
Expand Down
10 changes: 7 additions & 3 deletions Source/ProcessorFramework/CompProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ public void AddIngredient(Thing ingredient)
{
int num = Mathf.Min(ingredient.stackCount, Props.capacity - TotalIngredientCount);
ProcessDef processDef = EnabledProcesses.First(x => x.ingredientFilter.Allows(ingredient));
if (num < ingredient.stackCount)
{
ingredient.SplitOff(ingredient.stackCount - num);
}
bool emptyBefore = Empty;
if (num > 0 && processDef != null)
{
Expand Down Expand Up @@ -468,7 +472,7 @@ public Thing TakeOutProduct(ActiveProcess activeProcess)
{
if (Rand.Chance(bonusOutput.chance))
{
int amount = GenMath.RoundRandom((activeProcess.ingredientCount * activeProcess.processDef.capacityFactor / Props.capacity) * bonusOutput.amount);
int amount = GenMath.RoundRandom(activeProcess.ingredientCount * activeProcess.processDef.capacityFactor / Props.capacity * bonusOutput.amount);
if (amount > 0)
{
if (bonusOutput.thingDef.race != null)
Expand Down Expand Up @@ -500,7 +504,7 @@ public Thing TakeOutProduct(ActiveProcess activeProcess)
activeProcesses.Remove(activeProcess);

//Destroy chance
if (Rand.Chance(activeProcess.processDef.destroyChance))
if (Rand.Chance(activeProcess.processDef.destroyChance * activeProcess.ingredientCount * activeProcess.processDef.capacityFactor / Props.capacity))
{
if (PF_Settings.replaceDestroyedProcessors)
{
Expand Down Expand Up @@ -592,7 +596,7 @@ public override string CompInspectStringExtra()
else if (activeProcesses[0].SpeedFactor < 0.75f)
str.AppendTagged("PF_RunningSlow".Translate(activeProcesses[0].SpeedFactor.ToStringPercent(), activeProcesses[0].ActiveProcessPercent));
else
str.AppendTagged("PF_RunningInfo".Translate(activeProcesses[0].ActiveProcessPercent));
str.AppendTagged("PF_RunningInfo".Translate(activeProcesses[0].ActiveProcessPercent.ToStringPercent()));
}

str.AppendLine();
Expand Down
29 changes: 28 additions & 1 deletion Source/ProcessorFramework/ITab_ProcessSelection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ public void DoItemsList(ref Rect listRect, IEnumerable<CompProcessor> processors
}

Widgets.Label(headerRect, processDef.thingDef.LabelCap);
if (processDef.destroyChance != 0)
{
Rect destroyChanceRect = new Rect(headerRect.width - 80, headerRect.y + 2, 32, 20f);
Text.Anchor = TextAnchor.UpperRight;
if (Mouse.IsOver(destroyChanceRect))
{
GUI.color = ITab_Pawn_Gear.HighlightColor;
GUI.DrawTexture(destroyChanceRect, TexUI.HighlightTex);
}
TooltipHandler.TipRegion(destroyChanceRect, () => "PF_DestroyChanceTooltip".Translate(), 23492389);
Text.Font = GameFont.Tiny;
GUI.color = Color.red;
Widgets.Label(destroyChanceRect, processDef.destroyChance.ToStringByStyle(ToStringStyle.PercentZero));
GUI.color = Color.white;
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.UpperLeft;

}
Widgets.Checkbox(new Vector2(checkboxRect.xMin, checkboxRect.yMin), ref productAllowed, 20);
localProductFilter.SetAllow(processDef.thingDef, productAllowed);

Expand All @@ -141,11 +159,20 @@ public void DoItemsList(ref Rect listRect, IEnumerable<CompProcessor> processors
Widgets.Label(headerRect, ingredient.LabelCap);
if (processDef.efficiency != 1)
{
Rect efficiencyRect = new Rect(headerRect.width - 70, headerRect.y + 2, 32, 20f);
Text.Anchor = TextAnchor.UpperRight;
if (Mouse.IsOver(efficiencyRect))
{
GUI.color = ITab_Pawn_Gear.HighlightColor;
GUI.DrawTexture(efficiencyRect, TexUI.HighlightTex);
}
TooltipHandler.TipRegion(efficiencyRect, () => "PF_EfficiencyTooltip".Translate(), 23492389);
Text.Font = GameFont.Tiny;
GUI.color = Color.gray;
Widgets.Label(new Rect(headerRect.width - 58f, headerRect.y + 2, 30f, 20f), "x" + (1f / processDef.efficiency).ToStringByStyle(ToStringStyle.FloatMaxTwo));
Widgets.Label(efficiencyRect, "x" + (1f / processDef.efficiency).ToStringByStyle(ToStringStyle.FloatMaxTwo));
Text.Font = GameFont.Small;
GUI.color = Color.white;
Text.Anchor = TextAnchor.UpperLeft;
}
Widgets.Checkbox(new Vector2(checkboxRect.xMin, checkboxRect.yMin), ref ingredientAllowed, 20);
localIngredientFilter.SetAllow(ingredient, ingredientAllowed);
Expand Down
2 changes: 1 addition & 1 deletion Source/ProcessorFramework/WorkGiver_FillProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
if (!comp.EnabledProcesses.EnumerableNullOrEmpty())
{
float minFactor = comp.EnabledProcesses.MinBy(x => x.capacityFactor).capacityFactor;
if (comp.unreservedSpaceLeft < minFactor)
if (Mathf.Min(comp.unreservedSpaceLeft, comp.SpaceLeft) < minFactor)
{
return false;
}
Expand Down

0 comments on commit fb429ac

Please sign in to comment.