@@ -338,6 +338,8 @@ public LightCondition(LightCondition condition, bool reverse)
338338 public class Light
339339 {
340340 public int Index ;
341+ public int ShapeIndex = - 1 ;
342+ public string ShapeHierarchy ;
341343 public LightType Type ;
342344 public bool Cycle ;
343345 public float FadeIn ;
@@ -369,12 +371,16 @@ public Light(int index, STFReader stf)
369371 if ( States . Count < count )
370372 STFException . TraceWarning ( stf , ( count - States . Count ) . ToString ( ) + " missing State(s)" ) ;
371373 } ) ,
374+ new STFReader . TokenProcessor ( "shapeindex" , ( ) => { ShapeIndex = stf . ReadIntBlock ( null ) ; } ) ,
375+ new STFReader . TokenProcessor ( "shapehierarchy" , ( ) => { ShapeHierarchy = stf . ReadStringBlock ( null ) . ToUpper ( ) ; } ) ,
372376 } ) ;
373377 }
374378
375379 public Light ( Light light , bool reverse )
376380 {
377381 Index = light . Index ;
382+ ShapeIndex = light . ShapeIndex ;
383+ ShapeHierarchy = light . ShapeHierarchy ;
378384 Type = light . Type ;
379385 Cycle = light . Cycle ;
380386 FadeIn = light . FadeIn ;
@@ -396,6 +402,11 @@ public class LightCollection
396402 {
397403 public List < Light > Lights = new List < Light > ( ) ;
398404
405+ // Array of bools, one per type of condition in the same order as presented in the 'LightCondition' class
406+ // A 'true' indicates all lights in this set ignore the corresponding condition, so we don't need to waste time thinking about it
407+ // Remember to expand this if more conditions are added!
408+ public bool [ ] IgnoredConditions = new bool [ 15 ] ;
409+
399410 public LightCollection ( STFReader stf )
400411 {
401412 stf . MustMatch ( "(" ) ;
@@ -410,6 +421,23 @@ public LightCollection(STFReader stf)
410421 foreach ( var light in Lights . ToArray ( ) )
411422 if ( light . Type == LightType . Cone )
412423 Lights . Add ( new Light ( light , true ) ) ;
424+
425+ // Determine which, if any, conditions are ignored by all conditions of all lights
426+ IgnoredConditions [ 0 ] = Lights . All ( light => light . Conditions . All ( cond => cond . Headlight == LightHeadlightCondition . Ignore ) ) ;
427+ IgnoredConditions [ 1 ] = Lights . All ( light => light . Conditions . All ( cond => cond . Unit == LightUnitCondition . Ignore ) ) ;
428+ IgnoredConditions [ 2 ] = Lights . All ( light => light . Conditions . All ( cond => cond . Penalty == LightPenaltyCondition . Ignore ) ) ;
429+ IgnoredConditions [ 3 ] = Lights . All ( light => light . Conditions . All ( cond => cond . Control == LightControlCondition . Ignore ) ) ;
430+ IgnoredConditions [ 4 ] = Lights . All ( light => light . Conditions . All ( cond => cond . Service == LightServiceCondition . Ignore ) ) ;
431+ IgnoredConditions [ 5 ] = Lights . All ( light => light . Conditions . All ( cond => cond . TimeOfDay == LightTimeOfDayCondition . Ignore ) ) ;
432+ IgnoredConditions [ 6 ] = Lights . All ( light => light . Conditions . All ( cond => cond . Weather == LightWeatherCondition . Ignore ) ) ;
433+ IgnoredConditions [ 7 ] = Lights . All ( light => light . Conditions . All ( cond => cond . Coupling == LightCouplingCondition . Ignore ) ) ;
434+ IgnoredConditions [ 8 ] = Lights . All ( light => light . Conditions . All ( cond => cond . Battery == LightBatteryCondition . Ignore ) ) ;
435+ IgnoredConditions [ 9 ] = Lights . All ( light => light . Conditions . All ( cond => cond . Brake == LightBrakeCondition . Ignore ) ) ;
436+ IgnoredConditions [ 10 ] = Lights . All ( light => light . Conditions . All ( cond => cond . Reverser == LightReverserCondition . Ignore ) ) ;
437+ IgnoredConditions [ 11 ] = Lights . All ( light => light . Conditions . All ( cond => cond . Doors == LightDoorsCondition . Ignore ) ) ;
438+ IgnoredConditions [ 12 ] = Lights . All ( light => light . Conditions . All ( cond => cond . Horn == LightHornCondition . Ignore ) ) ;
439+ IgnoredConditions [ 13 ] = Lights . All ( light => light . Conditions . All ( cond => cond . Bell == LightBellCondition . Ignore ) ) ;
440+ IgnoredConditions [ 14 ] = Lights . All ( light => light . Conditions . All ( cond => cond . MU == LightMUCondition . Ignore ) ) ;
413441 }
414442 }
415443}
0 commit comments