Beispiel #1
0
        public void SetLightMode(LightModeClass? mode, ILight light)
        {
            if (!mode.HasValue)
            {
                if (light.LightMode != null)
                {
                    light.LightMode.OnRemove(light);
                    light.LightMode = null;
                }
                return;
            }

            var modes = new List<LightMode>();
            foreach (Type t in LightModes)
            {
                var temp = (LightMode) Activator.CreateInstance(t);
                if (temp.LightModeClass == mode.Value)
                {
                    if (light.LightMode != null)
                    {
                        light.LightMode.OnRemove(light);
                        light.LightMode = null;
                    }
                    light.LightMode = temp;
                    temp.OnAdd(light);
                    return;
                }
            }
        }
 public void GenerateShadowMatrix(ICamera camera, ILight light, out Matrix view, out Matrix projection)
 {
     /// view transforms into Lightspace. Depth is saved. The depth value is then written to the shadowmap position defined by projection (the normal modelviewprojection matrix)
     /// but this is nonsense cause projection will not generate the same position for every pixel across a ray originatin from the lightposition
     view = new Matrix();
     projection = new Matrix();
 }
Beispiel #3
0
 protected override void Init()
 {
     Light = new PointLight()
         {
             Ambient = new Vector4(1, 1, 1, 1),
             Diffuse = new Vector4(1, 1, 1, 1),
         };
 }
 public RayEngineScene3(SceneGeometryInfo geometry, IMaterialProvider materials, ILight[] lights = null) {
     this.MaterialProvider = materials;
     this.SceneGeometry = geometry;
     Triangles = new List<TriangleDataInfo>();
     Meshes = new List<ITriangleMesh>();
     meshTriangleMap = new Dictionary<int, ITriangleMesh>();
     this.Lights = lights;
     this.BuildSceneData();
 }
Beispiel #5
0
 public void Add(ILight e)
 {
     Lights.Add(e);
     if(e is ProjectionLight)
         Game.Invoke(() =>
             Game.ShadowMaps.UpdateFromLightsList(
                 Lights
                 .Where((a) => a is ProjectionLight)
                 .Cast<ProjectionLight>().ToList()));
 }
        //When added, set up the light.
        public override void OnAdd(Entity owner)
        {
            base.OnAdd(owner);

            _light = IoCManager.Resolve<ILightManager>().CreateLight();
            IoCManager.Resolve<ILightManager>().AddLight(_light);

            _light.SetRadius(_lightRadius);
            _light.SetColor(255, (int) _lightColor.X, (int) _lightColor.Y, (int) _lightColor.Z);
            _light.Move(Owner.GetComponent<TransformComponent>(ComponentFamily.Transform).Position + _lightOffset);
            _light.SetMask(_mask);
            Owner.GetComponent<TransformComponent>(ComponentFamily.Transform).OnMove += OnMove;
        }
Beispiel #7
0
 public BouncingLight(TestableGameObject obj,
                      Sphere sphere,
                      [Resource("physic/bouncy")] IPhysicMaterial material,
                      ILight light,
                      Random rand)
     : base(obj)
 {
     this.light = light;
     this.rand = rand;
     sphere.collider.material = material;
     light.intensity = 2.0f;
     light.range = 15;
 }
Beispiel #8
0
        public void GetErrorWhenSetColorThrowsException()
        {
            var main = new Main();
            GivenThatWeSubscribeToErrors(main);

            var mockBlink1 = new Mock<IBlink1>();

            mockBlink1
                .Setup(b => b.SetColor(It.IsAny<ushort>(), It.IsAny<ushort>(), It.IsAny<ushort>()))
                .Throws(new InvalidOperationException());

            light = new Blink1Light(main, mockBlink1.Object);

            WhenSettingAColor();
            ThenWeGetAnError();
        }
