@@ -327,7 +327,7 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
327
327
328
328
var shadowCaster = ( worldObject . StaticFlags & ( uint ) StaticFlag . AnyShadow ) != 0 || viewer . Settings . ShadowAllShapes ;
329
329
var animated = ( worldObject . StaticFlags & ( uint ) StaticFlag . Animate ) != 0 ;
330
- var isAnalogClock = GetClockType ( worldObject . FileName ) == ClockType . Analog ;
330
+ var isAnimatedClock = false ; //Declare and preset shape is not an animated clock
331
331
var global = ( worldObject is TrackObj ) || ( worldObject is HazardObj ) || ( worldObject . StaticFlags & ( uint ) StaticFlag . Global ) != 0 ;
332
332
333
333
// TransferObj have a FileName but it is not a shape, so we need to avoid sanity-checking it as if it was.
@@ -480,7 +480,28 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
480
480
}
481
481
else if ( worldObject . GetType ( ) == typeof ( StaticObj ) )
482
482
{
483
- if ( isAnalogClock )
483
+ isAnimatedClock = false ; //Preset
484
+ // preTestShape for lookup if it is an animated clock shape with subobjects named as clock hands
485
+ StaticShape preTestShape = ( new StaticShape ( viewer , shapeFilePath , worldMatrix , shadowCaster ? ShapeFlags . ShadowCaster : ShapeFlags . None ) ) ;
486
+ if ( preTestShape . SharedShape . Animations != null ) // shape has an Animation at all
487
+ {
488
+ if ( preTestShape . SharedShape . Animations [ 0 ] . anim_nodes . Count > 1 ) // shape has more than 1 anim node
489
+ {
490
+ //lookup in all anim nodes of the shape for subobjects named as clock hands
491
+ foreach ( var animNodes in preTestShape . SharedShape . Animations [ 0 ] . anim_nodes )
492
+ {
493
+ if ( animNodes . Name . ToLowerInvariant ( ) . IndexOf ( "hand_clock" ) == 6 ) //Shape anim node name contains "hand_clock"
494
+ {
495
+ if ( animNodes . Name . ToLowerInvariant ( ) . IndexOf ( "orts_" ) == 0 ) //Shape anim node name begins with "ORTS_"
496
+ {
497
+ isAnimatedClock = true ; //Shape is animated clock
498
+ break ; //Exit because of find a clock hand subobject
499
+ }
500
+ }
501
+ }
502
+ }
503
+ }
504
+ if ( isAnimatedClock )
484
505
{
485
506
sceneryObjects . Add ( new AnalogClockShape ( viewer , shapeFilePath , worldMatrix , shadowCaster ? ShapeFlags . ShadowCaster : ShapeFlags . None ) ) ;
486
507
}
0 commit comments