Skip to content

Commit

Permalink
CAI fix (#45)
Browse files Browse the repository at this point in the history
* Fix CAI patch.
* Restore path blocking when in animations.
* Fix or suppress warnings, re-enable warnings as errors.
  • Loading branch information
Epicguru authored Apr 26, 2024
1 parent 67d83e4 commit 75751be
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 49 deletions.
11 changes: 5 additions & 6 deletions Source/1.5/AnimationMod/Grappling/GrappleFlyer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ public static GrappleFlyer MakeGrappleFlyer(Pawn grappler, Pawn victim, in IntVe
public int TotalDurationTicks => ticksFlightTime;
public Pawn Grappler;

private Material cachedShadowMaterial;
private Effecter flightEffecter = null;
private int positionLastComputedTick = -1;
private Vector3 groundPos;
private Vector3 effectivePos;
private float effectiveHeight;
private new Effecter flightEffecter = null;
private new int positionLastComputedTick = -1;
private new Vector3 groundPos;
private new Vector3 effectivePos;
private new float effectiveHeight;

private Material ShadowMaterial => this.def.pawnFlyer.ShadowMaterial;

Expand Down
2 changes: 1 addition & 1 deletion Source/1.5/AnimationMod/Grappling/KnockbackFlyer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public override void Tick()
map.flecks.CreateFleck(dataStatic);
}

private void LandingEffects()
private new void LandingEffects()
{
soundLanding.PlayOneShot(new TargetInfo(EndPos.ToIntVec3(), Map));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace AM.Patches;
[HarmonyPatch(typeof(InvisibilityUtility), nameof(InvisibilityUtility.IsPsychologicallyInvisible))]
public static class Patch_InvisibilityUtility_IsPsychologicallyInvisible
{
/// <summary>
/// If true, the patch is disabled.
/// </summary>
public static bool IsRendering;

[HarmonyPriority(Priority.First)]
Expand All @@ -24,8 +27,7 @@ public static bool Prefix(Pawn pawn, ref bool __result)
if (!Core.Settings.AllowInvisiblePawns)
return true;

var anim = PatchMaster.GetAnimator(pawn);
if (anim != null && !IsRendering)
if (!IsRendering && PatchMaster.GetAnimator(pawn) != null)
{
__result = true;
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using HarmonyLib;
using JetBrains.Annotations;
using RimWorld;

namespace AM.Patches;

/// <summary>
/// Invisible pawns can't block pathing, but we do want pathing to be blocked
/// by pawns that are in animations.
/// This was a change introduced in Rimworld 1.5.
/// </summary>
[HarmonyPatch(typeof(PawnUtility), nameof(PawnUtility.PawnBlockingPathAt))]
[UsedImplicitly]
public static class Patch_PawnUtility_PawnBlockingPathAt
{
[HarmonyPriority(Priority.First)]
// ReSharper disable once RedundantAssignment
private static void Prefix(ref bool __state)
{
__state = Patch_InvisibilityUtility_IsPsychologicallyInvisible.IsRendering;
Patch_InvisibilityUtility_IsPsychologicallyInvisible.IsRendering = true;
}

[HarmonyPriority(Priority.First)]
private static void Prefix(bool __state)
{
Patch_InvisibilityUtility_IsPsychologicallyInvisible.IsRendering = __state;
}
}
3 changes: 0 additions & 3 deletions Source/1.5/CAI5000Patch/CAI5000AnimationPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ public static void Init()
IdleControllerComp.ShouldDrawAdditional.Add(ShouldDraw);

GameComp.LazyTick += FlushOldMapsFromCache;

AnimRenderer.PrePawnSpecialRender += FixCustomRenderInAnimator.PreCustomPawnRender;
AnimRenderer.PostPawnSpecialRender += FixCustomRenderInAnimator.PostCustomPawnRender;
}

private static MapComponent_FogGrid GetFogger(ThingComp comp)
Expand Down
2 changes: 2 additions & 0 deletions Source/1.5/CAI5000Patch/CAI5000Patch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<Nullable>disable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>none</DebugType>
<!-- CombatAI assembly, as released on Steam, is built on AMD, throws warning, harmless but annoying. -->
<NoWarn>MSB3270</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
36 changes: 0 additions & 36 deletions Source/1.5/CAI5000Patch/FixCustomRenderInAnimator.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace AM.CAI5000Patch;

/// <summary>
/// Prevents pawns from running away (a mechanic added by CAI) during animations.
/// </summary>
[UsedImplicitly]
[HarmonyPatch(typeof(ThingComp_CombatAI), nameof(ThingComp_CombatAI.CompTickRare))]
public static class ThingComp_CombatAI_CompTickRare_Transpiler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace AM.CAI5000Patch;

/// <summary>
/// Prevents pawns from running away (a mechanic added by CAI) during animations.
/// </summary>
[UsedImplicitly]
[HarmonyPatch(typeof(ThingComp_CombatAI), nameof(ThingComp_CombatAI.OnScanFinished))]
public static class ThingComp_CombatAI_OnScanFinished_Transpiler
Expand Down
Binary file modified Source/1.5/CAI5000Patch/refs/CombatAI.dll
Binary file not shown.
3 changes: 3 additions & 0 deletions Source/1.5/CombatExtendedPatch/CombatExtendedPatch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<Nullable>disable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>none</DebugType>

<!-- Duplicate type caused by publiciser content (which includes a .cs file) being brought in from the referenced .dll -->
<NoWarn>CS0436</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Source/1.5/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<!-- Other common properties -->
<TargetFramework>net48</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
Expand All @@ -10,14 +10,22 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<!-- Generate ready to run images during publishing to improve cold start time. -->
<PublishReadyToRun>true</PublishReadyToRun>

<!-- Models project build for net472, throws warning when used in net6.0. Ignore it, it's fine. -->
<!-- Newtonsoft.Json built for net472, throws warning when used in net6.0. Ignore it, it's fine (the serializer is not actually used here in the backend). -->
<NoWarn>NU1702,NU1701</NoWarn>
<MSBuildWarningsAsMessages>NU1702</MSBuildWarningsAsMessages>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Amazon.Lambda.AspNetCoreServer.Hosting" Version="1.6.0" />
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.200.3" />
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.7" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\ModRequestAPI.Models\ModRequestAPI.Models.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<Nullable>disable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DebugType>none</DebugType>

<!-- Duplicate type caused by publiciser content (which includes a .cs file) being brought in from the referenced .dll -->
<NoWarn>CS0436</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 75751be

Please sign in to comment.