Beispiel #9
0
        public void GetErrorWhenSetColorReturnsFalse()
        {
            var main = new Main();
            GivenThatWeSubscribeToErrors(main);

            var mockBlink1 = new Mock<IBlink1>();

            mockBlink1
                .Setup(b => b.SetColor(It.IsAny<ushort>(), It.IsAny<ushort>(), It.IsAny<ushort>()))
                .Returns(false);

            light = new Blink1Light(main, mockBlink1.Object);

            WhenSettingAColor();
            ThenWeGetAnError();
        }
Beispiel #10
0
        public void SetLight(ILight light, Vector4 position)
        {
            if (!(light is PointLight)) throw new NotSupportedException("Only pointlights supported in this shader");

            var baseLight = light as PointLight;

            var loc = GetUniformLocation("u_light.position");
            GL.Uniform4(loc, position);

            loc = GetUniformLocation("u_light.ambient");
            GL.Uniform4(loc, baseLight.Ambient);

            loc = GetUniformLocation("u_light.diffuse");
            GL.Uniform4(loc, baseLight.Diffuse);

            loc = GetUniformLocation("u_light.specular");
            GL.Uniform4(loc, baseLight.Specular);
        }
        public static Rectangle GetScissor(this 
            ILightmapPass pass, ILight light)
        {
            var outline = light.Outline;

            if (outline == null)
            {
                return pass.Viewport.Bounds;
            }

            var vectors = outline.Select(x => ScreenToPixel(pass, Vector2.Transform(x, pass.Matrix))).ToList();

            var min = vectors.Aggregate(Vector2.Min);
            var max = vectors.Aggregate(Vector2.Max);

            var rect = new Rectangle((int)min.X, (int)min.Y, (int)(max.X - min.X), (int)(max.Y - min.Y));

            return Rectangle.Intersect(rect, pass.Viewport.Bounds);
        }
Beispiel #12
0
 public void Update(ILight owner, float frametime)
 {
     if (flickering)
     {
         if (lightOn == false)
         {
             if (timer.Milliseconds >= 50 && IoCManager.Resolve<IRand>().Next(1, 6) == 2)
             {
                 flickerCount++;
                 lightOn = true;
                 owner.SetColor(_lightColorOriginal);
                 owner.LightArea.Calculated = false;
                 timer.Reset();
                 if (flickerCount >= 2 && IoCManager.Resolve<IRand>().Next(1, 6) == 2)
                     flickering = false;
             }
         }
         else if (timer.Milliseconds >= 50 && IoCManager.Resolve<IRand>().Next(1, 6) == 2)
         {
             owner.SetColor((_lightColorOriginal.A/2), (_lightColorOriginal.R/2), (_lightColorOriginal.G/2),
                            (_lightColorOriginal.B/2));
             owner.LightArea.Calculated = false;
             lightOn = false;
             timer.Reset();
         }
     }
     else
     {
         if (timer.Seconds >= 4 && IoCManager.Resolve<IRand>().Next(1, 5) == 2)
         {
             flickering = true;
             flickerCount = 0;
             lightOn = false;
             owner.SetColor((_lightColorOriginal.A/2), (_lightColorOriginal.R/2), (_lightColorOriginal.G/2),
                            (_lightColorOriginal.B/2));
             owner.LightArea.Calculated = false;
             timer.Reset();
         }
     }
 }
        private static int GetLightTypeValue(ILight lightType)
        {
            // TODO: Use comparison operator on ILight

            //switch (lightType)
            //{
            //    case LightType.Point:
            //        return 3;
            //case LightType.Spherical:
            //    return 4;
            if (lightType is LightDirectional)
            {
                return(0);
            }
            if (lightType is LightSpot)
            {
                return(1);
            }
            //    default:
            //        throw new ArgumentOutOfRangeException("lightType");
            //}
            return(0);
        }
        public void Setup()
        {
            // Drivers
            _driverDoor              = new Door();
            _driverPowerButton       = new Button();
            _driverTimeButton        = new Button();
            _driverStartCancelButton = new Button();

            // Stubs/mocks
            _display   = Substitute.For <IDisplay>();
            _timer     = Substitute.For <ITimer>();
            _powertube = Substitute.For <IPowerTube>();
            _light     = Substitute.For <ILight>();

            // Unit under test
            _cookController = new CookController(_timer, _display, _powertube);

            // Included
            _userInterface = new UserInterface(_driverPowerButton, _driverTimeButton, _driverStartCancelButton, _driverDoor, _display, _light, _cookController);

            // Property inject userinterface into cookcontroller to support the circular dependency between them
            _cookController.UI = _userInterface;
        }
        public void Setup()
        {
            _powerButton       = new Button();
            _timeButton        = new Button();
            _startCancelButton = new Button();
            _door = new Door();


            _display   = Substitute.For <IDisplay>();
            _light     = Substitute.For <ILight>();
            _timer     = Substitute.For <ITimer>();
            _powerTube = Substitute.For <IPowerTube>();

            _cookController = new CookController(_timer, _display, _powerTube, _userInterface);

            _userInterface = new UserInterface(
                _powerButton,
                _timeButton,
                _startCancelButton,
                _door,
                _display,
                _light,
                _cookController);
        }
        public void Setup()
        {
            #region SetUp

            #endregion

            timer = Substitute.For <ITimer>();

            buttoStartCancel = Substitute.For <IButton>();
            buttoTime        = Substitute.For <IButton>();
            buttoPower       = Substitute.For <IButton>();
            door             = Substitute.For <IDoor>();
            fakeOutput       = Substitute.For <IOutput>();


            powerTube = new PowerTube(fakeOutput);
            light     = new Light(fakeOutput);
            display   = new Display(fakeOutput);


            cookController    = new CookController(timer, display, powerTube);
            userInterface     = new UserInterface(buttoPower, buttoTime, buttoStartCancel, door, display, light, cookController);
            cookController.UI = userInterface;
        }
Beispiel #17
0
        public void SetUp()
        {
            stringWriter = new StringWriter();
            Console.SetOut(stringWriter);


            stubLight   = Substitute.For <ILight>();
            stubDisplay = Substitute.For <IDisplay>();
            door        = Substitute.For <IDoor>();



            powerButton       = new Button();
            timeButton        = new Button();
            startCancelButton = new Button();

            sutTimer     = new MicrowaveOvenClasses.Boundary.Timer();
            sutOutput    = new Output();
            sutPowerTube = new PowerTube(sutOutput);

            sutCookController = new CookController(sutTimer, stubDisplay, sutPowerTube);
            sut_ = new UserInterface(powerButton, timeButton, startCancelButton, door, stubDisplay, stubLight, sutCookController);
            sutCookController.UI = sut_;
        }
Beispiel #18
0
        public void Setup()
        {
            _fakePowerTube = Substitute.For <IPowerTube>();
            _fakeDisplay   = Substitute.For <IDisplay>();
            _fakeLight     = Substitute.For <ILight>();

            _startCancelBtn = new Button();
            _timeBtn        = new Button();
            _powerBtn       = new Button();
            _door           = new Door();
            _timer          = new Timer();
            _cookController = new CookController(_timer, _fakeDisplay, _fakePowerTube);

            _userInterface = new UserInterface(_powerBtn,
                                               _timeBtn,
                                               _startCancelBtn,
                                               _door,
                                               _fakeDisplay,
                                               _fakeLight,
                                               _cookController);

            // Completing double association
            _cookController.UI = _userInterface;
        }
Beispiel #19
0
        public void Setup()
        {
            // fakes!!
            _output = Substitute.For <IOutput>();
            _timer  = Substitute.For <ITimer>();
            _light  = Substitute.For <ILight>();

            // reals!!!
            _display   = new Display(_output);
            _powerTube = new PowerTube(_output);


            // drivers!!!
            _door              = new Door();
            _powerButton       = new Button();
            _timeButton        = new Button();
            _startCancelButton = new Button();

            //also reals!!!
            _cookController = new CookController(_timer, _display, _powerTube);
            _userInterface  = new UserInterface(_powerButton, _timeButton, _startCancelButton, _door, _display, _light,
                                                _cookController);
            ((CookController)_cookController).UI = _userInterface;
        }
Beispiel #20
0
        public void Setup()
        {
            timerSubstitute             = Substitute.For <ITimer>();
            doorSubstitute              = Substitute.For <IDoor>();
            powerButtonSubstitute       = Substitute.For <IButton>();
            timeButtonSubstitute        = Substitute.For <IButton>();
            startCancelButtonSubstitute = Substitute.For <IButton>();
            powerTubeSubstitute         = Substitute.For <IPowerTube>();
            displaySubstitute           = Substitute.For <IDisplay>();
            lightSubstitute             = Substitute.For <ILight>();

            uut = new CookController(timerSubstitute, displaySubstitute, powerTubeSubstitute);

            ui = new UserInterface(
                powerButtonSubstitute,
                timeButtonSubstitute,
                startCancelButtonSubstitute,
                doorSubstitute,
                displaySubstitute,
                lightSubstitute,
                uut);

            uut.UI = ui;
        }
Beispiel #21
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            _gameControls    = new GameplayScreenControls(this);
            _dragDropHandler = new DragDropHandler(this);

            _socket = ClientSockets.Instance;

            _world             = new World(this, new Camera2D(GameData.ScreenSize), new UserInfo(Socket));
            _world.MapChanged += World_MapChanged;

            // Create some misc goodies that require a reference to the Socket
            _equipmentInfoRequester = new EquipmentInfoRequester(UserInfo.Equipped, Socket);
            _inventoryInfoRequester = new InventoryInfoRequester(UserInfo.Inventory, Socket);

            // Other inits
            InitializeGUI();
            _characterTargeter = new CharacterTargeter(World);

            // NOTE: Test lighting
            _userLight = new Light {
                Size = new Vector2(512), IsEnabled = false
            };
            DrawingManager.LightManager.Add(_userLight);
        }
Beispiel #22
0
 public Light()
 {
     _state = new LightOff();
 }
Beispiel #23
0
 /// <summary>
 /// Removes a light from the map.
 /// </summary>
 /// <param name="light">The <see cref="ILight"/> to add.</param>
 /// <returns>True if the <paramref name="light"/> was removed; false if the <paramref name="light"/> was not
 /// in the map's light collection and thus not removed.</returns>
 public bool RemoveLight(ILight light)
 {
     return _lights.Remove(light);
 }
 public DimDownCommand(ILight light)
 {
     _light = light;
 }
 public void SetLightSource(ILight l)
 {
     lightSource = l;
 }
 public BookLightController(IBookingLight IBookingLight, ILight ILight)
 {
     _IBookingLight = IBookingLight;
     _ILight        = ILight;
 }
Beispiel #27
0
        /// <summary>
        /// Handles initialization of the GameScreen. This will be invoked after the GameScreen has been
        /// completely and successfully added to the ScreenManager. It is highly recommended that you
        /// use this instead of the constructor. This is invoked only once.
        /// </summary>
        public override void Initialize()
        {
            _gameControls = new GameplayScreenControls(this);
            _dragDropHandler = new DragDropHandler(this);

            _socket = ClientSockets.Instance;

            _world = new World(this, new Camera2D(GameData.ScreenSize), new UserInfo(Socket));
            _world.MapChanged += World_MapChanged;

            // Create some misc goodies that require a reference to the Socket
            _equipmentInfoRequester = new EquipmentInfoRequester(UserInfo.Equipped, Socket);
            _inventoryInfoRequester = new InventoryInfoRequester(UserInfo.Inventory, Socket);

            // Other inits
            InitializeGUI();
            _characterTargeter = new CharacterTargeter(World);

            // NOTE: Test lighting
            _userLight = new Light { Size = new Vector2(512), IsEnabled = false };
            DrawingManager.LightManager.Add(_userLight);
        }
 /// <summary>
 /// Removes a light to the lighting manager
 /// </summary>
 /// <param name="light">Light to remove</param>
 public void RemoveLight( ILight light )
 {
     m_Lights.Remove( light );
 }
Beispiel #29
0
 /// <summary>
 /// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1"/>.
 /// </summary>
 /// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
 /// <returns>
 /// true if <paramref name="item"/> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1"/>;
 /// otherwise, false. This method also returns false if <paramref name="item"/> is not found in the original
 /// <see cref="T:System.Collections.Generic.ICollection`1"/>.
 /// </returns>
 /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.
 /// </exception>
 public bool Remove(ILight item)
 {
     return(_list.Remove(item));
 }
Beispiel #30
0
 /// <summary>
 /// Determines the index of a specific item in the <see cref="T:System.Collections.Generic.IList`1"/>.
 /// </summary>
 /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.IList`1"/>.</param>
 /// <returns>
 /// The index of <paramref name="item"/> if found in the list; otherwise, -1.
 /// </returns>
 public int IndexOf(ILight item)
 {
     return(_list.IndexOf(item));
 }
 public void Setup()
 {
     _output = new Output();
     _sut    = new Light(_output);
 }
Beispiel #32
0
 /// <summary>
 /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1"/> contains a specific value.
 /// </summary>
 /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
 /// <returns>
 /// true if <paramref name="item"/> is found in the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false.
 /// </returns>
 public bool Contains(ILight item)
 {
     return _list.Contains(item);
 }
Beispiel #33
0
        /// <summary>
        /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1"/>.
        /// </summary>
        /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
        /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.
        /// </exception>
        public void Add(ILight item)
        {
            if (item.Sprite == null)
            {
                if (DefaultSprite != null)
                {
                    // Use a copy of the DefaultSprite
                    item.Sprite = DefaultSprite.DeepCopy();
                }
                else
                {
                    // No sprite was given, and no DefaultSprite to be used
                    const string errmsg =
                        "Added light `{0}` to `{1}` with no sprite, but couldn't use LightManager.DefaultSprite" +
                        " because the property is null.";
                    if (log.IsWarnEnabled)
                        log.WarnFormat(errmsg, item, this);
                    Debug.Fail(string.Format(errmsg, item, this));
                }
            }

            if (!_list.Contains(item))
                _list.Add(item);
        }
        private static int GetLightTypeValue(ILight lightType)
        {
            // TODO: Use comparison operator on ILight

            //switch (lightType)
            //{
            //    case LightType.Point:
            //        return 3;
                //case LightType.Spherical:
                //    return 4;
            if (lightType is LightDirectional)
                return 0;
            if (lightType is LightSpot)
                return 1;
            //    default:
            //        throw new ArgumentOutOfRangeException("lightType");
            //}
            return 0;
        }
 public void SetUp()
 {
     _output = new Output();
     _light  = new Light(_output);
 }
Beispiel #36
0
 private void CalculateLightArea(ILight l)
 {
     // TODO: See Startup for SFML tasks to re-enable lighting
     /*ILightArea area = l.LightArea;
     if (area.Calculated)
         return;
     area.LightPosition = l.Position; //mousePosWorld; // Set the light position
     TileRef t = MapManager.GetTileRef(l.Position);
     if (t.Tile.IsSpace)
         return;
     if (t.Tile.TileDef.IsOpaque)
     {
         area.LightPosition = new Vector2(area.LightPosition.X,
                                           t.Y +
                                           MapManager.TileSize + 1);
     }
     area.BeginDrawingShadowCasters(); // Start drawing to the light rendertarget
     DrawWallsRelativeToLight(area); // Draw all shadowcasting stuff here in black
     area.EndDrawingShadowCasters(); // End drawing to the light rendertarget
     shadowMapResolver.ResolveShadows(area.renderTarget.Image, area.renderTarget, area.LightPosition, true,
                                      area.Mask.Image, area.MaskProps, Vector4.Unit); // Calc shadows
     area.Calculated = true;*/
 }
Beispiel #37
0
 /// <summary>
 /// Inserts an item to the <see cref="T:System.Collections.Generic.IList`1"/> at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
 /// <param name="item">The object to insert into the <see cref="T:System.Collections.Generic.IList`1"/>.</param>
 /// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="index"/> is not a valid index in the
 /// <see cref="T:System.Collections.Generic.IList`1"/>.
 /// </exception>
 /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.IList`1"/> is read-only.
 /// </exception>
 public void Insert(int index, ILight item)
 {
     _list.Insert(index, item);
 }
Beispiel #38
0
 public static void Remove(ILight light)
 {
     if(Lights.Contains(light))
         Lights.Remove(light);
 }
 /// <summary>
 /// Adds a light to the lighting manager
 /// </summary>
 /// <param name="light">Light to add</param>
 public void AddLight( ILight light )
 {
     m_Lights.Add( light );
 }
 public void Setup()
 {
     output = new Output();
     light  = new Light(output);
 }
 public ILightObject(ILight ILightinstance)
 {
     ILightInstance = ILightinstance;
 }
Beispiel #42
0
 public void OnRemove(ILight owner)
 {
     owner.Color = _lightColorOriginal;
     owner.LightArea.Calculated = false;
 }
Beispiel #43
0
 public LightComponent(ILight light)
 {
     Light = light;
 }
 public override IPixelColor GetPointLightColor(IRayHit hit, ILight light)
 {
     return(null);
 }
Beispiel #45
0
        void OnBatteryTimer(object sender, ElapsedEventArgs eea)
        {
            foreach (KeyValuePair <int, IStructure> str in mStructs)
            {
                if (!str.Value.IsReady)
                {
                    continue;
                }
                if (!str.Value.IsPowered)
                {
                    continue;
                }

                if (str.Value.FuelTank != null)
                {
                    mAPI.Log("Fuel tank capacity: " + str.Value.FuelTank.Capacity +
                             ", Content: " + str.Value.FuelTank.Content);
                }

                //located the battery through a prevous 3d search of
                //the volume of the test base (offset by 128)
                IDevice bat = str.Value.GetDevice <IDevice>(-5, 129, -1);
                if (bat == null)
                {
                    mAPI.Log("Bat null");
                }
                else
                {
                    mAPI.Log("Got device: " + bat);
                }

                BlockSearch(str.Value);

                IDevicePosList idpl = str.Value.GetDevices("AmmoCntr");
                for (int i = 0; i < idpl.Count; i++)
                {
                    VectorInt3 pos = idpl.GetAt(i);

                    mAPI.Log("Device at pos: " + pos);

                    IContainer con = str.Value.GetDevice <IContainer>(pos);

                    mAPI.Log("Ammo container has " + con.VolumeCapacity + " volume.");
                }

                idpl = str.Value.GetDevices("Container");
                for (int i = 0; i < idpl.Count; i++)
                {
                    VectorInt3 pos = idpl.GetAt(i);

                    mAPI.Log("Device at pos: " + pos);

                    IContainer con = str.Value.GetDevice <IContainer>(pos);

                    mAPI.Log("Container has " + con.VolumeCapacity + " volume.");
                }

                idpl = str.Value.GetDevices("Fridge");
                for (int i = 0; i < idpl.Count; i++)
                {
                    VectorInt3 pos = idpl.GetAt(i);

                    mAPI.Log("Device at pos: " + pos);

                    IContainer con = str.Value.GetDevice <IContainer>(pos);

                    mAPI.Log("Fridge has " + con.VolumeCapacity + " volume.");
                }

                idpl = str.Value.GetDevices("LCD");
                for (int i = 0; i < idpl.Count; i++)
                {
                    VectorInt3 pos = idpl.GetAt(i);

                    mAPI.Log("Device at pos: " + pos);

                    ILcd lcd = str.Value.GetDevice <ILcd>(pos);

                    mAPI.Log("LCD says: " + lcd.GetText());
                }

                idpl = str.Value.GetDevices("Light");
                for (int i = 0; i < idpl.Count; i++)
                {
                    VectorInt3 pos = idpl.GetAt(i);

                    mAPI.Log("Device at pos: " + pos);

                    ILight lt = str.Value.GetDevice <ILight>(pos);

                    mAPI.Log("Light has range: " + lt.GetRange());
                }

                idpl = str.Value.GetDevices("Portal");
                for (int i = 0; i < idpl.Count; i++)
                {
                    VectorInt3 pos = idpl.GetAt(i);

                    mAPI.Log("Device at pos: " + pos);

                    IPortal door = str.Value.GetDevice <IPortal>(pos);

                    mAPI.Log("Door is a door");
                }
            }
        }
Beispiel #46
0
 public LightController(ILight ILight, IHostingEnvironment hostingEnvironment)
 {
     _ILight      = ILight;
     _environment = hostingEnvironment;
 }
 /// <summary>
 /// Sets the lights that this meter is affected by
 /// </summary>
 public void SetLights( ILight[] lights )
 {
     Lights = lights;
 }
 public AllLightController(ILight ILight)
 {
     _ILight = ILight;
 }
Beispiel #49
0
 /// <summary>
 /// Adds a light to the map as long as it does not already exist in the map's light collection.
 /// </summary>
 /// <param name="light">The <see cref="ILight"/> to add.</param>
 public void AddLight(ILight light)
 {
     if (!_lights.Contains(light))
         _lights.Add(light);
 }
Beispiel #50
0
 /// <summary>
 /// Determines whether the <see cref="T:System.Collections.Generic.ICollection`1"/> contains a specific value.
 /// </summary>
 /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
 /// <returns>
 /// true if <paramref name="item"/> is found in the <see cref="T:System.Collections.Generic.ICollection`1"/>; otherwise, false.
 /// </returns>
 public bool Contains(ILight item)
 {
     return(_list.Contains(item));
 }
Beispiel #51
0
 /// <summary>
 /// Copies the elements of the <see cref="T:System.Collections.Generic.ICollection`1"/> to an <see cref="T:System.Array"/>,
 /// starting at a particular <see cref="T:System.Array"/> index.
 /// </summary>
 /// <param name="array">The one-dimensional <see cref="T:System.Array"/> that is the destination of the elements copied from
 /// <see cref="T:System.Collections.Generic.ICollection`1"/>. The <see cref="T:System.Array"/> must have zero-based indexing.</param>
 /// <param name="arrayIndex">The zero-based index in <paramref name="array"/> at which copying begins.</param>
 /// <exception cref="T:System.ArgumentNullException"><paramref name="array"/> is null.
 /// </exception>
 /// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="arrayIndex"/> is less than 0.
 /// </exception>
 /// <exception cref="T:System.ArgumentException"><paramref name="array"/> is multidimensional.
 /// -or-
 /// <paramref name="arrayIndex"/> is equal to or greater than the length of <paramref name="array"/>.
 /// -or-
 /// The number of elements in the source <see cref="T:System.Collections.Generic.ICollection`1"/> is greater than the
 /// available space from <paramref name="arrayIndex"/> to the end of the destination <paramref name="array"/>.
 /// -or-
 /// Type <see cref="ILight"/> cannot be cast automatically to the type of the destination <paramref name="array"/>.
 /// </exception>
 public void CopyTo(ILight[] array, int arrayIndex)
 {
     _list.CopyTo(array, arrayIndex);
 }
        private double ComputeLightIntensity(ILight light, Vector3d intersectionPoint, Vector3d normal, Vector3d viewDirection, double specularExponent)
        {
            if (light is AmbientLight)
            {
                return(light.Intensity);
            }

            Vector3d oppositeLightDirection;
            double   maxDistance;

            switch (light)
            {
            case DirectionalLight directionalLight:
                oppositeLightDirection = -directionalLight.Direction;
                maxDistance            = double.PositiveInfinity;
                break;

            case PointLight pointLight:
                oppositeLightDirection = pointLight.Position - intersectionPoint;
                maxDistance            = 1d;
                break;

            default:
                throw new NotSupportedException($"Cannot handle light of type {light.GetType().Name}");
            }

            // shadow
            Ray  shadowRay = new Ray(intersectionPoint, oppositeLightDirection);
            bool hasShadow = shadowRay.HasIntersection(_scene.Objects, RayTracer.Delta, maxDistance);

            if (hasShadow)
            {
                return(0d);
            }

            double intensity = 0d;

            // diffuse
            double nl = normal * oppositeLightDirection;

            if (nl > 0d)
            {
                intensity += light.Intensity * nl / (normal.Length * intersectionPoint.Length);
            }

            // specular
            if (specularExponent < 0d)
            {
                return(intensity);
            }

            Vector3d lightReflection = oppositeLightDirection.Reflect(normal);
            double   rv = lightReflection * viewDirection;

            if (rv > 0d)
            {
                intensity += light.Intensity * Math.Pow(rv / (lightReflection.Length * viewDirection.Length), specularExponent);
            }

            return(intensity);
        }
 public LightTurnOnCommand(ILight light, ILogger <LightTurnOnCommand> logger)
 {
     this.light  = light ?? throw new ArgumentNullException(nameof(light));
     this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Beispiel #54
0
 /// <summary>
 /// Determines the index of a specific item in the <see cref="T:System.Collections.Generic.IList`1"/>.
 /// </summary>
 /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.IList`1"/>.</param>
 /// <returns>
 /// The index of <paramref name="item"/> if found in the list; otherwise, -1.
 /// </returns>
 public int IndexOf(ILight item)
 {
     return _list.IndexOf(item);
 }
Beispiel #55
0
 public static void Add(ILight light)
 {
     if(!Lights.Contains(light))
         Lights.Add(light);
 }
Beispiel #56
0
 /// <summary>
 /// Inserts an item to the <see cref="T:System.Collections.Generic.IList`1"/> at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
 /// <param name="item">The object to insert into the <see cref="T:System.Collections.Generic.IList`1"/>.</param>
 /// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="index"/> is not a valid index in the
 /// <see cref="T:System.Collections.Generic.IList`1"/>.
 /// </exception>
 /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.IList`1"/> is read-only.
 /// </exception>
 public void Insert(int index, ILight item)
 {
     _list.Insert(index, item);
 }
Beispiel #57
0
 public LightObject(ILight light)
 {
     LightComponent = new LightComponent(this, light);
     AddComponent(LightComponent);
 }
Beispiel #58
0
 /// <summary>
 /// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1"/>.
 /// </summary>
 /// <param name="item">The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
 /// <returns>
 /// true if <paramref name="item"/> was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1"/>;
 /// otherwise, false. This method also returns false if <paramref name="item"/> is not found in the original
 /// <see cref="T:System.Collections.Generic.ICollection`1"/>.
 /// </returns>
 /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.
 /// </exception>
 public bool Remove(ILight item)
 {
     return _list.Remove(item);
 }
Beispiel #59
0
 public LightOffCommand(ILight light)
 {
     _light = light;
 }
Beispiel #60
0
        //Since lightcolor is only saved when added, changes made during the effects of this mode will reset. FIX THIS.

        public void OnAdd(ILight owner)
        {
            _lightColorOriginal = owner.Color;
            timer.Reset();
        }