Skip to content

Commit

Permalink
1.0.9.8
Browse files Browse the repository at this point in the history
-Added HediffGiver_StartWithHediff
-Added HediffExpandedDef
  • Loading branch information
jecrell committed Apr 15, 2018
1 parent 2becba3 commit d450bad
Show file tree
Hide file tree
Showing 12 changed files with 474 additions and 400 deletions.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<url></url>
<targetVersion>0.18.0</targetVersion>
<description>
[1.0.9.7] Adds modding components to RimWorld: vehicles, spell casting, weapon slots, oversized weapons, and more!
[1.0.9.8] Adds modding components to RimWorld: vehicles, spell casting, weapon slots, oversized weapons, and more!

Note to players: This mod will not change your game, but rather it lets modders do more, so you can have an even more amazing RimWorld experience.

Expand Down
Binary file modified Assemblies/0JecsTools.dll
Binary file not shown.
Binary file modified Assemblies/AbilityUserAI.dll
Binary file not shown.
Binary file modified Assemblies/CompInstalledPart.dll
Binary file not shown.
Binary file modified Assemblies/CompSlotLoadable.dll
Binary file not shown.
3 changes: 3 additions & 0 deletions Source/.idea/.idea.JecsTools/.idea/contentModel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

759 changes: 360 additions & 399 deletions Source/.idea/.idea.JecsTools/.idea/workspace.xml

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions Source/AllModdingComponents/JecsTools/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ static HarmonyPatches()
new HarmonyMethod(typeof(HarmonyPatches), nameof(ApplyProperDamage)), null);
harmony.Patch(AccessTools.Method(typeof(ArmorUtility), "GetPostArmorDamage"), null,
new HarmonyMethod(typeof(HarmonyPatches), nameof(Post_GetPostArmorDamage)));
harmony.Patch(AccessTools.Method(typeof(PawnGenerator), "GeneratePawnInternal"), null,
new HarmonyMethod(typeof(HarmonyPatches), nameof(Post_GeneratePawnInternal)));


/* harmony.Patch(
AccessTools.Method(typeof(DamageWorker_AddInjury), "FinalizeAndAddInjury",
Expand All @@ -43,6 +46,18 @@ static HarmonyPatches()
nameof(ApplyProperDamage)), null);*/
}

public static void Post_GeneratePawnInternal(PawnGenerationRequest request, ref Pawn __result)
{
var hediffGiverSet = __result?.def?.race?.hediffGiverSets?.FirstOrDefault(
x => x.hediffGivers.Any(y => y is HediffGiver_StartWithHediff));
if (hediffGiverSet == null) return;

if (hediffGiverSet.hediffGivers.FirstOrDefault(x => x is HediffGiver_StartWithHediff) is HediffGiver_StartWithHediff hediffGiver)
{
hediffGiver.GiveHediff(__result);
}
}

//ArmorUtility
public static void Post_GetPostArmorDamage(Pawn pawn, int amountInt, BodyPartRecord part, DamageDef damageDef)
{
Expand Down
29 changes: 29 additions & 0 deletions Source/AllModdingComponents/JecsTools/HediffExpandedDef.cs
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;

}
}
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 Source/AllModdingComponents/JecsTools/HediffWithComps_Expanded.cs
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();
}
}
}
}
3 changes: 3 additions & 0 deletions Source/AllModdingComponents/JecsTools/JecsTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
<Compile Include="CaravanJobs\WorldObjectRecipeDef.cs" />
<Compile Include="CaravanJobs\WorldObject_ProgressBar.cs" />
<None Include="CaravanJobs\WorldProgressBarDrawer.cs" />
<Compile Include="HediffExpandedDef.cs" />
<Compile Include="HediffGiver_StartWithHediff.cs" />
<Compile Include="HediffWithComps_Expanded.cs" />
<Compile Include="PatchOperationModLoaded.cs" />
<Compile Include="Projectile_Laser.cs" />
<Compile Include="DamageDefCleave.cs" />
Expand Down

0 comments on commit d450bad

Please sign in to comment.