public LightSection Migrate(LightSectionV1 oldLightSection)
        {
            if (oldLightSection == null)
              {
            return null;
              }

              var newLightSectionBuilder = new LightSectionBuilder();

              foreach (var direction in EnumExtensions.GetCompassDirections())
              {
            var oldLight = (LightV1)oldLightSection.GetComponentValueInDirection(direction);
            if (oldLight == null)
            {
              continue;
            }

            var newLight = new Light()
            {
              Red = oldLight.Red,
              Green = oldLight.Green,
              Blue = oldLight.Blue,
              FadeTime = oldLight.FadeTime
            };
            newLightSectionBuilder.WithLightInDirection(direction, newLight);
              }

              return newLightSectionBuilder.Build();
        }
        private LightSection GetLightSection(bool lightEnabled, Light enabledColour)
        {
            var light = lightEnabled
            ? enabledColour
            : DefaultLights.Off;

              return lightSectionBuilder.WithAllLights(light)
            .Build();
        }
        public LightSectionBuilder WithLightInDirections(IEnumerable<eDirection> directions, Light light)
        {
            foreach (var direction in directions)
              {
            var directionalLight = (Light)light.Clone();
            WithLightInDirection(direction, directionalLight);
              }

              return this;
        }
        public Settings(string xiMessage)
        {
            Message = xiMessage;

              Colour = DefaultLights.White;
              UnitLength = 200;
              LightsEnabled = true;
              RumblesEnabled = false;
              RepeatMessage = false;

              // The following settings cannot be overridden:
              Rumble = DefaultRumbles.Thunder;
        }
        public Light BuildCompositeLight(Light firstLight, Light secondLight, int firstLightPercentage)
        {
            if (!IsPercentage(firstLightPercentage))
              {
            throw new ArgumentException("Unexpected percentage (must be between 0 and 100)");
              }

              return new Light
              {
            Red = BuildCompositeValue(firstLight.Red, secondLight.Red, firstLightPercentage),
            Blue = BuildCompositeValue(firstLight.Blue, secondLight.Blue, firstLightPercentage),
            Green = BuildCompositeValue(firstLight.Green, secondLight.Green, firstLightPercentage),
            FadeTime = firstLight.FadeTime
              };
        }
        public LightSectionBuilder WithLightInDirection(eDirection direction, Light light)
        {
            if (lightSection.GetComponentSectionInDirection(direction) != null)
              {
            throw new ArgumentException("Attempted to add multiple lights in the same direction");
              }

              if (!LightIsValid(light))
              {
            throw new ArgumentException("Input Light is invalid");
              }

              light.Direction = direction;
              lightSection.Lights.Add(light);
              return this;
        }
 public LightBuilder Reset()
 {
     light = GetEmptyLight();
       return this;
 }
 private void UpdateLight(Light light)
 {
     Updated[eComponentType.Light] = true;
       Status.LightSection.Lights.Add(light);
 }
 public void UpdateLight(Light inputLight)
 {
     var light = lights[inputLight.Direction];
       light.Color = new amBXColor { Red = inputLight.Red, Green = inputLight.Green, Blue = inputLight.Blue };
       light.FadeTime = inputLight.FadeTime;
 }
 public CompositeLightSectionBuilder WithLights(Light westLight, Light eastLight)
 {
     this.westLight = westLight;
       this.eastLight = eastLight;
       return this;
 }
 public void Setup()
 {
     arbitraryLight = DefaultLights.Red;
 }
 private bool LightIsEmpty(Light light)
 {
     return Math.Abs(light.Red) < lightTolerance &&
     Math.Abs(light.Green) < lightTolerance &&
     Math.Abs(light.Blue) < lightTolerance;
 }
 private bool LightIsValid(Light light)
 {
     return light.FadeTime > 0;
 }
 public LightSectionBuilder WithAllLights(Light light)
 {
     return WithLightInDirections(EnumExtensions.GetCompassDirections(), light);
 }