Skip to content

Commit

Permalink
Done...
Browse files Browse the repository at this point in the history
  • Loading branch information
Epicguru committed Apr 14, 2024
1 parent 08cdd43 commit ef81b71
Show file tree
Hide file tree
Showing 30 changed files with 348 additions and 250 deletions.
2 changes: 1 addition & 1 deletion Defs/Jobs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<casualInterruptible>false</casualInterruptible>
<playerInterruptible>true</playerInterruptible>
<allowOpportunisticPrefix>false</allowOpportunisticPrefix>
<dropThingBeforeJob>false</dropThingBeforeJob>
<dropThingBeforeJob>true</dropThingBeforeJob>
<suspendable>false</suspendable>
<neverShowWeapon>true</neverShowWeapon>
<isIdle>false</isIdle>
Expand Down
2 changes: 1 addition & 1 deletion Source/AMRetextureSupport/AMRetextureSupport.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.4060-beta" />
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.4063" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Source/AlienRacesPatch/AlienRacesPatch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.4060-beta" />
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.4063" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 7 additions & 0 deletions Source/AnimationMod.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Patches", "Patches", "{7C1C
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TacticowlPatch", "TacticowlPatch\TacticowlPatch.csproj", "{DEC2223C-6DD4-48EF-9438-8F4E97B6C542}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FacialAnimationPatch", "FacialAnimationPatch\FacialAnimationPatch.csproj", "{B5AC984E-8B51-426B-9F54-CC85006449F1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -84,6 +86,10 @@ Global
{DEC2223C-6DD4-48EF-9438-8F4E97B6C542}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEC2223C-6DD4-48EF-9438-8F4E97B6C542}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEC2223C-6DD4-48EF-9438-8F4E97B6C542}.Release|Any CPU.Build.0 = Release|Any CPU
{B5AC984E-8B51-426B-9F54-CC85006449F1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B5AC984E-8B51-426B-9F54-CC85006449F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B5AC984E-8B51-426B-9F54-CC85006449F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B5AC984E-8B51-426B-9F54-CC85006449F1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -98,6 +104,7 @@ Global
{06C481CC-E8D0-46D6-B02B-127DD9E3A1AA} = {3549402C-9759-4ABC-938C-FC4F801C156F}
{7B881968-1527-40FC-9FB3-85A5A01BEE88} = {7C1CE274-810E-467E-B8EF-4AB2A83E17F9}
{DEC2223C-6DD4-48EF-9438-8F4E97B6C542} = {7C1CE274-810E-467E-B8EF-4AB2A83E17F9}
{B5AC984E-8B51-426B-9F54-CC85006449F1} = {7C1CE274-810E-467E-B8EF-4AB2A83E17F9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1478B48A-1088-4408-9427-E3B4EADB515C}
Expand Down
33 changes: 18 additions & 15 deletions Source/AnimationMod/AnimRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public class AnimRenderer : IExposable

public static readonly char[] Alphabet = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
public static readonly List<AnimRenderer> PostLoadPendingAnimators = new List<AnimRenderer>();
public static event Action<Pawn, AnimRenderer> PrePawnSpecialRender;
public static event Action<Pawn, AnimRenderer> PostPawnSpecialRender;
public static Action<Pawn, AnimRenderer, Map> PrePawnSpecialRender;
public static Action<Pawn, AnimRenderer, Map> PostPawnSpecialRender;
public static Material DefaultCutout, DefaultTransparent;
public static IReadOnlyList<AnimRenderer> ActiveRenderers => activeRenderers;
public static IReadOnlyCollection<Pawn> CapturedPawns => pawnToRenderer.Keys;
Expand Down Expand Up @@ -909,15 +909,16 @@ protected void DrawPawns(Action<Pawn, Vector2> labelDraw = null)
{
// Regular pawn render.
Patch_PawnRenderer_RenderPawnAt.AllowNext = true;
Patch_PawnRenderer_RenderPawnInternal.AllowNext = true;
Patch_PawnRenderer_RenderPawnInternal.DoNotModify = true; // Don't use animation position/rotation.
Patch_PawnRenderer_RenderPawnInternal.NextDrawMode = Patch_PawnRenderer_RenderPawnInternal.DrawMode.Full;
PrePawnSpecialRender?.Invoke(pawn, this);
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;
PrePawnSpecialRender?.Invoke(pawn, this, Map);

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

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

// Draw label.
Vector3 drawPos2 = pawn.DrawPos;
Expand Down Expand Up @@ -959,24 +960,26 @@ protected void DrawPawns(Action<Pawn, Vector2> labelDraw = null)

// Head rotation needs to be sent manually because the head
// does not have a direction curve to sample.
Patch_PawnRenderer_RenderPawnInternal.HeadRotation = dir; // Copy body facing direction.
Patch_PawnRenderer_RenderPawnAt.HeadRotation = dir; // Copy body facing direction.
}

// Render pawn in custom position using patches.
Patch_PawnRenderer_RenderPawnAt.AllowNext = true;
Patch_PawnRenderer_RenderPawnInternal.AllowNext = true;

Patch_PawnRenderer_RenderPawnInternal.NextDrawMode = !isBeheaded
? Patch_PawnRenderer_RenderPawnInternal.DrawMode.Full
: i == 0 ? Patch_PawnRenderer_RenderPawnInternal.DrawMode.BodyOnly : Patch_PawnRenderer_RenderPawnInternal.DrawMode.HeadOnly;
Patch_PawnRenderer_RenderPawnAt.NextDrawMode = !isBeheaded
? Patch_PawnRenderer_RenderPawnAt.DrawMode.Full
: 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.
PrePawnSpecialRender?.Invoke(pawn, this);
Patch_PawnUtility_IsInvisible.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);
PostPawnSpecialRender?.Invoke(pawn, this, Map);
Patch_PawnRenderer_DrawShadowInternal.Suppress = false;
Patch_PawnUtility_IsInvisible.IsRendering = false;
}

