Skip to content

Commit

Permalink
make disease minimum threshold configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
FluffierThanThou committed Nov 8, 2018
1 parent a5ec007 commit 1d23def
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 13 deletions.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Vokania: Korean translation
53N4: Spanish translation

<size=24>Version</size>
This is version 2.2.129, for RimWorld 1.0.2059.
This is version 2.2.132, for RimWorld 1.0.2059.

</description>
</ModMetaData>
Binary file modified Assemblies/Pharmacist.dll
Binary file not shown.
4 changes: 3 additions & 1 deletion Languages/English/Keyed/Keyed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
<Fluffy.Pharmacist.Severity.Operation.Tip>All operations, transplants and limb replacements.</Fluffy.Pharmacist.Severity.Operation.Tip>

<Fluffy.Pharmacist.DiseaseMargin>Disease immunity margin: {0}</Fluffy.Pharmacist.DiseaseMargin>
<Fluffy.Pharmacist.DiseaseMargin.Tip>Security margin used when treating diseases. \n\nIf immunity is lower than disease progress plus this margin, the disease is treated as a life-threathening injury.\n\nFor example, if a disease has progressed 75%, immunity is at 80%, and the margin is 10%, the disease will be classed as life-threatening. If the threshold was 5%, the disease would be classed as a major injury instead.</Fluffy.Pharmacist.DiseaseMargin.Tip>
<Fluffy.Pharmacist.DiseaseMargin.Tip>Security margin used when treating diseases. \n\nIf immunity is lower than disease progress plus this margin (and severity is higher than the minimum threshold), the disease is treated as a life-threathening injury.\n\nFor example, if a disease has progressed 75%, immunity is at 80%, and the margin is 10%, the disease will be classed as life-threatening. If the threshold was 5%, the disease would be classed as a major injury instead.</Fluffy.Pharmacist.DiseaseMargin.Tip>
<Fluffy.Pharmacist.DiseaseThreshold>Disease minimum severity theshold: {0}</Fluffy.Pharmacist.DiseaseThreshold>
<Fluffy.Pharmacist.DiseaseThreshold.Tip>Minimum severity before a disease can be classed as potentially lethal. \n\nIf severity is higher than this threshold (and immunity is lower than the severity plus security margin), the disease is treated as a life-threathening injury.</Fluffy.Pharmacist.DiseaseThreshold.Tip>
<Fluffy.Pharmacist.MinorWoundsThreshold>Minor cuts threshold: {0}</Fluffy.Pharmacist.MinorWoundsThreshold>
<Fluffy.Pharmacist.MinorWoundsThreshold.Tip>If the number of minor cuts is greater than this threshold, they are treated as a major injury regardless of bleed rate. \n\nUseful to prevent 'death by a thousand cuts', where a large number of small cuts can cause multiple infections - and ultimately, death.</Fluffy.Pharmacist.MinorWoundsThreshold.Tip>

