Пример #1
0
        public override void Render(Scene scene)
        {
            Insist.IsNotNull(RenderTexture, $"{nameof(StencilLightRenderer)} requires a RenderTexture!");

            var cam = Camera ?? scene.Camera;

            BeginRender(cam);

            var renderables = scene.RenderableComponents.ComponentsWithRenderLayer(RenderLayer);

            for (var i = 0; i < renderables.Length; i++)
            {
                var renderable = renderables.Buffer[i];
                if (renderable.Enabled && renderable.IsVisibleFromCamera(cam))
                {
                    RenderLight(renderable, cam);
                }
            }

            if (ShouldDebugRender && Core.DebugRenderEnabled)
            {
                DebugRender(scene, cam);
            }

            EndRender();
        }
Пример #2
0
        /// <summary>
        /// gets all the non-empty tiles that intersect the passed in bounds for the collision layer. The returned List can be put back in the
        /// pool via ListPool.free.
        /// </summary>
        /// <returns>The tiles intersecting bounds.</returns>
        /// <param name="bounds">Bounds.</param>
        public List <TmxLayerTile> GetTilesIntersectingBounds(Rectangle bounds)
        {
            Insist.IsNotNull(CollisionLayer, "collisionLayer must not be null!");

            // offset the passed in world position to compensate for the entity position
            bounds.Location -= (Entity.Transform.Position + _localOffset).ToPoint();
            return(CollisionLayer.GetTilesIntersectingBounds(bounds));
        }
Пример #3
0
        /// <summary>
        /// this method requires that you are using a collision layer setup in the constructor.
        /// </summary>
        /// <returns>The tile at world position.</returns>
        /// <param name="worldPos">World position.</param>
        public TiledTile GetTileAtWorldPosition(Vector2 worldPos)
        {
            Insist.IsNotNull(CollisionLayer, "collisionLayer must not be null!");

            // offset the passed in world position to compensate for the entity position
            worldPos -= Entity.Transform.Position + _localOffset;
            return(CollisionLayer.GetTileAtWorldPosition(worldPos));
        }
Пример #4
0
        /// <summary>
        /// this method requires that you are using a collision layer setup in the constructor.
        /// </summary>
        public TmxLayerTile GetTileAtWorldPosition(Vector2 worldPos)
        {
            Insist.IsNotNull(CollisionLayer, "collisionLayer must not be null!");

            return(CollisionLayer.GetTileAtWorldPosition(worldPos - _localOffset));
        }