// Render shadow.
Expand Down
4 changes: 2 additions & 2 deletions Source/AnimationMod/AnimationMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Lib.Harmony" Version="2.3.1.1">
<PackageReference Include="Lib.Harmony" Version="2.3.3">
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="PolySharp" Version="1.14.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.4060-beta" />
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.5.4063" />
<PackageReference Include="Portable.Meta.Numerics" Version="3.1.0.73149" />
<ProjectReference Include="..\AMRetextureSupport\AMRetextureSupport.csproj" />
<ProjectReference Include="..\ModRequestAPI\ModRequestAPI.csproj" />
Expand Down
10 changes: 9 additions & 1 deletion Source/AnimationMod/AutoDuel/AutoFriendlyDuelMapComp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,15 @@ public static bool CanPawnDuel(Pawn pawn)
return false;

// Check pawn is in recreation and not doing anything majorly important.
if (pawn.timetable.CurrentAssignment != TimeAssignmentDefOf.Joy || !(pawn.CurJobDef?.playerInterruptible ?? true))
bool currentTimetableAllowsJob = pawn.timetable.CurrentAssignment.allowJoy;
bool currentTimetableIsSleep = pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Sleep;
if (currentTimetableIsSleep || !currentTimetableAllowsJob)
return false;

bool canInterruptJob = pawn.CurJobDef?.playerInterruptible ?? true;
bool isJobPlayerForced = pawn.CurJob?.playerForced ?? false;

if (!canInterruptJob || isJobPlayerForced)
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions Source/AnimationMod/AutoDuel/JoyGiver_FriendlyDuel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ public override Job TryGiveJob(Pawn pawn)
if (!AutoFriendlyDuelMapComp.CanPawnDuel(pawn))
return null;

// Try get a duel partner.
// Try to get a duel partner.
var partner = comp.TryGetRandomDuelPartner(pawn);
if (partner == null)
return null;

// Try get a duel spot for us two:
// Try to get a duel spot for us two:
var spot = comp.TryGetBestDuelSpotFor(pawn, partner);
if (spot == null)
return null;
Expand Down
1 change: 0 additions & 1 deletion Source/AnimationMod/GameComp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ public override void GameComponentTick()
GrabUtility.Tick();

Patch_Corpse_DrawAt.Tick();
Patch_PawnRenderer_LayingFacing.Tick();

const float DT = 1 / 60f;

Expand Down
4 changes: 2 additions & 2 deletions Source/AnimationMod/Grappling/GrappleFlyer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public override void SpawnSetup(Map map, bool respawningAfterLoad)
ticksFlightTime = Mathf.Max(2, (int)(ticksFlightTime / (speed * Core.Settings.GrappleSpeed)));
}

private void RecomputePosition()
private new void RecomputePosition()
{
if (this.positionLastComputedTick == this.ticksFlying)
{
Expand Down Expand Up @@ -158,7 +158,7 @@ public static void DrawBoundTexture(Pawn pawn, Vector3 drawLoc, Color ropeColor)
Graphics.DrawMesh(MeshPool.plane10, trs, mat, 0, null, 0, mpb);
}

private void DrawShadow(Vector3 drawLoc, float height)
private new void DrawShadow(Vector3 drawLoc, float height)
{
Material shadowMaterial = this.ShadowMaterial;
if (shadowMaterial == null)
Expand Down
15 changes: 10 additions & 5 deletions Source/AnimationMod/Heads/HeadInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,24 @@ public bool Render()
return true;

//Render pawn in custom position using patches.
Patch_PawnRenderer_RenderPawnInternal.NextDrawMode = Patch_PawnRenderer_RenderPawnInternal.DrawMode.HeadStandalone;
Patch_PawnRenderer_RenderPawnInternal.HeadRotation = Direction;
Patch_PawnRenderer_RenderPawnInternal.StandaloneHeadRotation = Rotation;
Patch_PawnRenderer_RenderPawnAt.NextDrawMode = Patch_PawnRenderer_RenderPawnAt.DrawMode.HeadStandalone;
Patch_PawnRenderer_RenderPawnAt.HeadRotation = Direction;
Patch_PawnRenderer_RenderPawnAt.StandaloneHeadAngle = Rotation;
Patch_PawnRenderer_RenderPawnAt.StandaloneHeadPosition = Position;
Patch_PawnRenderer_RenderPawnAt.AllowNext = true;
Patch_PawnRenderer_DrawShadowInternal.Suppress = true; // In 1.4 shadow rendering is baked into RenderPawnAt and may need to be prevented.
Patch_PawnRenderer_RenderPawnInternal.AllowNext = true;

try
{
AnimRenderer.PrePawnSpecialRender?.Invoke(Pawn, null, Map);

Pawn.Drawer.renderer.RenderPawnAt(Position, Direction, true);

AnimRenderer.PostPawnSpecialRender?.Invoke(Pawn, null, Map);
}
finally
{
Patch_PawnRenderer_RenderPawnInternal.NextDrawMode = Patch_PawnRenderer_RenderPawnInternal.DrawMode.Full;
Patch_PawnRenderer_RenderPawnAt.NextDrawMode = Patch_PawnRenderer_RenderPawnAt.DrawMode.Full;
Patch_PawnRenderer_DrawShadowInternal.Suppress = false;
}
return true;
Expand Down
3 changes: 1 addition & 2 deletions Source/AnimationMod/Outcome/OutcomeUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,7 @@ private static bool Kill(Pawn killer, Pawn pawn, in AdditionalArgs args)
{
// Do corpse interpolation - interpolates the corpse to the correct position, after the animated position.
Patch_Corpse_DrawAt.Interpolators[pawn.Corpse] = new CorpseInterpolate(pawn.Corpse, ss.GetWorldPosition());

Patch_PawnRenderer_LayingFacing.OverrideRotations[pawn] = ss.GetWorldDirection();
Patch_Corpse_DrawAt.OverrideRotations[pawn] = ss.GetWorldDirection();
}
else if (!isDeathless)
{
Expand Down
32 changes: 23 additions & 9 deletions Source/AnimationMod/Patches/Patch_Corpse_DrawAt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,50 @@

namespace AM.Patches;


[HarmonyPatch(typeof(ThingWithComps), nameof(ThingWithComps.DrawAt))] // Corpse DrawAt was removed in 1.5
[HarmonyPatch(typeof(PawnRenderer), nameof(PawnRenderer.ParallelPreRenderPawnAt))] // Corpse DrawAt was removed in 1.5
public static class Patch_Corpse_DrawAt
{
public static readonly Dictionary<Corpse, CorpseInterpolate> Interpolators = new Dictionary<Corpse, CorpseInterpolate>();
public static readonly Dictionary<Pawn, Rot4> OverrideRotations = new Dictionary<Pawn, Rot4>();

public static void Tick()
{
if(GenTicks.TicksGame % (60 * 30) == 0)
{
Interpolators.RemoveAll(p => !p.Key.Spawned);
OverrideRotations.RemoveAll(p => !p.Key.SpawnedOrAnyParentSpawned);
}
}

[HarmonyPriority(Priority.First)]
private static void Prefix(ThingWithComps __instance, ref Vector3 drawLoc)
[HarmonyPriority(Priority.Last)]
private static void Prefix(PawnRenderer __instance, ref Vector3 drawLoc, ref Rot4? rotOverride)
{
if (__instance is not Corpse corpse)
var corpse = __instance.pawn.ParentHolder as Corpse;

if (corpse == null)
return;

DoOffsetLogic(corpse, ref drawLoc);
DoOffsetLogic(corpse, ref drawLoc, ref rotOverride);
}

private static void DoOffsetLogic(Corpse __instance, ref Vector3 drawLoc)
private static void DoOffsetLogic(Corpse corpse, ref Vector3 drawLoc, ref Rot4? rotOverride)
{
// Override facing direction of corpse:
if (OverrideRotations.TryGetValue(corpse.InnerPawn, out var foundRot))
{
rotOverride = foundRot;
}

// Override position and rotation of corpse...

if (Core.Settings.CorpseOffsetMode == CorpseOffsetMode.None)
return;

if (!Interpolators.TryGetValue(__instance, out var found))
if (!Interpolators.TryGetValue(corpse, out var found))
return;

if (!found.Update(ref drawLoc))
Interpolators.Remove(__instance);
Interpolators.Remove(corpse);
}
}

Expand All @@ -53,6 +66,7 @@ public class CorpseInterpolate
public CorpseInterpolate(Corpse corpse, Vector3 startPos)
{
TargetPosition = corpse.DrawPos;
startPos.y = TargetPosition.y;
InitialOffset = startPos - TargetPosition;
CurrentPosition = startPos;
}
Expand Down
22 changes: 22 additions & 0 deletions Source/AnimationMod/Patches/Patch_HediffSet_HasHead.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using HarmonyLib;
using Verse;

namespace AM.Patches;

[HarmonyPatch(typeof(HediffSet), nameof(HediffSet.HasHead), MethodType.Getter)]
public static class Patch_HediffSet_HasHead
{
public static bool? ForcedHasHeadValue;

[HarmonyPriority(Priority.First)]
public static bool Prefix(ref bool __result)
{
if (ForcedHasHeadValue != null)
{
__result = ForcedHasHeadValue.Value;
return false;
}

return true;
}
}
31 changes: 0 additions & 31 deletions Source/AnimationMod/Patches/Patch_PawnRenderer_LayingFacing.cs

This file was deleted.

Loading

0 comments on commit ef81b71

Please sign in to comment.