Skip to content

Commit

Permalink
Priximity detector bug fix (#43)
Browse files Browse the repository at this point in the history
* Rider IDE support.

* Untested patch for Anomaly proximity detector.

* Update Rider support gitignore.
  • Loading branch information
Epicguru authored Apr 26, 2024
1 parent 4e64b30 commit e7a9936
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 7 deletions.
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,29 @@ Source/packages/
Source/Content/Unity/RimVibes Bundles/Temp/

Source/UnityProject/UserSettings/

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries
8 changes: 4 additions & 4 deletions Source/AnimationMod/AnimRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -911,14 +911,14 @@ protected void DrawPawns(Action<Pawn, Vector2> labelDraw = null)
Patch_PawnRenderer_RenderPawnAt.AllowNext = true;
Patch_PawnRenderer_RenderPawnAt.DoNotModify = true; // Don't use animation position/rotation.
Patch_PawnRenderer_RenderPawnAt.NextDrawMode = Patch_PawnRenderer_RenderPawnAt.DrawMode.Full;
Patch_PawnUtility_IsInvisible.IsRendering = true;
Patch_InvisibilityUtility_IsPsychologicallyInvisible.IsRendering = true;
PrePawnSpecialRender?.Invoke(pawn, this, Map);

pawn.DrawNowAt(pawn.DrawPosHeld ?? pawn.DrawPos);

PostPawnSpecialRender?.Invoke(pawn, this, Map);
Patch_PawnRenderer_RenderPawnAt.DoNotModify = false;
Patch_PawnUtility_IsInvisible.IsRendering = false;
Patch_InvisibilityUtility_IsPsychologicallyInvisible.IsRendering = false;

// Draw label.
Vector3 drawPos2 = pawn.DrawPos;
Expand Down Expand Up @@ -971,15 +971,15 @@ protected void DrawPawns(Action<Pawn, Vector2> labelDraw = null)
: i == 0 ? Patch_PawnRenderer_RenderPawnAt.DrawMode.BodyOnly : Patch_PawnRenderer_RenderPawnAt.DrawMode.HeadOnly;

Patch_PawnRenderer_DrawShadowInternal.Suppress = suppressShadow; // In 1.4 shadow rendering is baked into RenderPawnAt and may need to be prevented.
Patch_PawnUtility_IsInvisible.IsRendering = true;
Patch_InvisibilityUtility_IsPsychologicallyInvisible.IsRendering = true;

PrePawnSpecialRender?.Invoke(pawn, this, Map);

pawn.Drawer.renderer.RenderPawnAt(pos, dir, true); // This direction here is not the final one.

PostPawnSpecialRender?.Invoke(pawn, this, Map);
Patch_PawnRenderer_DrawShadowInternal.Suppress = false;
Patch_PawnUtility_IsInvisible.IsRendering = false;
Patch_InvisibilityUtility_IsPsychologicallyInvisible.IsRendering = false;
}

// Render shadow.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using HarmonyLib;
using JetBrains.Annotations;
using RimWorld;

namespace AM.Patches;

/// <summary>
/// The proximity detector freaks out if it detects any invisible pawn in range,
/// which includes the animated pawns.
/// This patch makes them not be considered invisible when the detection process is running.
/// </summary>
[HarmonyPatch(typeof(Building_ProximityDetector), nameof(Building_ProximityDetector.RunDetection))]
[UsedImplicitly(ImplicitUseKindFlags.Access, ImplicitUseTargetFlags.Itself | ImplicitUseTargetFlags.WithMembers)]
public class Patch_Building_ProximityDetector_RunDetection
{
[HarmonyPriority(Priority.First)]
private static void Prefix(ref bool __state)
{
__state = Patch_InvisibilityUtility_IsPsychologicallyInvisible.IsRendering;
Patch_InvisibilityUtility_IsPsychologicallyInvisible.IsRendering = true;
}

[HarmonyPriority(Priority.First)]
private static void Postfix(bool __state)
{
Patch_InvisibilityUtility_IsPsychologicallyInvisible.IsRendering = __state;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace AM.Patches;
/// compromise.
/// </summary>
[HarmonyPatch(typeof(InvisibilityUtility), nameof(InvisibilityUtility.IsPsychologicallyInvisible))]
public static class Patch_PawnUtility_IsInvisible
public static class Patch_InvisibilityUtility_IsPsychologicallyInvisible
{
public static bool IsRendering;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ private static void Prefix(DrawFaceGraphicsComp __instance, ref bool __state)
{
__state = true;
__instance.SetDirty();
Patch_PawnUtility_IsInvisible.IsRendering = true;
Patch_InvisibilityUtility_IsPsychologicallyInvisible.IsRendering = true;
}
}

private static void Postfix(bool __state)
{
if (__state)
{
Patch_PawnUtility_IsInvisible.IsRendering = false;
Patch_InvisibilityUtility_IsPsychologicallyInvisible.IsRendering = false;
}
}
}

0 comments on commit e7a9936

Please sign in to comment.