-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Added HediffGiver_StartWithHediff -Added HediffExpandedDef
- Loading branch information
Showing
12 changed files
with
474 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Source/AllModdingComponents/JecsTools/HediffExpandedDef.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Verse; | ||
|
||
namespace JecsTools | ||
{ | ||
/// <summary> | ||
/// A simple hediff for translations. | ||
/// </summary> | ||
public class HediffExpandedDef : HediffDef | ||
{ | ||
/// <summary> | ||
/// Determines if the description should be shown for a hediff. | ||
/// </summary> | ||
public bool showDescription; | ||
|
||
///Reminder: the string description already exists in the Def class we inherit in this class | ||
//public string description; | ||
|
||
/// <summary> | ||
/// Text that appears before the list of modifiers. | ||
/// </summary> | ||
public string preListText; | ||
|
||
/// <summary> | ||
/// Text that appears after the list of modifiers. | ||
/// </summary> | ||
public string postListText; | ||
|
||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
Source/AllModdingComponents/JecsTools/HediffGiver_StartWithHediff.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Verse; | ||
|
||
namespace JecsTools | ||
{ | ||
/// <summary> | ||
/// Adds a hediff to a character after it is generated/spawned. | ||
/// Perfect for Alien Race bonuses/modifiers. | ||
/// Chance option to add for some randomization. | ||
/// </summary> | ||
public class HediffGiver_StartWithHediff : HediffGiver | ||
{ | ||
public float chance = 100.0f; | ||
public float maleCommonality = 100.0f; | ||
public float femaleCommonality = 100.0f; | ||
public HediffExpandedDef expandedDef; | ||
|
||
public void GiveHediff(Pawn pawn) | ||
{ | ||
//If the random number is not within the chance range, exit. | ||
if (!(chance >= Rand.Range(0.0f, 100.0f))) return; | ||
//If the gender is male, check the male commonality chance, and if it fails, exit. | ||
if (pawn.gender == Gender.Male && !(maleCommonality >= Rand.Range(0.0f, 100.0f))) | ||
return; | ||
//If the gender is female, check the female commonality chance, and if it fails, exit. | ||
if (pawn.gender == Gender.Female && !(femaleCommonality >= Rand.Range(0.0f, 100.0f))) | ||
return; | ||
|
||
if (expandedDef != null) | ||
HealthUtility.AdjustSeverity(pawn, expandedDef, 1f); | ||
else | ||
HealthUtility.AdjustSeverity(pawn, this.hediff, 1f); | ||
|
||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
Source/AllModdingComponents/JecsTools/HediffWithComps_Expanded.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Linq; | ||
using System.Text; | ||
using Verse; | ||
|
||
namespace JecsTools | ||
{ | ||
public class HediffWithComps_Expanded : HediffWithComps | ||
{ | ||
private HediffExpandedDef Def => def as HediffExpandedDef; | ||
|
||
public override string TipStringExtra | ||
{ | ||
get | ||
{ | ||
if (Def == null) return base.TipStringExtra; | ||
StringBuilder s = new StringBuilder(); | ||
if (Def.showDescription) | ||
{ | ||
s.AppendLine(def.description); | ||
} | ||
if (!string.IsNullOrEmpty(Def.preListText)) s.AppendLine(Def.preListText); | ||
s.AppendLine(base.TipStringExtra); | ||
if (!string.IsNullOrEmpty(Def.postListText)) s.AppendLine(Def.postListText); | ||
return s.ToString(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters