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; }
public SignalTypeData(Viewer viewer, Orts.Formats.Msts.SignalType mstsSignalType) { if (!viewer.SIGCFG.LightTextures.ContainsKey(mstsSignalType.LightTextureName)) { Trace.TraceWarning("Skipped invalid light texture {1} for signal type {0}", mstsSignalType.Name, mstsSignalType.LightTextureName); Material = viewer.MaterialManager.Load("missing-signal-light"); #if DEBUG_SIGNAL_SHAPES Type = SignalTypeDataType.Normal; #endif FlashTimeOn = 1; FlashTimeTotal = 2; } else { var mstsLightTexture = viewer.SIGCFG.LightTextures[mstsSignalType.LightTextureName]; Material = viewer.MaterialManager.Load("SignalLight", Helpers.GetRouteTextureFile(viewer.Simulator, Helpers.TextureFlags.None, mstsLightTexture.TextureFile)); GlowMaterial = viewer.MaterialManager.Load("SignalLightGlow"); #if DEBUG_SIGNAL_SHAPES Type = (SignalTypeDataType)mstsSignalType.FnType; #endif if (mstsSignalType.Lights != null) { // Set up some heuristic glow values from the available data: // Typical electric light is 3.0/5.0 // Semaphore is 0.0/5.0 // Theatre box is 0.0/0.0 var glowDay = 3.0f; var glowNight = 5.0f; if (mstsSignalType.Semaphore) { glowDay = 0.0f; } if (mstsSignalType.FnType == SignalType.FnTypes.Info || mstsSignalType.FnType == SignalType.FnTypes.Shunting) // These are good at identifying theatre boxes. { glowDay = glowNight = 0.0f; } foreach (var mstsSignalLight in mstsSignalType.Lights) { if (!viewer.SIGCFG.LightsTable.ContainsKey(mstsSignalLight.Name)) { Trace.TraceWarning("Skipped invalid light {1} for signal type {0}", mstsSignalType.Name, mstsSignalLight.Name); continue; } var mstsLight = viewer.SIGCFG.LightsTable[mstsSignalLight.Name]; Lights.Add(new SignalLightPrimitive(viewer, new Vector3(-mstsSignalLight.X, mstsSignalLight.Y, mstsSignalLight.Z), mstsSignalLight.Radius, new Color(mstsLight.r, mstsLight.g, mstsLight.b, mstsLight.a), glowDay, glowNight, mstsLightTexture.u0, mstsLightTexture.v0, mstsLightTexture.u1, mstsLightTexture.v1)); LightsSemaphoreChange.Add(mstsSignalLight.SemaphoreChange); } } foreach (KeyValuePair <string, Orts.Formats.Msts.SignalDrawState> sdrawstate in mstsSignalType.DrawStates) { DrawAspects.Add(sdrawstate.Value.Index, new SignalAspectData(mstsSignalType, sdrawstate.Value)); } FlashTimeOn = mstsSignalType.FlashTimeOn; FlashTimeTotal = mstsSignalType.FlashTimeOn + mstsSignalType.FlashTimeOff; Semaphore = mstsSignalType.Semaphore; SemaphoreAnimationTime = mstsSignalType.SemaphoreInfo; } }