Better error handling for missing graphic variants, missing offsets
This commit is contained in:
parent
67ff59ed80
commit
c33072614b
Binary file not shown.
|
@ -98,7 +98,6 @@
|
|||
</keyframes>
|
||||
</value>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<key>RenderNodeTag_Xray_Inside</key>
|
||||
<value>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<Rimworld_Animations.GroupAnimationDef>
|
||||
<defName>TestGroupAnimation1</defName>
|
||||
<numActors>2</numActors>
|
||||
<canMirror>True</canMirror>
|
||||
<animationStages>
|
||||
<li Class="Rimworld_Animations.AnimationStage_LoopRandomSelectChance">
|
||||
<loops>10</loops>
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace Rimworld_Animations
|
|||
{
|
||||
//element at or default to stop errors
|
||||
if (offsetDefs == null) return null;
|
||||
if ((actor + reorder) % numActors >= offsetDefs.Count) return null;
|
||||
return offsetDefs[(actor + reorder) % numActors].FindOffset(pawn);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,10 +153,8 @@ namespace Rimworld_Animations {
|
|||
{
|
||||
|
||||
PawnRenderNodeProperties props = animationProp.animPropProperties;
|
||||
Log.Message("Texpath of prop:" + props.texPath);
|
||||
if (props.texPath.NullOrEmpty())
|
||||
{
|
||||
Log.Message("Setting default texture");
|
||||
props.texPath = "AnimationProps/Banana/Banana";
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace Rimworld_Animations
|
|||
|
||||
public override bool CanDrawNow(PawnRenderNode node, PawnDrawParms parms)
|
||||
{
|
||||
if (!base.CanDrawNow(node, parms)) return false;
|
||||
|
||||
if (parms.Portrait) return false;
|
||||
|
||||
//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)
|
||||
{
|
||||
|
@ -37,7 +39,11 @@ namespace Rimworld_Animations
|
|||
//and texpathvariant is set
|
||||
&& 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
|
||||
|
@ -47,6 +53,9 @@ namespace Rimworld_Animations
|
|||
public virtual Material GetMaterialVariant(PawnRenderNode_GraphicVariants node, PawnDrawParms parms, int variant)
|
||||
{
|
||||
Material material = node.getGraphicVariant(variant).NodeGetMat(parms);
|
||||
|
||||
if (material == null) return null;
|
||||
|
||||
if (material != null && !parms.Portrait && parms.flags.FlagSet(PawnRenderFlags.Invisible))
|
||||
{
|
||||
material = InvisibilityMatPool.GetInvisibleMat(material);
|
||||
|
|
|
@ -16,6 +16,12 @@ namespace Rimworld_Animations
|
|||
|
||||
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];
|
||||
}
|
||||
|
||||
|
@ -48,6 +54,8 @@ namespace Rimworld_Animations
|
|||
|
||||
Dictionary<int, Graphic> variantGraphics = new Dictionary<int, Graphic>();
|
||||
|
||||
if (texPathVariants == null) return variantGraphics;
|
||||
|
||||
//for each graphic variant
|
||||
for (int i = 0; i < texPathVariants.variants.Count; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue