Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jecrell/JecsTools
Browse files Browse the repository at this point in the history
  • Loading branch information
jecrell committed Dec 14, 2018
2 parents a99fc92 + d0cd247 commit a44af6b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
34 changes: 33 additions & 1 deletion Source/AllModdingComponents/JecsTools/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using AbilityUser;
using Harmony;
using RimWorld;
Expand Down Expand Up @@ -93,8 +95,11 @@ static HarmonyPatches()
AccessTools.Method(typeof(Verb),
"CanHitCellFromCellIgnoringRange"),
new HarmonyMethod(type, nameof(CanHitCellFromCellIgnoringRange_Prefix)), null);

//optionally use "CutoutComplex" shader for apparel that wants it
harmony.Patch(AccessTools.Method(typeof(ApparelGraphicRecordGetter), nameof(ApparelGraphicRecordGetter.TryGetGraphicApparel)), null, null, new HarmonyMethod(type, nameof(CutOutComplexApparel_Transpiler)));
}

//Added B19, Oct 2019
//ProjectileExtension check
//Allows a bullet to pass through walls when fired.
Expand Down Expand Up @@ -712,5 +717,32 @@ public static void PushEffect(Thing Caster, Thing target, int distance, bool dam
}
}, "PushingCharacter", false, null);
}

//added 2018/12/13 - Mehni.
//Uses CutoutComplex shader for apparel that wants it.
private static IEnumerable<CodeInstruction> CutOutComplexApparel_Transpiler(IEnumerable<CodeInstruction> instructions)
{
MethodInfo shader = AccessTools.Method(typeof(HarmonyPatches), nameof(HarmonyPatches.Shader));
FieldInfo cutOut = AccessTools.Field(typeof(ShaderDatabase), nameof(ShaderDatabase.Cutout));

foreach (CodeInstruction codeInstruction in instructions)
{
if (codeInstruction.opcode == OpCodes.Ldsfld && codeInstruction.operand == cutOut)
{
yield return new CodeInstruction(OpCodes.Ldarg_0); //apparel
yield return new CodeInstruction(OpCodes.Call, shader); //return shader type
continue; //skip instruction.
}
yield return codeInstruction;
}
}

private static Shader Shader (Apparel apparel)
{
if (apparel.def.graphicData.shaderType.Shader == ShaderDatabase.CutoutComplex)
return ShaderDatabase.CutoutComplex;

return ShaderDatabase.Cutout;
}
}
}
3 changes: 0 additions & 3 deletions Source/DiscordWebhookToken.txt

This file was deleted.

0 comments on commit a44af6b

Please sign in to comment.