mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
Better error handling for missing graphic variants, missing offsets
This commit is contained in:
parent
67ff59ed80
commit
c33072614b
7 changed files with 21 additions and 5 deletions
Binary file not shown.
|
@ -98,7 +98,6 @@
|
||||||
</keyframes>
|
</keyframes>
|
||||||
</value>
|
</value>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<key>RenderNodeTag_Xray_Inside</key>
|
<key>RenderNodeTag_Xray_Inside</key>
|
||||||
<value>
|
<value>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<Rimworld_Animations.GroupAnimationDef>
|
<Rimworld_Animations.GroupAnimationDef>
|
||||||
<defName>TestGroupAnimation1</defName>
|
<defName>TestGroupAnimation1</defName>
|
||||||
<numActors>2</numActors>
|
<numActors>2</numActors>
|
||||||
|
<canMirror>True</canMirror>
|
||||||
<animationStages>
|
<animationStages>
|
||||||
<li Class="Rimworld_Animations.AnimationStage_LoopRandomSelectChance">
|
<li Class="Rimworld_Animations.AnimationStage_LoopRandomSelectChance">
|
||||||
<loops>10</loops>
|
<loops>10</loops>
|
||||||
|
|
|
@ -55,6 +55,7 @@ namespace Rimworld_Animations
|
||||||
{
|
{
|
||||||
//element at or default to stop errors
|
//element at or default to stop errors
|
||||||
if (offsetDefs == null) return null;
|
if (offsetDefs == null) return null;
|
||||||
|
if ((actor + reorder) % numActors >= offsetDefs.Count) return null;
|
||||||
return offsetDefs[(actor + reorder) % numActors].FindOffset(pawn);
|
return offsetDefs[(actor + reorder) % numActors].FindOffset(pawn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,10 +153,8 @@ namespace Rimworld_Animations {
|
||||||
{
|
{
|
||||||
|
|
||||||
PawnRenderNodeProperties props = animationProp.animPropProperties;
|
PawnRenderNodeProperties props = animationProp.animPropProperties;
|
||||||
Log.Message("Texpath of prop:" + props.texPath);
|
|
||||||
if (props.texPath.NullOrEmpty())
|
if (props.texPath.NullOrEmpty())
|
||||||
{
|
{
|
||||||
Log.Message("Setting default texture");
|
|
||||||
props.texPath = "AnimationProps/Banana/Banana";
|
props.texPath = "AnimationProps/Banana/Banana";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ namespace Rimworld_Animations
|
||||||
|
|
||||||
public override bool CanDrawNow(PawnRenderNode node, PawnDrawParms parms)
|
public override bool CanDrawNow(PawnRenderNode node, PawnDrawParms parms)
|
||||||
{
|
{
|
||||||
|
if (!base.CanDrawNow(node, parms)) return false;
|
||||||
|
|
||||||
if (parms.Portrait) return false;
|
if (parms.Portrait) return false;
|
||||||
|
|
||||||
//don't draw if not visible at tick
|
//don't draw if not visible at tick
|
||||||
|
@ -23,7 +25,7 @@ namespace Rimworld_Animations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return base.CanDrawNow(node, parms);
|
return true;
|
||||||
}
|
}
|
||||||
protected override Material GetMaterial(PawnRenderNode node, PawnDrawParms parms)
|
protected override Material GetMaterial(PawnRenderNode node, PawnDrawParms parms)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +39,11 @@ namespace Rimworld_Animations
|
||||||
//and texpathvariant is set
|
//and texpathvariant is set
|
||||||
&& extendedAnimWorker.TexPathVariantAtTick(node.tree.AnimationTick) != null)
|
&& extendedAnimWorker.TexPathVariantAtTick(node.tree.AnimationTick) != null)
|
||||||
{
|
{
|
||||||
return GetMaterialVariant(nodeWithGraphicVariants, parms, (int)extendedAnimWorker.TexPathVariantAtTick(node.tree.AnimationTick));
|
Material materialVariant = GetMaterialVariant(nodeWithGraphicVariants, parms, (int)extendedAnimWorker.TexPathVariantAtTick(node.tree.AnimationTick));
|
||||||
|
if (materialVariant != null) {
|
||||||
|
return materialVariant;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//otherwise return original texture
|
//otherwise return original texture
|
||||||
|
@ -47,6 +53,9 @@ namespace Rimworld_Animations
|
||||||
public virtual Material GetMaterialVariant(PawnRenderNode_GraphicVariants node, PawnDrawParms parms, int variant)
|
public virtual Material GetMaterialVariant(PawnRenderNode_GraphicVariants node, PawnDrawParms parms, int variant)
|
||||||
{
|
{
|
||||||
Material material = node.getGraphicVariant(variant).NodeGetMat(parms);
|
Material material = node.getGraphicVariant(variant).NodeGetMat(parms);
|
||||||
|
|
||||||
|
if (material == null) return null;
|
||||||
|
|
||||||
if (material != null && !parms.Portrait && parms.flags.FlagSet(PawnRenderFlags.Invisible))
|
if (material != null && !parms.Portrait && parms.flags.FlagSet(PawnRenderFlags.Invisible))
|
||||||
{
|
{
|
||||||
material = InvisibilityMatPool.GetInvisibleMat(material);
|
material = InvisibilityMatPool.GetInvisibleMat(material);
|
||||||
|
|
|
@ -16,6 +16,12 @@ namespace Rimworld_Animations
|
||||||
|
|
||||||
public Graphic getGraphicVariant(int variant)
|
public Graphic getGraphicVariant(int variant)
|
||||||
{
|
{
|
||||||
|
if (!variants.ContainsKey(variant))
|
||||||
|
{
|
||||||
|
Log.ErrorOnce("[Anims] Error: tried to get key from variants that doesn't exist; key = " + variant, 2043428111);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return variants[variant];
|
return variants[variant];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +54,8 @@ namespace Rimworld_Animations
|
||||||
|
|
||||||
Dictionary<int, Graphic> variantGraphics = new Dictionary<int, Graphic>();
|
Dictionary<int, Graphic> variantGraphics = new Dictionary<int, Graphic>();
|
||||||
|
|
||||||
|
if (texPathVariants == null) return variantGraphics;
|
||||||
|
|
||||||
//for each graphic variant
|
//for each graphic variant
|
||||||
for (int i = 0; i < texPathVariants.variants.Count; i++)
|
for (int i = 0; i < texPathVariants.variants.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue