mirror of
https://gitgud.io/AbstractConcept/rimworld-animations-patch.git
synced 2024-08-15 00:43:27 +00:00
v2.0.0
This commit is contained in:
parent
38ec4f86c1
commit
ae95e34137
35 changed files with 242 additions and 612 deletions
|
@ -8,13 +8,31 @@ using Verse;
|
|||
namespace Rimworld_Animations_Patch
|
||||
{
|
||||
[StaticConstructorOnStartup]
|
||||
|
||||
[HarmonyPatch(typeof(ApparelGraphicRecordGetter), "TryGetGraphicApparel")]
|
||||
public static class HarmonyPatch_ApparelGraphicRecordGetter_TryGetGraphicApparel
|
||||
{
|
||||
static bool _checkedForSizedApparel;
|
||||
static bool _isRunningSizedApparel;
|
||||
|
||||
// Not compatible with SizedApparel - running Graphic.Blit on the resized apparel will cause the pawn to turn invisible for one facing
|
||||
public static bool IsRunningSizedApparel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_checkedForSizedApparel == false)
|
||||
{
|
||||
_isRunningSizedApparel = LoadedModManager.RunningModsListForReading.Any(x => x.PackageIdPlayerFacing == "OTYOTY.SizedApparel");
|
||||
_checkedForSizedApparel = true;
|
||||
}
|
||||
|
||||
return _isRunningSizedApparel;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Postfix(ref bool __result, ref Apparel apparel, ref BodyTypeDef bodyType, ref ApparelGraphicRecord rec)
|
||||
{
|
||||
if (__result == false || apparel == null || bodyType == null || rec.graphic == null || ApparelSettings.cropApparel == false)
|
||||
{ return; }
|
||||
if (__result == false || apparel == null || bodyType == null || rec.graphic == null || ApparelSettings.cropApparel == false || IsRunningSizedApparel) return;
|
||||
|
||||
// Get graphic
|
||||
Graphic graphic = rec.graphic;
|
||||
|
@ -23,17 +41,14 @@ namespace Rimworld_Animations_Patch
|
|||
if (apparel.def.apparel.LastLayer == ApparelLayerDefOf.OnSkin && apparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso) && !apparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs))
|
||||
{
|
||||
Dictionary<GraphicRequest, Graphic> allGraphics = Traverse.Create(typeof(GraphicDatabase)).Field("allGraphics").GetValue() as Dictionary<GraphicRequest, Graphic>;
|
||||
GraphicRequest graphicRequest = new GraphicRequest(typeof(Graphic_Multi), graphic.path, ShaderDatabase.CutoutComplex, apparel.def.graphicData.drawSize, apparel.DrawColor, apparel.DrawColor, null, 0, null, "Masks/apparel_shirt_mask_" + bodyType.defName);
|
||||
GraphicRequest graphicRequest = new GraphicRequest(typeof(Graphic_Multi), graphic.path, ShaderDatabase.CutoutComplex, graphic.drawSize, apparel.DrawColor, apparel.DrawColor, null, 0, null, "Masks/apparel_shirt_mask_" + bodyType.defName);
|
||||
|
||||
if (allGraphics.TryGetValue(graphicRequest) == null)
|
||||
{
|
||||
Graphic graphicWithApparelMask = GraphicDatabase.Get<Graphic_Multi>(graphic.path, ShaderDatabase.CutoutComplex, apparel.def.graphicData.drawSize, apparel.DrawColor, apparel.DrawColor, null, "Masks/apparel_shirt_mask_" + bodyType.defName);
|
||||
graphic = GraphicMaskingUtility.ApplyGraphicWithMasks(graphic, graphicWithApparelMask, true);
|
||||
|
||||
//DebugMode.Message("Applying apparel mask: Masks/apparel_shirt_mask_" + bodyType.defName + " to " + apparel.def.defName + " (" + graphic.path + ")");
|
||||
Graphic graphicWithApparelMasks = GraphicDatabase.Get<Graphic_Multi>(graphic.path, ShaderDatabase.CutoutComplex, graphic.drawSize, apparel.DrawColor, apparel.DrawColor, null, "Masks/apparel_shirt_mask_" + bodyType.defName);
|
||||
graphic = GraphicMaskingUtility.ApplyGraphicMasks(graphic, graphicWithApparelMasks, true);
|
||||
|
||||
if (apparel.Wearer != null)
|
||||
{ PortraitsCache.SetDirty(apparel.Wearer); }
|
||||
//DebugMode.Message("Applying apparel mask: Masks/apparel_shirt_mask_" + bodyType.defName + " to " + apparel.def.defName + " (" + graphic.path + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,8 @@ using BabiesAndChildren.api;
|
|||
|
||||
namespace Rimworld_Animations_Patch
|
||||
{
|
||||
[StaticConstructorOnStartup]
|
||||
// To be revisited if BabiesAndChildren is updated
|
||||
/*[StaticConstructorOnStartup]
|
||||
public static class HarmonyPatch_BabiesAndChildren
|
||||
{
|
||||
static HarmonyPatch_BabiesAndChildren()
|
||||
|
@ -45,5 +46,5 @@ namespace Rimworld_Animations_Patch
|
|||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -21,12 +21,14 @@ namespace Rimworld_Animations_Patch
|
|||
if (__instance?.pawn == null)
|
||||
{ return; }
|
||||
|
||||
// Scale delta by body size
|
||||
if (BasicSettings.autoscaleDeltaPos)
|
||||
{
|
||||
__instance.deltaPos.x *= __instance.pawn.RaceProps.baseBodySize;
|
||||
__instance.deltaPos.z *= __instance.pawn.RaceProps.baseBodySize;
|
||||
}
|
||||
|
||||
// In-bed specific animations cause the actors to turn to match its facing
|
||||
if (__instance.pawn.IsInBed(out Building bed) &&
|
||||
__instance.pawn.GetAnimationData().animationDef.actors[__instance.pawn.GetAnimationData().actorID].requiredGenitals.NullOrEmpty() == false &&
|
||||
__instance.pawn.GetAnimationData().animationDef.actors[__instance.pawn.GetAnimationData().actorID].requiredGenitals.Contains("Bed"))
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using RimWorld;
|
||||
using Verse;
|
||||
using Verse.AI;
|
||||
using Rimworld_Animations;
|
||||
using rjw;
|
||||
|
||||
namespace Rimworld_Animations_Patch
|
||||
{
|
||||
[HarmonyPatch(typeof(JobDriver), "GetReport")]
|
||||
public static class HarmonyPatch_JobDriver
|
||||
{
|
||||
public static bool Prefix(JobDriver __instance, ref string __result)
|
||||
{
|
||||
JobDriver_Sex jobdriver = __instance as JobDriver_Sex;
|
||||
|
||||
if (jobdriver != null && jobdriver.pawn != null && jobdriver.pawn.GetAnimationData() != null && jobdriver.Sexprops.isRape == false && jobdriver.Sexprops.isWhoring == false)
|
||||
{
|
||||
LocalTargetInfo a = jobdriver.job.targetA.IsValid ? jobdriver.job.targetA : jobdriver.job.targetQueueA.FirstValid();
|
||||
LocalTargetInfo b = jobdriver.job.targetB.IsValid ? jobdriver.job.targetB : jobdriver.job.targetQueueB.FirstValid();
|
||||
LocalTargetInfo targetC = jobdriver.job.targetC;
|
||||
|
||||
//__result = JobUtility.GetResolvedJobReport(jobdriver.pawn.GetAnimationData().animationDef.label, a, b, targetC);
|
||||
|
||||
//return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
using HarmonyLib;
|
||||
using RimNudeWorld;
|
||||
|
||||
namespace Rimworld_Animations_Patch
|
||||
{
|
||||
/*[StaticConstructorOnStartup]
|
||||
public static class HarmonyPatch_RimNudeWorld
|
||||
{
|
||||
static HarmonyPatch_RimNudeWorld()
|
||||
{
|
||||
try
|
||||
{
|
||||
((Action)(() =>
|
||||
{
|
||||
if (LoadedModManager.RunningModsListForReading.Any(x => x.PackageIdPlayerFacing == "shauaputa.rimnudeworld"))
|
||||
{
|
||||
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(AccessTools.TypeByName("RevealingApparel.HarmonyPatch_DrawAddons"), "Postfix"),
|
||||
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_RimNudeWorld), "Prefix_HarmonyPatch_DrawAddons")));
|
||||
}
|
||||
}))();
|
||||
}
|
||||
catch (TypeLoadException) { }
|
||||
}
|
||||
|
||||
// Patch RimNudeWorld to override the revealing apparel feature; this task is handled by the new apparel settings system
|
||||
public static bool Prefix_HarmonyPatch_DrawAddons()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
|
@ -163,7 +163,7 @@ namespace Rimworld_Animations_Patch
|
|||
if (bodyAddonDatum.alignsWithHead)
|
||||
{ bodyAngle = MathUtility.ClampAngle(animatorComp.headAngle); }
|
||||
|
||||
if (animatorComp.controlGenitalAngle && (addonGraphic.path.Contains("penis") || addonGraphic.path.Contains("Penis")))
|
||||
if (animatorComp.controlGenitalAngle && addonGraphic.path.Contains("penis", StringComparison.OrdinalIgnoreCase))
|
||||
{ bodyAddonAngle = MathUtility.ClampAngle(bodyAddonAngle + (AnimationSettings.controlGenitalRotation ? MathUtility.ClampAngle(animatorComp.genitalAngle) : 0f)); }
|
||||
}
|
||||
|
||||
|
@ -205,30 +205,6 @@ namespace Rimworld_Animations_Patch
|
|||
}
|
||||
}
|
||||
|
||||
// Add-ons
|
||||
if (animatorComp?.isAnimating == true)
|
||||
{
|
||||
//ActorAnimationData actorData = pawn.GetAnimationData();
|
||||
//PawnAnimationClipExt clip = actorData.animationDef.animationStages[actorData.currentStage].animationClips[actorData.actorID] as PawnAnimationClipExt;
|
||||
|
||||
/*foreach (ActorAddon addon in clip.Addons)
|
||||
{
|
||||
actorBodypart = actorBody.GetActorBodyPart(addon.AddonName);
|
||||
if (actorBodypart == null) continue;
|
||||
|
||||
ActorBody anchoringActorBody = actorBodies.GetComponentsInChildren<ActorBody>()?.FirstOrDefault(x => x.actorID == addon.AnchoringActor);
|
||||
Vector3 anchor = PawnUtility.GetBodyPartAnchor(anchoringActorBody, addon.anchorName);
|
||||
|
||||
actorBodypart.transform.position = anchor + new Vector3(addon.PosX.Evaluate(clipPercent), addon.PosZ.Evaluate(clipPercent), 0);
|
||||
actorBodypart.transform.eulerAngles = new Vector3(0, 0, -addon.Rotation.Evaluate(clipPercent));
|
||||
|
||||
actorBodypart.bodyPartRenderer.sortingLayerName = addon.Layer;
|
||||
//actorBodypart.bodyPartRenderer.sprite
|
||||
|
||||
actorBodypart.gameObject.SetActive(addon.Render);
|
||||
}*/
|
||||
}
|
||||
|
||||
// Body addons are sometimes are not appropriately concealed by long hair in portraits, so re-draw the pawn's hair here
|
||||
if (pawn.Drawer.renderer.graphics.headGraphic != null && renderFlags.FlagSet(PawnRenderFlags.Portrait) && BasicSettings.redrawHair)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue