mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
Fixing texture path issues
This commit is contained in:
parent
3cc7985515
commit
bbc5effe88
5 changed files with 34 additions and 22 deletions
Binary file not shown.
|
@ -41,7 +41,9 @@ namespace Rimworld_Animations
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* no longer needed; taken care of by graphic variants
|
||||
*
|
||||
// For changing texture path of thing to variant
|
||||
[HarmonyPatch(typeof(PawnRenderNode), "TexPathFor")]
|
||||
public static class HarmonyPatch_PawnRenderNode2
|
||||
|
@ -54,4 +56,6 @@ namespace Rimworld_Animations
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace Rimworld_Animations
|
|||
public class PawnRenderNode_BodyTypeVariants : PawnRenderNode_GraphicVariants
|
||||
{
|
||||
|
||||
private BodyTypeDef bodyType;
|
||||
protected new PawnRenderNodeProperties_BodyTypeVariants props;
|
||||
|
||||
public PawnRenderNode_BodyTypeVariants(Pawn pawn, PawnRenderNodeProperties props, PawnRenderTree tree) : base(pawn, props, tree)
|
||||
|
@ -25,30 +26,35 @@ namespace Rimworld_Animations
|
|||
|
||||
if (props.bodyTypeVariantsDef == null)
|
||||
{
|
||||
Log.ErrorOnce("[Anims] Error: Tried to use BodyTypeVariants node, but bodyTypeVariants weren't given", 211341349);
|
||||
Log.Error("[Anims] Error: Tried to use BodyTypeVariants node, but bodyTypeVariants weren't given");
|
||||
return null;
|
||||
}
|
||||
|
||||
//for each different hediff-based texpathvariants,
|
||||
foreach (TexPathVariants_BodyType texPathVariant_BodyType in props.bodyTypeVariantsDef)
|
||||
{
|
||||
if (pawn.story.bodyType == texPathVariant_BodyType.bodyType)
|
||||
if (pawn.story?.bodyType == texPathVariant_BodyType.bodyType)
|
||||
{
|
||||
//return that specific variant
|
||||
bodyType = texPathVariant_BodyType.bodyType;
|
||||
return GenerateVariants(pawn, texPathVariant_BodyType.texPathVariantsDef);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//otherwise just use default
|
||||
return base.GraphicVariantsFor(pawn);
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
protected override void EnsureMaterialsInitialized()
|
||||
{
|
||||
if (variants == null
|
||||
|| this.tree.pawn.story?.bodyType != bodyType)
|
||||
variants = GraphicVariantsFor(this.tree.pawn);
|
||||
|
||||
//call this in case variants wasn't set, and there is no graphic bodytype variants appropriate; it'll set variants based on default
|
||||
base.EnsureMaterialsInitialized();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Rimworld_Animations
|
|||
|
||||
if (props.hediffVariants == null)
|
||||
{
|
||||
Log.ErrorOnce("[Anims] Error: Tried to use GraphicHediffVariants node, but hediffVariants weren't given", 231321349);
|
||||
Log.Error("[Anims] Error: Tried to use GraphicHediffVariants node, but hediffVariants weren't given");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -47,9 +47,9 @@ namespace Rimworld_Animations
|
|||
|
||||
}
|
||||
|
||||
//otherwise just use default
|
||||
//there is no graphic hediff variants appropriate
|
||||
curHediff = null;
|
||||
return base.GraphicVariantsFor(pawn);
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
@ -60,9 +60,12 @@ namespace Rimworld_Animations
|
|||
(this.tree.pawn.health?.hediffSet?.hediffs is List<Hediff> hediffs
|
||||
&& hediffs.Any((Hediff hediff) => hediff.def == curHediff)))
|
||||
{
|
||||
//redo graphicvariantsfor
|
||||
//do graphicvariantsfor
|
||||
variants = GraphicVariantsFor(this.tree.pawn);
|
||||
}
|
||||
|
||||
//call this in case variants wasn't set, and there is no graphic hediff variants appropriate; it'll set variants based on default
|
||||
base.EnsureMaterialsInitialized();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,17 +30,6 @@ namespace Rimworld_Animations
|
|||
|
||||
}
|
||||
|
||||
protected override void EnsureMaterialsInitialized()
|
||||
{
|
||||
|
||||
if (variants == null)
|
||||
{
|
||||
variants = GraphicVariantsFor(this.tree.pawn);
|
||||
}
|
||||
|
||||
base.EnsureMaterialsInitialized();
|
||||
}
|
||||
|
||||
protected virtual Dictionary<int, Graphic> GraphicVariantsFor(Pawn pawn)
|
||||
{
|
||||
|
||||
|
@ -53,6 +42,18 @@ namespace Rimworld_Animations
|
|||
|
||||
}
|
||||
|
||||
protected override void EnsureMaterialsInitialized()
|
||||
{
|
||||
|
||||
if (variants == null)
|
||||
{
|
||||
variants = GraphicVariantsFor(this.tree.pawn);
|
||||
}
|
||||
|
||||
base.EnsureMaterialsInitialized();
|
||||
}
|
||||
|
||||
|
||||
//used by all, including base classes, to create texPathVariants for pawn
|
||||
protected Dictionary<int, Graphic> GenerateVariants(Pawn pawn, TexPathVariantsDef texPathVariants)
|
||||
{
|
||||
|
@ -74,7 +75,5 @@ namespace Rimworld_Animations
|
|||
return variantGraphics;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue