Skip to content

Commit

Permalink
Fix #145: callback animator: check for missing transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyOThan committed Sep 13, 2024
1 parent 9a80631 commit 1a4e82c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 5 additions & 6 deletions RasterPropMonitor/Auxiliary modules/JSICallbackAnimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ public void Load(ConfigNode node, InternalProp thisProp)
}

animationName = node.GetValue(nameof(animationName));
string controlledTransformName = node.GetValue("KcontrolledTransform");

if (animationName != null)
{
Expand All @@ -316,7 +315,7 @@ public void Load(ConfigNode node, InternalProp thisProp)
}
else if (node.HasValue("controlledTransform") && node.HasValue("localRotationStart") && node.HasValue("localRotationEnd"))
{
controlledTransform = JUtil.FindPropTransform(thisProp, node.GetValue("controlledTransform").Trim());
controlledTransform = JUtil.FindPropTransformOrThrow(thisProp, node.GetValue("controlledTransform").Trim());
initialRotation = controlledTransform.localRotation;
if (node.HasValue("longPath"))
{
Expand All @@ -333,23 +332,23 @@ public void Load(ConfigNode node, InternalProp thisProp)
}
else if (node.HasValue("controlledTransform") && node.HasValue("localTranslationStart") && node.HasValue("localTranslationEnd"))
{
controlledTransform = JUtil.FindPropTransform(thisProp, node.GetValue("controlledTransform").Trim());
controlledTransform = JUtil.FindPropTransformOrThrow(thisProp, node.GetValue("controlledTransform").Trim());
initialPosition = controlledTransform.localPosition;
vectorStart = ConfigNode.ParseVector3(node.GetValue("localTranslationStart"));
vectorEnd = ConfigNode.ParseVector3(node.GetValue("localTranslationEnd"));
mode = Mode.Translation;
}
else if (node.HasValue("controlledTransform") && node.HasValue("localScaleStart") && node.HasValue("localScaleEnd"))
{
controlledTransform = JUtil.FindPropTransform(thisProp, node.GetValue("controlledTransform").Trim());
controlledTransform = JUtil.FindPropTransformOrThrow(thisProp, node.GetValue("controlledTransform").Trim());
initialScale = controlledTransform.localScale;
vectorStart = ConfigNode.ParseVector3(node.GetValue("localScaleStart"));
vectorEnd = ConfigNode.ParseVector3(node.GetValue("localScaleEnd"));
mode = Mode.Scale;
}
else if (node.HasValue("controlledTransform") && node.HasValue("textureLayers") && node.HasValue("textureShiftStart") && node.HasValue("textureShiftEnd"))
{
controlledTransform = JUtil.FindPropTransform(thisProp, node.GetValue("controlledTransform").Trim());
controlledTransform = JUtil.FindPropTransformOrThrow(thisProp, node.GetValue("controlledTransform").Trim());
var textureLayers = node.GetValue("textureLayers").Split(',');
for (int i = 0; i < textureLayers.Length; ++i)
{
Expand All @@ -363,7 +362,7 @@ public void Load(ConfigNode node, InternalProp thisProp)
}
else if (node.HasValue("controlledTransform") && node.HasValue("textureLayers") && node.HasValue("textureScaleStart") && node.HasValue("textureScaleEnd"))
{
controlledTransform = JUtil.FindPropTransform(thisProp, node.GetValue("controlledTransform").Trim());
controlledTransform = JUtil.FindPropTransformOrThrow(thisProp, node.GetValue("controlledTransform").Trim());
var textureLayers = node.GetValue("textureLayers").Split(',');
for (int i = 0; i < textureLayers.Length; ++i)
{
Expand Down
10 changes: 10 additions & 0 deletions RasterPropMonitor/Core/UtilityFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1582,6 +1582,16 @@ internal static Transform FindPropTransform(InternalProp prop, string nameOrPath
}
}

internal static Transform FindPropTransformOrThrow(InternalProp prop, string nameOrPath)
{
Transform result = FindPropTransform(prop, nameOrPath);
if (result == null)
{
throw new ArgumentException($"could not find transform '{nameOrPath}' in prop {prop.propName}");
}
return result;
}

internal static Transform FindInternalTransform(InternalModel model, string nameOrPath)
{
if (nameOrPath.IndexOf('/') == -1)
Expand Down

0 comments on commit 1a4e82c

Please sign in to comment.