mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
build
This commit is contained in:
parent
702964a8c2
commit
3828895fd7
5 changed files with 363 additions and 0 deletions
92
Source/Patches/OtherModPatches/HarmonyPatch_AlienRace.cs
Normal file
92
Source/Patches/OtherModPatches/HarmonyPatch_AlienRace.cs
Normal file
|
@ -0,0 +1,92 @@
|
|||
using HarmonyLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
using AlienRace;
|
||||
|
||||
namespace Rimworld_Animations {
|
||||
[HarmonyPatch(typeof(AlienRace.HarmonyPatches), "DrawAddons")]
|
||||
public static class HarmonyPatch_AlienRace {
|
||||
|
||||
|
||||
|
||||
public static void RenderHeadAddonInAnimation(Mesh mesh, Vector3 loc, Quaternion quat, Material mat, bool drawNow, Graphic graphic, AlienPartGenerator.BodyAddon bodyAddon, Vector3 v, float num, Vector3 headOffset, Pawn pawn, PawnRenderFlags renderFlags)
|
||||
{
|
||||
|
||||
CompBodyAnimator pawnAnimator = pawn.TryGetComp<CompBodyAnimator>();
|
||||
if (!renderFlags.FlagSet(PawnRenderFlags.Portrait) && pawnAnimator.isAnimating && (bodyAddon.drawnInBed || bodyAddon.alignWithHead))
|
||||
{
|
||||
|
||||
Quaternion headQuatInAnimation = Quaternion.AngleAxis(pawnAnimator.headAngle, Vector3.up);
|
||||
Rot4 headRotInAnimation = pawnAnimator.headFacing;
|
||||
Vector3 headPositionInAnimation = pawnAnimator.getPawnHeadPosition() - pawn.Drawer.renderer.BaseHeadOffsetAt(pawnAnimator.headFacing).RotatedBy(angle: Mathf.Acos(f: Quaternion.Dot(a: Quaternion.identity, b: headQuatInAnimation)) * 2f * 57.29578f);
|
||||
|
||||
Log.Message(bodyAddon.path + " " + bodyAddon.inFrontOfBody.ToStringSafe());
|
||||
headPositionInAnimation.y += bodyAddon.inFrontOfBody ? 1f : -1f;
|
||||
|
||||
GenDraw.DrawMeshNowOrLater(mesh: graphic.MeshAt(rot: headRotInAnimation), loc: headPositionInAnimation + (bodyAddon.alignWithHead ? headOffset : Vector3.zero) + v.RotatedBy(angle: Mathf.Acos(f: Quaternion.Dot(a: Quaternion.identity, b: headQuatInAnimation)) * 2f * 57.29578f),
|
||||
quat: Quaternion.AngleAxis(angle: num, axis: Vector3.up) * headQuatInAnimation, mat: graphic.MatAt(rot: pawnAnimator.headFacing), drawNow: drawNow);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
GenDraw.DrawMeshNowOrLater(mesh, loc, quat, mat, drawNow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
||||
{
|
||||
List<CodeInstruction> ins = instructions.ToList();
|
||||
for (int i = 0; i < ins.Count; i++)
|
||||
{
|
||||
|
||||
Type[] type = new Type[] { typeof(Mesh), typeof(Vector3), typeof(Quaternion), typeof(Material), typeof(bool) };
|
||||
|
||||
|
||||
if (ins[i].OperandIs(AccessTools.Method(typeof(GenDraw), "DrawMeshNowOrLater", type)))
|
||||
{
|
||||
|
||||
yield return new CodeInstruction(OpCodes.Ldloc, (object)7); //graphic
|
||||
yield return new CodeInstruction(OpCodes.Ldloc, (object)4); //bodyAddon
|
||||
yield return new CodeInstruction(OpCodes.Ldloc, (object)5); //offsetVector/AddonOffset (v)
|
||||
yield return new CodeInstruction(OpCodes.Ldloc, (object)6); //num
|
||||
yield return new CodeInstruction(OpCodes.Ldarg, (object)2); //headOffset
|
||||
yield return new CodeInstruction(OpCodes.Ldarg, (object)3); //pawn
|
||||
yield return new CodeInstruction(OpCodes.Ldarg, (object)0); //renderflags
|
||||
|
||||
yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(HarmonyPatch_AlienRace), "RenderHeadAddonInAnimation"));
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
yield return ins[i];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(PawnGraphicSet), "ResolveApparelGraphics")]
|
||||
public static class HarmonyPatch_ResolveApparelGraphics
|
||||
{
|
||||
public static bool Prefix(ref Pawn ___pawn)
|
||||
{
|
||||
|
||||
if (___pawn.TryGetComp<CompBodyAnimator>() != null && ___pawn.TryGetComp<CompBodyAnimator>().isAnimating)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
87
Source/Patches/OtherModPatches/HarmonyPatch_CSL.cs
Normal file
87
Source/Patches/OtherModPatches/HarmonyPatch_CSL.cs
Normal file
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using HarmonyLib;
|
||||
using rjw;
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
using System.Reflection.Emit;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Rimworld_Animations {
|
||||
[StaticConstructorOnStartup]
|
||||
public static class HarmonyPatch_CSL {
|
||||
static HarmonyPatch_CSL() {
|
||||
try {
|
||||
((Action)(() => {
|
||||
if (LoadedModManager.RunningModsListForReading.Any(x => x.Name == "Children, school and learning")) {
|
||||
|
||||
(new Harmony("rjw")).Patch(AccessTools.Method(AccessTools.TypeByName("Children.PawnRenderer_RenderPawnInternal_Patch"), "RenderPawnInternalScaled"),
|
||||
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_CSL), "Prefix_CSL")),
|
||||
transpiler: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_CSL), "Transpiler_CSL")));
|
||||
}
|
||||
}))();
|
||||
}
|
||||
catch (TypeLoadException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void Prefix_CSL(PawnRenderer __instance, Pawn pawn, ref Vector3 rootLoc, ref float angle, bool renderBody, ref Rot4 bodyFacing, ref Rot4 headFacing, RotDrawMode bodyDrawType, bool portrait, bool headStump, bool invisible) {
|
||||
|
||||
PawnGraphicSet graphics = __instance.graphics;
|
||||
CompBodyAnimator bodyAnim = pawn.TryGetComp<CompBodyAnimator>();
|
||||
|
||||
if (!graphics.AllResolved) {
|
||||
graphics.ResolveAllGraphics();
|
||||
}
|
||||
|
||||
|
||||
if (bodyAnim != null && bodyAnim.isAnimating && !portrait) {
|
||||
bodyAnim.tickGraphics(graphics);
|
||||
pawn.TryGetComp<CompBodyAnimator>().animatePawn(ref rootLoc, ref angle, ref bodyFacing, ref headFacing);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<CodeInstruction> Transpiler_CSL(IEnumerable<CodeInstruction> instructions) {
|
||||
|
||||
MethodInfo drawMeshNowOrLater = AccessTools.Method(typeof(GenDraw), "DrawMeshNowOrLater");
|
||||
FieldInfo headGraphic = AccessTools.Field(typeof(PawnGraphicSet), "headGraphic");
|
||||
|
||||
|
||||
List<CodeInstruction> codes = instructions.ToList();
|
||||
bool forHead = true;
|
||||
for (int i = 0; i < codes.Count(); i++) {
|
||||
|
||||
//Instead of calling drawmeshnoworlater, add pawn to the stack and call my special static method
|
||||
if (codes[i].OperandIs(drawMeshNowOrLater) && forHead) {
|
||||
|
||||
yield return new CodeInstruction(OpCodes.Ldarg_0);
|
||||
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.DeclaredField(typeof(PawnRenderer), "pawn"));
|
||||
yield return new CodeInstruction(OpCodes.Ldarg_2);
|
||||
yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(AnimationUtility), nameof(AnimationUtility.RenderPawnHeadMeshInAnimation), new Type[] { typeof(Mesh), typeof(Vector3), typeof(Quaternion), typeof(Material), typeof(bool), typeof(Pawn), typeof(float) }));
|
||||
|
||||
}
|
||||
//checking for if(graphics.headGraphic != null)
|
||||
else if (codes[i].opcode == OpCodes.Ldfld && codes[i].OperandIs(headGraphic)) {
|
||||
forHead = true;
|
||||
yield return codes[i];
|
||||
}
|
||||
//checking for if(renderbody)
|
||||
else if (codes[i].opcode == OpCodes.Ldarg_3) {
|
||||
forHead = false;
|
||||
yield return codes[i];
|
||||
}
|
||||
else {
|
||||
yield return codes[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}*/
|
|
@ -0,0 +1,29 @@
|
|||
using HarmonyLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace Rimworld_Animations {
|
||||
class HarmonyPatch_DontShaveYourHead {
|
||||
|
||||
[StaticConstructorOnStartup]
|
||||
public static class Patch_DontShaveYourHead {
|
||||
|
||||
static Patch_DontShaveYourHead() {
|
||||
try {
|
||||
((Action)(() =>
|
||||
{
|
||||
if (LoadedModManager.RunningModsListForReading.Any(x => x.Name == "Don't Shave Your Head 1.0")) {
|
||||
(new Harmony("rjw")).Patch(AccessTools.Method(AccessTools.TypeByName("DontShaveYourHead.Harmony_PawnRenderer"), "DrawHairReroute"), //typeof(ShowHair.Patch_PawnRenderer_RenderPawnInternal), nameof(ShowHair.Patch_PawnRenderer_RenderPawnInternal.Postfix)),
|
||||
transpiler: new HarmonyMethod(AccessTools.Method(typeof(Patch_ShowHairWithHats), "Transpiler")));
|
||||
}
|
||||
}))();
|
||||
}
|
||||
catch (TypeLoadException ex) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
104
Source/Patches/OtherModPatches/HarmonyPatch_FacialAnimation.cs
Normal file
104
Source/Patches/OtherModPatches/HarmonyPatch_FacialAnimation.cs
Normal file
|
@ -0,0 +1,104 @@
|
|||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
|
||||
namespace Rimworld_Animations {
|
||||
[StaticConstructorOnStartup]
|
||||
public static class Patch_FacialAnimation {
|
||||
|
||||
static Patch_FacialAnimation() {
|
||||
try {
|
||||
((Action)(() => {
|
||||
if (LoadedModManager.RunningModsListForReading.Any(x => x.Name == "[NL] Facial Animation - WIP")) {
|
||||
(new Harmony("rjw")).Patch(AccessTools.Method(AccessTools.TypeByName("FacialAnimation.DrawFaceGraphicsComp"), "DrawGraphics"),
|
||||
prefix: new HarmonyMethod(AccessTools.Method(typeof(Patch_FacialAnimation), "Prefix")));
|
||||
}
|
||||
}))();
|
||||
}
|
||||
catch (TypeLoadException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Prefix(ref Pawn ___pawn, ref Rot4 headFacing, ref Vector3 headOrigin, ref Quaternion quaternion, ref bool portrait) {
|
||||
|
||||
CompBodyAnimator bodyAnim = ___pawn.TryGetComp<CompBodyAnimator>();
|
||||
|
||||
if (bodyAnim != null && bodyAnim.isAnimating && !portrait) {
|
||||
|
||||
headFacing = bodyAnim.headFacing;
|
||||
headOrigin = new Vector3(bodyAnim.getPawnHeadPosition().x, headOrigin.y, bodyAnim.getPawnHeadPosition().z);
|
||||
quaternion = Quaternion.AngleAxis(bodyAnim.headAngle, Vector3.up);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
public static List<string> rjwLovinDefNames = new List<string>{
|
||||
"Lovin",
|
||||
"Quickie",
|
||||
"GettingQuickie",
|
||||
"JoinInBed",
|
||||
"JoinInBedAnimation",
|
||||
"GettinLovedAnimation",
|
||||
"GettinLoved",
|
||||
"GettinLicked",
|
||||
"GettinSucked",
|
||||
"GettinRaped",
|
||||
"ViolateCorpse",
|
||||
"RJW_Masturbate",
|
||||
"GettinBred",
|
||||
"Breed",
|
||||
"RJW_Mate",
|
||||
"Bestiality",
|
||||
"BestialityForFemale",
|
||||
"StruggleInBondageGear",
|
||||
"WhoreIsServingVisitors",
|
||||
"UseFM"
|
||||
};
|
||||
|
||||
public static List<string> rjwRapeDefNames = new List<string> {
|
||||
"RapeComfortPawn",
|
||||
"RandomRape",
|
||||
"RapeEnemy"
|
||||
};
|
||||
|
||||
public static bool Prefix_IsSameA(JobDef job, string ___jobDef, ref bool __result) {
|
||||
|
||||
if(___jobDef != null && ___jobDef == "Lovin" && job?.defName != null && rjwLovinDefNames.Contains(job?.defName)) {
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
else if (___jobDef != null && ___jobDef == "Wait_Combat" && job?.defName != null && rjwRapeDefNames.Contains(job?.defName)) {
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool Prefix_IsSameB(string jobName, string ___jobDef, ref bool __result) {
|
||||
|
||||
if (___jobDef != null && ___jobDef == "Lovin" && jobName != null && rjwLovinDefNames.Contains(jobName)) {
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
if (___jobDef != null && ___jobDef == "Wait_Combat" && jobName != null && rjwRapeDefNames.Contains(jobName)) {
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
using HarmonyLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using Verse;
|
||||
|
||||
namespace Rimworld_Animations {
|
||||
[StaticConstructorOnStartup]
|
||||
public static class Patch_ShowHairWithHats {
|
||||
|
||||
static Patch_ShowHairWithHats() {
|
||||
try {
|
||||
((Action)(() =>
|
||||
{
|
||||
if (LoadedModManager.RunningModsListForReading.Any(x => x.Name == "[KV] Show Hair With Hats or Hide All Hats - 1.1")) {
|
||||
(new Harmony("rjw")).Patch(AccessTools.Method(AccessTools.TypeByName("ShowHair.Patch_PawnRenderer_RenderPawnInternal"), "Postfix"), //typeof(ShowHair.Patch_PawnRenderer_RenderPawnInternal), nameof(ShowHair.Patch_PawnRenderer_RenderPawnInternal.Postfix)),
|
||||
transpiler: new HarmonyMethod(AccessTools.Method(typeof(Patch_ShowHairWithHats), "Transpiler")));
|
||||
}
|
||||
}))();
|
||||
}
|
||||
catch (TypeLoadException ex) { }
|
||||
}
|
||||
|
||||
|
||||
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) {
|
||||
|
||||
MethodInfo drawMeshNowOrLater = AccessTools.Method(typeof(GenDraw), "DrawMeshNowOrLater");
|
||||
|
||||
List<CodeInstruction> codes = instructions.ToList();
|
||||
for (int i = 0; i < codes.Count(); i++) {
|
||||
|
||||
//Instead of calling drawmeshnoworlater, add pawn to the stack and call my special static method
|
||||
if (codes[i].OperandIs(drawMeshNowOrLater)) {
|
||||
|
||||
yield return new CodeInstruction(OpCodes.Ldarg_0);
|
||||
yield return new CodeInstruction(OpCodes.Ldfld, AccessTools.DeclaredField(typeof(PawnRenderer), "pawn"));
|
||||
yield return new CodeInstruction(OpCodes.Call, AccessTools.DeclaredMethod(typeof(AnimationUtility), nameof(AnimationUtility.RenderPawnHeadMeshInAnimation), new Type[] { typeof(Mesh), typeof(Vector3), typeof(Quaternion), typeof(Material), typeof(bool), typeof(Pawn) }));
|
||||
|
||||
}
|
||||
else {
|
||||
yield return codes[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue