Skip to content

Commit ce89a06

Browse files
author
Chris Jakeman
committed
LINQ for simpler syntax
1 parent 62a1c27 commit ce89a06

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Source/RunActivity/Viewer3D/Scenery.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -482,14 +482,12 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
482482
{
483483
// preTestShape for lookup if it is an animated clock shape with subobjects named as clock hands
484484
StaticShape preTestShape = (new StaticShape(viewer, shapeFilePath, worldMatrix, shadowCaster ? ShapeFlags.ShadowCaster : ShapeFlags.None));
485-
var isAnimatedClock = false;
486-
if (preTestShape.SharedShape.Animations != null
487-
&& preTestShape.SharedShape.Animations.Count > 0) // Since animations( 0 ) is a valid entry in *.s files
488-
// and is included by MSTSexporter for Blender 2.8+ Release V4.0 or older
489-
{
490-
var animNodes = preTestShape.SharedShape.Animations[0]?.anim_nodes ?? new List<anim_node>();
491-
isAnimatedClock = animNodes.Exists(node => Regex.IsMatch(node.Name, @"^orts_[hmsc]hand_clock", RegexOptions.IgnoreCase));
492-
}
485+
486+
// FirstOrDefault() checks for "animations( 0 )" as this is a valid entry in *.s files
487+
// and is included by MSTSexporter for Blender 2.8+ Release V4.0 or older
488+
var animNodes = preTestShape.SharedShape.Animations?.FirstOrDefault()?.anim_nodes ?? new List<anim_node>();
489+
490+
var isAnimatedClock = animNodes.Exists(node => Regex.IsMatch(node.Name, @"^orts_[hmsc]hand_clock", RegexOptions.IgnoreCase));
493491
if (isAnimatedClock)
494492
{
495493
sceneryObjects.Add(new AnalogClockShape(viewer, shapeFilePath, worldMatrix, shadowCaster ? ShapeFlags.ShadowCaster : ShapeFlags.None));

0 commit comments

Comments
 (0)