예제 #1
0
            public SignalAspectData(Orts.Formats.Msts.SignalType mstsSignalType, Orts.Formats.Msts.SignalDrawState drawStateData)
            {
                if (mstsSignalType.Lights != null)
                {
                    DrawLights = new bool[mstsSignalType.Lights.Count];
                    FlashLights = new bool[mstsSignalType.Lights.Count];
                }
                else
                {
                    DrawLights = null;
                    FlashLights = null;
                }

                if (drawStateData.DrawLights != null)
                {
                    foreach (var drawLight in drawStateData.DrawLights)
                    {
                        if (drawLight.LightIndex < 0 || DrawLights == null || drawLight.LightIndex >= DrawLights.Length)
                            Trace.TraceWarning("Skipped extra draw light {0}", drawLight.LightIndex);
                        else
                        {
                            DrawLights[drawLight.LightIndex] = true;
                            FlashLights[drawLight.LightIndex] = drawLight.Flashing;
                        }
                    }
                }
                SemaphorePos = drawStateData.SemaphorePos;
            }
예제 #2
0
        static IDictionary <string, SignalDrawState> ReadDrawStates(STFReader stf)
        {
            stf.MustMatch("(");
            int count = stf.ReadInt(null);
            Dictionary <string, SignalDrawState> drawStates = new Dictionary <string, SignalDrawState>(count);

            stf.ParseBlock(new STFReader.TokenProcessor[] {
                new STFReader.TokenProcessor("signaldrawstate", () => {
                    if (drawStates.Count >= count)
                    {
                        STFException.TraceWarning(stf, "Skipped extra SignalDrawState");
                    }
                    else
                    {
                        SignalDrawState drawState = new SignalDrawState(stf);
                        if (drawStates.ContainsKey(drawState.Name))
                        {
                            string TempNew = String.Copy("DST");
                            TempNew        = String.Concat(TempNew, drawStates.Count.ToString());
                            drawStates.Add(TempNew, drawState);
                            STFException.TraceInformation(stf, "Duplicate SignalDrawState name \'" + drawState.Name + "\', using name \'" + TempNew + "\' instead");
                        }
                        else
                        {
                            drawStates.Add(drawState.Name, drawState);
                        }
                    }
                }),
            });
            if (drawStates.Count < count)
            {
                STFException.TraceWarning(stf, (count - drawStates.Count).ToString() + " missing SignalDrawState(s)");
            }
            return(drawStates);
        }
예제 #3
0
 /// <summary>
 /// Comparator function for ordering signal draw states
 /// </summary>
 /// <param name="drawStateA">first draw state to compare</param>
 /// <param name="drawStateB">second draw state to compare</param>
 /// <returns>integer describing whether first draw state needs to be sorted before second state (so less than 0, 0, or larger than 0)</returns>
 public static int Comparer(SignalDrawState drawStateA, SignalDrawState drawStateB)
 {
     return((int)drawStateA.Index - (int)drawStateB.Index);
 }