Skip to content

Commit

Permalink
Friendly animals who are blocking shooters will have their name label…
Browse files Browse the repository at this point in the history
… shown in green, even if animal labels are off.
  • Loading branch information
Falconne committed Mar 15, 2019
1 parent 29f901f commit c71a998
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/AvoidFriendlyFire/AvoidFriendlyFire.csproj
Expand Up @@ -54,6 +54,7 @@
<Compile Include="FireProperties.cs" />
<Compile Include="Main.cs" />
<Compile Include="Patches\AttackTargetFinder_BestAttackTarget_Patch.cs" />
<Compile Include="Patches\PawnUIOverlay_DrawPawnGUIOverlay_Patch.cs" />
<Compile Include="Patches\TooltipUtility_ShotCalculationTipString_Patch.cs" />
<Compile Include="Patches\PawnNameColorUtility_PawnNameColorOf_Patch.cs" />
<Compile Include="Patches\Pawn_DraftController_GetGizmos_Patch.cs" />
Expand Down
@@ -0,0 +1,34 @@
using System.Reflection;
using Harmony;
using UnityEngine;
using Verse;

namespace AvoidFriendlyFire
{
[HarmonyPatch(typeof(PawnUIOverlay), "DrawPawnGUIOverlay")]
public class PawnUIOverlay_DrawPawnGUIOverlay_Patch
{
private static readonly FieldInfo _pawnGetter =
typeof(PawnUIOverlay).GetField("pawn", BindingFlags.NonPublic | BindingFlags.Instance);

public static bool Prefix(ref PawnUIOverlay __instance)
{
var pawn = (Pawn) _pawnGetter.GetValue(__instance);
if (!pawn.Spawned || pawn.Map.fogGrid.IsFogged(pawn.Position))
{
return false;
}

if (pawn.RaceProps.Humanlike || pawn.Name == null)
return true;

if (!Main.Instance.PawnStatusTracker.IsABlocker(pawn))
return true;

Vector2 pos = GenMapUI.LabelDrawPosFor(pawn, -0.6f);
GenMapUI.DrawPawnLabel(pawn, pos);

return false;
}
}
}
4 changes: 2 additions & 2 deletions src/AvoidFriendlyFire/Properties/AssemblyInfo.cs
Expand Up @@ -32,7 +32,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.4.0")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyVersion("1.0.5.0")]
[assembly: AssemblyFileVersion("1.0.5.0")]


0 comments on commit c71a998

Please sign in to comment.