Ejemplo n.º 1
0
        public Light(Light light, bool reverse)
        {
            Index     = light.Index;
            Type      = light.Type;
            Headlight = light.Headlight;
            Unit      = light.Unit;
            Penalty   = light.Penalty;
            Control   = light.Control;
            Service   = light.Service;
            TimeOfDay = light.TimeOfDay;
            Weather   = light.Weather;
            Coupling  = light.Coupling;
            Cycle     = light.Cycle;
            FadeIn    = light.FadeIn;
            FadeOut   = light.FadeOut;
            foreach (var state in light.States)
            {
                States.Add(new LightState(state, reverse));
            }

            if (reverse)
            {
                if (Unit == LightUnitCondition.First)
                {
                    Unit = LightUnitCondition.FirstRev;
                }
                else if (Unit == LightUnitCondition.Last)
                {
                    Unit = LightUnitCondition.LastRev;
                }
            }
        }
Ejemplo n.º 2
0
 public Light(int index, STFReader stf)
 {
     Index = index;
     stf.MustMatch("(");
     stf.ParseBlock(new[] {
         new STFReader.TokenProcessor("type", () => { Type = (LightType)stf.ReadIntBlock(null); }),
         new STFReader.TokenProcessor("conditions", () => { stf.MustMatch("("); stf.ParseBlock(new[] {
                 new STFReader.TokenProcessor("headlight", () => { Headlight = (LightHeadlightCondition)stf.ReadIntBlock(null); }),
                 new STFReader.TokenProcessor("unit", () => { Unit = (LightUnitCondition)stf.ReadIntBlock(null); }),
                 new STFReader.TokenProcessor("penalty", () => { Penalty = (LightPenaltyCondition)stf.ReadIntBlock(null); }),
                 new STFReader.TokenProcessor("control", () => { Control = (LightControlCondition)stf.ReadIntBlock(null); }),
                 new STFReader.TokenProcessor("service", () => { Service = (LightServiceCondition)stf.ReadIntBlock(null); }),
                 new STFReader.TokenProcessor("timeofday", () => { TimeOfDay = (LightTimeOfDayCondition)stf.ReadIntBlock(null); }),
                 new STFReader.TokenProcessor("weather", () => { Weather = (LightWeatherCondition)stf.ReadIntBlock(null); }),
                 new STFReader.TokenProcessor("coupling", () => { Coupling = (LightCouplingCondition)stf.ReadIntBlock(null); }),
                 new STFReader.TokenProcessor("ortsbattery", () => { Battery = (LightBatteryCondition)stf.ReadIntBlock(null); }),
             }); }),
         new STFReader.TokenProcessor("cycle", () => { Cycle = 0 != stf.ReadIntBlock(null); }),
         new STFReader.TokenProcessor("fadein", () => { FadeIn = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
         new STFReader.TokenProcessor("fadeout", () => { FadeOut = stf.ReadFloatBlock(STFReader.UNITS.None, null); }),
         new STFReader.TokenProcessor("states", () => {
             stf.MustMatch("(");
             var count = stf.ReadInt(null);
             stf.ParseBlock(new[] {
                 new STFReader.TokenProcessor("state", () => {
                     if (States.Count >= count)
                     {
                         STFException.TraceWarning(stf, "Skipped extra State");
                     }
                     else
                     {
                         States.Add(new LightState(stf));
                     }
                 }),
             });
             if (States.Count < count)
             {
                 STFException.TraceWarning(stf, (count - States.Count).ToString() + " missing State(s)");
             }
         }),
     });
 }