Skip to content

Commit

Permalink
git commit from PowerShell in C#JecsTools A (potential) fix for an is…
Browse files Browse the repository at this point in the history
…sue shared between Hospitality and JecsTools.
  • Loading branch information
jecrell committed Sep 17, 2018
1 parent 82c15c5 commit ad9a865
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 33 deletions.
2 changes: 1 addition & 1 deletion About/Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0.2
1.1.0.4
Binary file modified Assemblies/0JecsTools.dll
Binary file not shown.
Binary file modified Assemblies/AbilityUser.dll
Binary file not shown.
Binary file modified Assemblies/CompDeflector.dll
Binary file not shown.
75 changes: 49 additions & 26 deletions Source/AllModdingComponents/JecsTools/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static HarmonyPatches()
var harmony = HarmonyInstance.Create("rimworld.jecrell.jecstools.main");
//Allow fortitude to soak damage
var type = typeof(HarmonyPatches);

//Debug Line
//------------
// harmony.Patch(
Expand Down Expand Up @@ -94,9 +94,11 @@ public static void GenerateStartingApparelFor_PostFix(Pawn pawn, PawnGenerationR
{
pawn.apparel.Wear(apparel, false);
}

destroyables.Add(swap);
}
}

if (destroyables == null || destroyables?.Count <= 0) return;
while (destroyables?.Count > 0)
{
Expand Down Expand Up @@ -177,6 +179,7 @@ public static bool Notify_MemberDied(Faction __instance, Pawn member, DamageInfo
{
return false;
}

return true;
}

Expand All @@ -189,38 +192,49 @@ public static bool Notify_MemberDied(Faction __instance, Pawn member, DamageInfo
/// <param name="__result"></param>
public static void Post_CanWearTogether(ThingDef A, ThingDef B, BodyDef body, ref bool __result)
{
var aHasExt = A.HasModExtension<ApparelExtension>();
var bHasExt = B.HasModExtension<ApparelExtension>();
if (aHasExt && bHasExt)
try
{
var aExt = A.GetModExtension<ApparelExtension>();
var bExt = B.GetModExtension<ApparelExtension>();
var check = new Dictionary<string, int>();
for (int i = 0; i < aExt.coverage.Count; i++)
if (A == null || B == null || body == null || __result == true) return;
var aHasExt = A.HasModExtension<ApparelExtension>();
var bHasExt = B.HasModExtension<ApparelExtension>();
if (aHasExt && bHasExt)
{
if (!check.ContainsKey(aExt.coverage[i]))
check.Add(aExt.coverage[i].ToLowerInvariant(), 1);
else
{
Log.Warning("JecsTools :: ApparelExtension :: Warning:: " + A.label +
" has multiple of the same tags.");
return;
}
var aExt = A.GetModExtension<ApparelExtension>();
var bExt = B.GetModExtension<ApparelExtension>();
var check = new Dictionary<string, int>();
if (aExt.coverage?.Count > 0)
for (int i = 0; i < aExt.coverage.Count; i++)
{
if (!check.ContainsKey(aExt.coverage[i]))
check.Add(aExt.coverage[i].ToLowerInvariant(), 1);
else
{
Log.Warning("JecsTools :: ApparelExtension :: Warning:: " + A.label +
" has multiple of the same tags.");
return;
}
}

if (bExt.coverage?.Count > 0)
for (int j = 0; j < bExt.coverage.Count; j++)
{
if (!check.ContainsKey(bExt.coverage[j]))
check.Add(bExt.coverage[j].ToLowerInvariant(), 1);
else
{
__result = false;
break;
}
}
}
for (int j = 0; j < bExt.coverage.Count; j++)
else if ((aHasExt && !bHasExt) || (!aHasExt && bHasExt))
{
if (!check.ContainsKey(bExt.coverage[j]))
check.Add(bExt.coverage[j].ToLowerInvariant(), 1);
else
{
__result = false;
break;
}
__result = true;
}
}
else if ((aHasExt && !bHasExt) || (!aHasExt && bHasExt))
catch (Exception e)
{
__result = true;
Log.Message(e.ToString());
}
}

Expand Down Expand Up @@ -249,6 +263,7 @@ public static void Post_GetPostArmorDamage(Pawn pawn, float amount, BodyPartReco
{
DamageSoakedMote(pawn, tempDamageAbsorbed.Value);
}

tempDamageAbsorbed = null;
}
}
Expand Down Expand Up @@ -295,6 +310,7 @@ public static bool PreApplyDamage_PrePatch(Pawn_HealthTracker __instance, ref Da
{
}
}

if (dinfo.Weapon is ThingDef weaponDef && !weaponDef.IsRangedWeapon)
if (dinfo.Instigator is Pawn instigator)
{
Expand All @@ -316,6 +332,7 @@ public static bool PreApplyDamage_PrePatch(Pawn_HealthTracker __instance, ref Da
}
}
}

tempDamageAmount = (int) dinfo.Amount;
absorbed = false;
//Log.Message("Current Damage :" + dinfo.Amount);
Expand Down Expand Up @@ -352,6 +369,7 @@ private static void PreApplyDamage_ApplyKnockback(Pawn instigator, Pawn pawn)
explosion.damageFalloff = false; // dealMoreDamageAtCenter = false;
explosion.StartExplosion(null);
}

if (pawn != instigator && !pawn.Dead && !pawn.Downed && pawn.Spawned)
{
if (knocker.Props.stunChance > -1 && knocker.Props.stunChance >= Rand.Value)
Expand Down Expand Up @@ -379,10 +397,13 @@ private static bool PreApplyDamage_ApplyExtraDamages(out bool absorbed, Pawn ins
StopPreApplyDamageCheck = false;
return true;
}

pawn.TakeDamage(new DamageInfo(dmg.def, dmg.amount, dmg.armorPenetration, -1, instigator));
}

StopPreApplyDamageCheck = false;
}

absorbed = false;
return false;
}
Expand Down Expand Up @@ -459,6 +480,7 @@ private static bool PreApplyDamage_ApplyDamageSoakers(ref DamageInfo dinfo, out
}
}
}

absorbed = false;
return false;
}
Expand Down Expand Up @@ -497,6 +519,7 @@ public static Vector3 PushResult(Thing Caster, Thing thingToPush, int pushDist,
}
}
}

collision = collisionResult;
return result;
}
Expand Down
12 changes: 6 additions & 6 deletions updateinfo
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

JecsTools Update
====================
Version: 1.1.0.2
Updated: 09-16-2018
Description: Fixed the second error caused by deflection systems (from Xen)
Version: 1.1.0.3
Updated: 09-17-2018
Description: Neglected to include latest compiled fix.
====================

Download now on...
Expand All @@ -25,9 +25,9 @@ Discuss the mod on...
[img width=260]https://raw.githubusercontent.com/jecrell/JecsTools/master/About/Preview.png[/img]
[hr]
[b]JecsTools
Version: 1.1.0.2
Updated: 09-16-2018
Description: [color=orange]Fixed the second error caused by deflection systems (from Xen)[/color]
Version: 1.1.0.3
Updated: 09-17-2018
Description: [color=orange]Neglected to include latest compiled fix. [/color]
[hr]
[b]Download now on...[/b]
[url=https://www.patreon.com/posts/jecstools-for-0-21059900]Patreon[/url]
Expand Down

0 comments on commit ad9a865

Please sign in to comment.