Expand Down
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ Show your appreciation by buying me a coffee (or contribute towards a nice singl
[![Buy Me a Coffee](http://i.imgur.com/EjWiUwx.gif)](https://ko-fi.com/fluffymods)

# Version
This is version 2.2.129, for RimWorld 1.0.2059.
This is version 2.2.132, for RimWorld 1.0.2059.
1 change: 0 additions & 1 deletion Source/Pharmacist/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ public static class Constants
public const int CareSelectorColumnWidth = 50;
public const int CareSelectorRowLabelWidth = 150;
public const int Margin = 6;
public const float LethalDiseaseLowerBound = 0.1f;
}
}
32 changes: 26 additions & 6 deletions Source/Pharmacist/MainTabWindow_Pharmacist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,47 @@ private void CreateMedicalCareSelectionFloatMenu( Action<MedicalCareCategory> ac
Find.WindowStack.Add( new FloatMenu( options ) );
}

private float _optionsHeight = -1f;
private Vector2 _optionsScrollPosition = Vector2.zero;
private void DrawOptions( Rect canvas )
{
// draw background
GUI.DrawTexture( canvas, SlightlyDarkBackground );

var row = new Rect( canvas.xMin + Constants.Margin,
canvas.yMin + Constants.Margin,
canvas.width - Constants.Margin * 2,
var viewRect = new Rect(
canvas.xMin,
canvas.yMin,
canvas.width - 16f,
_optionsHeight );

var row = new Rect(
viewRect.xMin + Constants.Margin,
viewRect.yMin + Constants.Margin,
viewRect.width - Constants.Margin * 2,
RowHeight );


Widgets.BeginScrollView( canvas, ref _optionsScrollPosition, viewRect );

Widgets.Label( row, "Fluffy.Pharmacist.DiseaseMargin".Translate( PharmacistSettings.medicalCare.DiseaseMargin.ToStringPercent() ) );
TooltipHandler.TipRegion( row, "Fluffy.Pharmacist.DiseaseMargin.Tip".Translate() );
row.y += RowHeight;
PharmacistSettings.medicalCare.DiseaseMargin = Widgets.HorizontalSlider( row, PharmacistSettings.medicalCare.DiseaseMargin, 0f, 1f, roundTo: .01f );
row.y += RowHeight;


Widgets.Label( row, "Fluffy.Pharmacist.DiseaseThreshold".Translate( PharmacistSettings.medicalCare.DiseaseThreshold.ToStringPercent() ) );
TooltipHandler.TipRegion( row, "Fluffy.Pharmacist.DiseaseThreshold.Tip".Translate() );
row.y += RowHeight;
PharmacistSettings.medicalCare.DiseaseThreshold = Widgets.HorizontalSlider( row, PharmacistSettings.medicalCare.DiseaseThreshold, 0f, 1f, roundTo: .01f );
row.y += RowHeight;

Widgets.Label( row, "Fluffy.Pharmacist.MinorWoundsThreshold".Translate( PharmacistSettings.medicalCare.MinorWoundsThreshold ) );
TooltipHandler.TipRegion( row, "Fluffy.Pharmacist.MinorWoundsThreshold.Tip".Translate() );
row.y += RowHeight;
PharmacistSettings.medicalCare.MinorWoundsThreshold = (int)Widgets.HorizontalSlider( row, PharmacistSettings.medicalCare.MinorWoundsThreshold, 2, 20, roundTo: 1 );
row.y += RowHeight;

Widgets.EndScrollView();

_optionsHeight = row.yMax - canvas.yMin;
}

private void DrawCareSelectors( Rect canvas )
Expand Down
2 changes: 1 addition & 1 deletion Source/Pharmacist/Pharmacist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>node ../../postbuild update -x</PostBuildEvent>
<PostBuildEvent>mod update -x</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
8 changes: 8 additions & 0 deletions Source/Pharmacist/PharmacistSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class MedicalCare: IExposable
private Dictionary<Population, PopulationCare> _populationCare = new Dictionary<Population, PopulationCare>();
private float _diseaseMargin = 0.1f;
private int _minorWoundsThreshold = 5;
private float _diseaseThreshold = 0.1f;
public PopulationCare this[ Population index ]
{
get
Expand All @@ -47,6 +48,12 @@ public float DiseaseMargin
get => _diseaseMargin;
}

public float DiseaseThreshold
{
protected internal set => _diseaseThreshold = value;
get => _diseaseThreshold;
}

public int MinorWoundsThreshold
{
protected internal set => _minorWoundsThreshold = value;
Expand All @@ -57,6 +64,7 @@ public void ExposeData()
{
Scribe_Collections.Look( ref _populationCare, "Populations", LookMode.Value, LookMode.Deep );
Scribe_Values.Look( ref _diseaseMargin, "DiseaseMargin", 0.1f );
Scribe_Values.Look( ref _diseaseThreshold, "DiseaseThreshold", 0.1f );
Scribe_Values.Look( ref _minorWoundsThreshold, "MinorWoundsThreshold", 5 );
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Pharmacist/PharmacistUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static bool NearLethalDisease( Hediff h )
var compImmunizable = h.TryGetComp<HediffComp_Immunizable>();
return PotentiallyLethalDisease( h ) &&
!compImmunizable.FullyImmune &&
h.Severity > Constants.LethalDiseaseLowerBound &&
h.Severity > PharmacistSettings.medicalCare.DiseaseThreshold &&
compImmunizable.Immunity < PharmacistSettings.medicalCare.DiseaseMargin + h.Severity;
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Pharmacist/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0")]
[assembly: AssemblyFileVersion("2.2.129")]
[assembly: AssemblyFileVersion("2.2.132")]

0 comments on commit 1d23def

Please sign in to comment.