Esempio n. 1
0
        /// <summary>
        /// Add a block of text to the tooltip
        /// </summary>
        /// <param name="text">nullable text, null would have no effect</param>
        /// <param name="style"></param>
        public void AddText(string text, string style = "label")
        {
            if (text == null)
            {
                return;
            }
            TooltipComponent newComponent = new TooltipComponent();

            newComponent.text  = text;
            newComponent.style = GUI.skin.GetStyle(style);
            components.Add(newComponent);
        }
Esempio n. 2
0
        // Handle dialogue
        private void handleDialogue(string levelUid, PhysicsComponent playerPhysicsComponent, bool inDialogue)
        {
            DialogueSystem dialogueSystem   = _systemManager.getSystem(SystemType.Dialogue) as DialogueSystem;
            List <int>     dialogueEntities = _entityManager.getEntitiesPosessing(levelUid, ComponentType.CharacterDialogue);

            for (int i = 0; i < dialogueEntities.Count; i++)
            {
                PhysicsComponent otherPhysicsComponent = _entityManager.getComponent(levelUid, dialogueEntities[i], ComponentType.Physics) as PhysicsComponent;
                Vector2          relative   = playerPhysicsComponent.body.Position - otherPhysicsComponent.body.Position;
                float            distanceSq = relative.LengthSquared();

                if (_newKeyState.IsKeyDown(Keys.E) && _oldKeyState.IsKeyUp(Keys.E))
                {
                    if (!inDialogue && distanceSq <= 1f)
                    {
                        CharacterDialogueComponent dialogueComponent = _entityManager.getComponent(levelUid, dialogueEntities[i], ComponentType.CharacterDialogue) as CharacterDialogueComponent;

                        dialogueSystem.beginDialogue(levelUid, PlayerSystem.PLAYER_ID, dialogueEntities[i], dialogueComponent);
                    }
                }
                else
                {
                    TooltipComponent tooltipComponent = _entityManager.getComponent(levelUid, dialogueEntities[i], ComponentType.Tooltip) as TooltipComponent;

                    if (tooltipComponent == null)
                    {
                        if (!inDialogue && distanceSq <= 1f)
                        {
                            _entityManager.addComponent(levelUid, dialogueEntities[i], new TooltipComponent("[Use] Talk", otherPhysicsComponent.body, 1f));
                        }
                    }
                    else
                    {
                        if (inDialogue || distanceSq > 1f)
                        {
                            _entityManager.removeComponent(levelUid, dialogueEntities[i], ComponentType.Tooltip);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        // update
        public void update(GameTime gameTime)
        {
            if (!_paused || _singleStep)
            {
                if (_finalized)
                {
                    PhysicsComponent                playerPhysicsComponent    = (PhysicsComponent)_entityManager.getComponent(currentLevelUid, PlayerSystem.PLAYER_ID, ComponentType.Physics);
                    List <TooltipComponent>         tooltipComponents         = _entityManager.getComponents <TooltipComponent>(currentLevelUid, ComponentType.Tooltip);
                    List <LevelTransitionComponent> levelTransitionComponents = _entityManager.getComponents <LevelTransitionComponent>(currentLevelUid, ComponentType.LevelTransition);

                    _oldKeyState = _newKeyState;
                    _newKeyState = Keyboard.GetState();

                    if (playerPhysicsComponent != null)
                    {
                        Vector2 position      = playerPhysicsComponent.body.Position;
                        AABB    levelBoundary = _levelBoundaries[currentLevelUid];

                        // Check player's position against the level boundary
                        if (position.X < levelBoundary.LowerBound.X - _boundaryMargin.X || position.X > levelBoundary.UpperBound.X + _boundaryMargin.X ||
                            position.Y < levelBoundary.LowerBound.Y - _boundaryMargin.Y || position.Y > levelBoundary.UpperBound.Y + _boundaryMargin.Y)
                        {
                            endLevel();
                            _playerSystem.reloadInventory();
                        }

                        // Check player's position against tooltips
                        for (int i = 0; i < tooltipComponents.Count; i++)
                        {
                            TooltipComponent tooltip = tooltipComponents[i];

                            if ((position - tooltip.position).LengthSquared() <= tooltip.radiusSq)
                            {
                                tooltip.draw = true;
                            }
                        }

                        // Check player's position against level transitions
                        for (int i = 0; i < levelTransitionComponents.Count; i++)
                        {
                            LevelTransitionComponent levelTransition = levelTransitionComponents[i];

                            if (hitTestBox(levelTransition.position, levelTransition.halfWidth, levelTransition.halfHeight, levelTransition.angle, position))
                            {
                                if (levelTransition.requiresActivation)
                                {
                                    if (_newKeyState.IsKeyDown(Keys.E) && _oldKeyState.IsKeyUp(Keys.E))
                                    {
                                        Console.WriteLine("begin level transition to: {0}", levelTransition.levelUid);
                                        switchToLevel(levelTransition.levelUid, levelTransition.positionInLevel);
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("begin level transition to: {0}", levelTransition.levelUid);
                                    switchToLevel(levelTransition.levelUid, levelTransition.positionInLevel);
                                }
                            }
                        }
                    }
                }
            }
            _singleStep = false;
        }
Esempio n. 4
0
    public static void DisplayCategory(string category)
    {
        if (instance == null)
        {
            return;
        }

        // Optimisation for saving
        if (instance.currentCategory != string.Empty && instance.currentCategory != category && instance.options.ContainsKey(instance.currentCategory))
        {
            foreach (string headingName in instance.options[instance.currentCategory].Keys)
            {
                for (int i = 0; i < instance.options[instance.currentCategory][headingName].Length; i++)
                {
                    BaseSettingsElement elementCopy = instance.options[instance.currentCategory][headingName][i];

                    if (elementCopy != null && elementCopy.valueChanged)
                    {
                        instance.changesTracker.Add(elementCopy);
                    }
                }
            }

            if (instance.changesTracker.Count > 0)
            {
                instance.Apply();
            }
        }

        instance.categoryHeading.text = LocalizationTable.GetLocalization(category);
        instance.currentCategory      = category;

        // Clear root
        foreach (Transform child in instance.elementRoot.transform)
        {
            child.BroadcastMessage("Despawn", SendMessageOptions.DontRequireReceiver);
            Destroy(child.gameObject);
        }

        foreach (ColorButton button in instance.categoryRoot.GetComponentsInChildren <ColorButton>())
        {
            if (button.gameObject.name != category)
            {
                button.RevertColor();
            }
            else
            {
                button.SelectColor();
            }
        }

        if (instance.options.ContainsKey(category) == false)
        {
            return;
        }

        if (instance.currentCategory != string.Empty && instance.options.ContainsKey(instance.currentCategory))
        {
            foreach (string headingName in instance.options[instance.currentCategory].Keys)
            {
                // Create heading prefab
                SettingsHeading heading = Instantiate(instance.headingPrefab).GetComponent <SettingsHeading>();
                heading.SetText(headingName);
                heading.transform.SetParent(instance.elementRoot.transform);

                for (int i = 0; i < instance.options[instance.currentCategory][headingName].Length; i++)
                {
                    if (instance.options[instance.currentCategory][headingName][i] != null)
                    {
                        BaseSettingsElement element = instance.options[instance.currentCategory][headingName][i];
                        GameObject          go      = element.InitializeElement();
                        TooltipComponent    tc      = go.AddComponent <TooltipComponent>();
                        tc.Tooltip          = element.option.tooltip;
                        tc.UseHeavyTextMode = true;

                        heading.AddObjectToRoot(go);
                        element.valueChanged = false;
                    }
                }
            }
        }

        // Update canvases, to allow the normalized position to properly exist.
        Canvas.ForceUpdateCanvases();
        instance.settingsScrollRect.normalizedPosition = new Vector2(0, 1);
    }
Esempio n. 5
0
        // draw
        public void draw(GameTime gameTime)
        {
            string      levelUid                        = LevelSystem.currentLevelUid;
            FluidSystem fluidSystem                     = (FluidSystem)_systemManager.getSystem(SystemType.Fluid);
            List <int>  primitiveRenderEntities         = _entityManager.getEntitiesPosessing(levelUid, ComponentType.PrimitivesRender);
            List <int>  ropeEntities                    = _entityManager.getEntitiesPosessing(levelUid, ComponentType.Rope);
            List <int>  characterRenderEntities         = _entityManager.getEntitiesPosessing(levelUid, ComponentType.CharacterRender);
            List <int>  characterMovementEntities       = _entityManager.getEntitiesPosessing(levelUid, ComponentType.CharacterMovement);
            List <int>  treeEntities                    = _entityManager.getEntitiesPosessing(levelUid, ComponentType.Tree);
            List <int>  aimEntities                     = _entityManager.getEntitiesPosessing(levelUid, ComponentType.Aim);
            List <int>  explosionEntities               = _entityManager.getEntitiesPosessing(levelUid, ComponentType.Explosion);
            List <RopeGrabComponent> ropeGrabComponents = _entityManager.getComponents <RopeGrabComponent>(levelUid, ComponentType.RopeGrab);
            List <TooltipComponent>  tooltipComponents  = _entityManager.getComponents <TooltipComponent>(levelUid, ComponentType.Tooltip);
            Vector2 screenCenter                        = _cameraSystem.screenCenter;

            // Temporary debug draw
            if (LoderGame.debug)
            {
                Vector2 debugOffset = new Vector2(0f, 5f);
                _graphicsDevice.SetRenderTarget(_debugFluid);
                _graphicsDevice.Clear(Color.Black);
                _spriteBatch.Begin();

                // Cells
                foreach (KeyValuePair <int, Dictionary <int, List <int> > > row1Pair in fluidSystem.fluidGrid)
                {
                    foreach (KeyValuePair <int, List <int> > row2Pair in row1Pair.Value)
                    {
                        int     gridSize = (int)(FluidSystem.CELL_SPACING * scale) - 1;
                        Vector2 position = new Vector2((float)row1Pair.Key * FluidSystem.CELL_SPACING, (float)row2Pair.Key * FluidSystem.CELL_SPACING);
                        _spriteBatch.Draw(_pixel, (position - debugOffset) * scale + _halfScreen, new Rectangle(0, 0, gridSize, gridSize), Color.DarkBlue, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    }
                }

                // Particle pressures
                for (int i = 0; i < FluidSystem.MAX_PARTICLES; i++)
                {
                    Particle particle = fluidSystem.liquid[i];
                    _spriteBatch.Draw(_pixel, (particle.position - debugOffset) * scale + _halfScreen, new Rectangle(0, 0, 16, 16), Color.Red * 0.5f, 0f, new Vector2(8, 8), Math.Abs(particle.pressure) / FluidSystem.MAX_PRESSURE, SpriteEffects.None, 0f);
                }

                // Particle near pressures
                for (int i = 0; i < FluidSystem.MAX_PARTICLES; i++)
                {
                    Particle particle = fluidSystem.liquid[i];
                    _spriteBatch.Draw(_pixel, (particle.position - debugOffset) * scale + _halfScreen, new Rectangle(0, 0, 16, 16), Color.Orange * 0.5f, 0f, new Vector2(8, 8), Math.Abs(particle.pressureNear) / FluidSystem.MAX_PRESSURE_NEAR, SpriteEffects.None, 0f);
                }

                // Particle positions
                for (int i = 0; i < FluidSystem.MAX_PARTICLES; i++)
                {
                    Particle particle = fluidSystem.liquid[i];
                    Color    color    = particle.active ? Color.White : Color.DarkGray;
                    _spriteBatch.Draw(_pixel, (particle.position - debugOffset) * scale + _halfScreen, new Rectangle(0, 0, 4, 4), color, 0, new Vector2(2, 2), 1, SpriteEffects.None, 0);
                }

                // Simulation AABB
                Vector2[] vertices = new Vector2[4];
                vertices[0] = fluidSystem.simulationAABB.LowerBound;
                vertices[1] = new Vector2(fluidSystem.simulationAABB.UpperBound.X, fluidSystem.simulationAABB.LowerBound.Y);
                vertices[2] = fluidSystem.simulationAABB.UpperBound;
                vertices[3] = new Vector2(fluidSystem.simulationAABB.LowerBound.X, fluidSystem.simulationAABB.UpperBound.Y);
                for (int i = 0; i < 4; i++)
                {
                    Vector2   a        = vertices[i];
                    Vector2   b        = vertices[i == 3 ? 0 : i + 1];
                    Vector2   relative = b - a;
                    float     angle    = (float)Math.Atan2(relative.Y, relative.X);
                    Rectangle rect     = new Rectangle(0, 0, (int)(relative.Length() * scale), 2);
                    _spriteBatch.Draw(_pixel, (a - debugOffset) * scale + _halfScreen, rect, Color.Lime, angle, new Vector2(0, 1), 1f, SpriteEffects.None, 0);
                }

                _spriteBatch.End();
                _graphicsDevice.SetRenderTarget(null);
            }

            // Begin drawing a source for post effects under the player's level
            _graphicsDevice.SetRenderTarget(_postSourceUnder);
            _graphicsDevice.Clear(Color.Black);

            // Draw background
            if (_backgroundRenderer.background != null)
            {
                _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
                _backgroundRenderer.drawFirstHalf();
                _spriteBatch.End();
            }

            // Begin ordered drawing
            _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
            _halfScreen       = new Vector2(_graphicsDevice.Viewport.Width, _graphicsDevice.Viewport.Height) / 2;
            _viewMatrix       = Matrix.CreateTranslation(new Vector3(-screenCenter, 0)) * Matrix.CreateScale(new Vector3(_scale, -_scale, 1f));
            _projectionMatrix = Matrix.CreateOrthographic(_graphicsDevice.Viewport.Width, _graphicsDevice.Viewport.Height, 0, 1);
            _primitivesEffect.Parameters["view"].SetValue(_viewMatrix);
            _primitivesEffect.Parameters["projection"].SetValue(_projectionMatrix);

            // Primitive rendering
            for (int i = 0; i < primitiveRenderEntities.Count; i++)
            {
                int entityId = primitiveRenderEntities[i];
                PrimitivesRenderComponent primitiveRenderComponent = (PrimitivesRenderComponent)_entityManager.getComponent(levelUid, entityId, ComponentType.PrimitivesRender);

                for (int j = 0; j < primitiveRenderComponent.primitiveRenderObjects.Count; j++)
                {
                    PrimitiveRenderObject primitiveRenderObject = primitiveRenderComponent.primitiveRenderObjects[j];
                    PhysicsComponent      physicsComponent      = (PhysicsComponent)_entityManager.getComponent(levelUid, entityId, ComponentType.Physics);
                    IComponent            component;

                    // Update world matrix
                    if (physicsComponent != null)
                    {
                        primitiveRenderObject.worldMatrix = primitiveRenderObject.originMatrix * Matrix.CreateRotationZ(physicsComponent.body.Rotation) * Matrix.CreateTranslation(new Vector3(physicsComponent.body.Position, 0));
                    }
                    else if (_entityManager.tryGetComponent(levelUid, entityId, ComponentType.FollowMetamer, out component))
                    {
                        FollowMetamerComponent followMetamerComponent = component as FollowMetamerComponent;
                        primitiveRenderObject.worldMatrix = primitiveRenderObject.originMatrix * Matrix.CreateRotationZ(followMetamerComponent.metamer.currentAngle + StasisMathHelper.halfPi) * Matrix.CreateTranslation(new Vector3(followMetamerComponent.metamer.position, 0));
                    }

                    // Update vertices
                    primitiveRenderObject.updateVertices();

                    addRenderablePrimitive(primitiveRenderObject);
                }
            }

            // Rope rendering
            for (int i = 0; i < ropeEntities.Count; i++)
            {
                int           entityId      = ropeEntities[i];
                RopeComponent ropeComponent = _entityManager.getComponent(levelUid, entityId, ComponentType.Rope) as RopeComponent;
                RopeNode      current       = ropeComponent.ropeNodeHead;
                RopeNode      head          = current;
                RopeNode      tail          = head.tail;
                Vector2       position;
                float         muIncrement = 1f / (float)ropeComponent.interpolationCount;

                while (current != null)
                {
                    float mu = 0f;
                    for (int j = 0; j < ropeComponent.interpolationCount; j++)
                    {
                        Texture2D texture = current.ropeNodeTextures[j].texture;
                        Vector2   a;
                        Vector2   b = current.body.GetWorldPoint(new Vector2(current.halfLength, 0));
                        Vector2   c = current.body.GetWorldPoint(new Vector2(-current.halfLength, 0));
                        Vector2   d;

                        // Determine a's position
                        if (current.previous == null)
                        {
                            a = b + (b - c);
                        }
                        else
                        {
                            a = current.previous.body.GetWorldPoint(new Vector2(current.halfLength, 0));
                        }

                        // Determine d's position
                        if (current.next == null)
                        {
                            d = c + (c - b);
                        }
                        else
                        {
                            d = current.next.body.GetWorldPoint(new Vector2(-current.halfLength, 0));
                        }

                        StasisMathHelper.interpolate(ref a, ref b, ref c, ref d, mu, out position);
                        _spriteBatch.Draw(texture, (position - screenCenter) * _scale + _halfScreen, texture.Bounds, Color.White, current.body.Rotation + current.ropeNodeTextures[j].angleOffset, current.ropeNodeTextures[j].center, 1f, SpriteEffects.None, 0.1f);

                        mu += muIncrement;
                    }

                    current = current.next;
                }
            }

            // Character rendering
            for (int i = 0; i < characterRenderEntities.Count; i++)
            {
                PhysicsComponent         physicsComponent         = (PhysicsComponent)_entityManager.getComponent(levelUid, characterRenderEntities[i], ComponentType.Physics);
                CharacterRenderComponent characterRenderComponent = _entityManager.getComponent(levelUid, characterRenderEntities[i], ComponentType.CharacterRender) as CharacterRenderComponent;
                Vector2   offset;
                Texture2D texture = _animationManager.getTexture(characterRenderComponent.character, characterRenderComponent.animation, characterRenderComponent.currentFrame, out offset);

                _spriteBatch.Draw(texture, (physicsComponent.body.Position - screenCenter) * _scale + _halfScreen, texture.Bounds, Color.White, 0, offset, 1f, SpriteEffects.None, 0.05f);
            }

            /*
             * for (int i = 0; i < characterMovementEntities.Count; i++)
             * {
             *  PhysicsComponent physicsComponent = (PhysicsComponent)_entityManager.getComponent(levelUid, characterMovementEntities[i], ComponentType.Physics);
             *  CharacterMovementComponent characterMovementComponent = (CharacterMovementComponent)_entityManager.getComponent(levelUid, characterMovementEntities[i], ComponentType.CharacterMovement);
             *  Vector2 movementUnitVector = characterMovementComponent.movementUnitVector;
             *  Rectangle source = new Rectangle(0, 0, (int)(movementUnitVector.Length() * _scale), 2);
             *  float angle = (float)Math.Atan2(movementUnitVector.Y, movementUnitVector.X);
             *
             *  _spriteBatch.Draw(_pixel, (physicsComponent.body.Position - screenCenter) * _scale + _halfScreen, source, Color.Yellow, angle, new Vector2(0, 1), 1f, SpriteEffects.None, 0);
             * }*/

            // Tree
            _primitivesEffect.Parameters["world"].SetValue(Matrix.Identity);
            for (int i = 0; i < treeEntities.Count; i++)
            {
                TreeComponent treeComponent = _entityManager.getComponent(levelUid, treeEntities[i], ComponentType.Tree) as TreeComponent;

                if (treeComponent.tree.active)
                {
                    addRenderablePrimitive(treeComponent.tree);
                    treeComponent.tree.rootMetamer.draw(this);
                }
            }

            drawRenderablePrimitives();

            // Rope grab components (TEMPORARY)
            for (int i = 0; i < ropeGrabComponents.Count; i++)
            {
                foreach (KeyValuePair <Body, RevoluteJoint> pair in ropeGrabComponents[i].joints)
                {
                    Vector2 pointA   = pair.Value.BodyA.Position;
                    Vector2 pointB   = pair.Value.BodyB.Position;
                    Vector2 relative = pointB - pointA;
                    float   angle    = (float)Math.Atan2(relative.Y, relative.X);

                    _spriteBatch.Draw(_pixel, (pointA - screenCenter) * _scale + _halfScreen, new Rectangle(0, 0, (int)(relative.Length() * _scale), 2), Color.Green, angle, new Vector2(0, 1), 1f, SpriteEffects.None, 0f);
                }
            }

            // Draw explosions (TEMPORARY)
            for (int i = 0; i < explosionEntities.Count; i++)
            {
                ExplosionComponent explosionComponent = (ExplosionComponent)_entityManager.getComponent(levelUid, explosionEntities[i], ComponentType.Explosion);
                _spriteBatch.Draw(_circle, (explosionComponent.position - screenCenter) * _scale + _halfScreen, _circle.Bounds, Color.Red, 0f, new Vector2(_circle.Width, _circle.Height) / 2f, ((explosionComponent.radius * _scale) / (_circle.Width / 2f)), SpriteEffects.None, 0f);
            }

            // Aim components
            for (int i = 0; i < aimEntities.Count; i++)
            {
                AimComponent aimComponent  = (AimComponent)_entityManager.getComponent(levelUid, aimEntities[i], ComponentType.Aim);
                Vector2      worldPosition = (_entityManager.getComponent(levelUid, aimEntities[i], ComponentType.WorldPosition) as WorldPositionComponent).position;
                float        length        = aimComponent.length;

                _spriteBatch.Draw(_reticle, (worldPosition - screenCenter + new Vector2((float)Math.Cos(aimComponent.angle), (float)Math.Sin(aimComponent.angle)) * length) * _scale + _halfScreen, _reticle.Bounds, Color.Red, aimComponent.angle, new Vector2(_reticle.Width, _reticle.Height) / 2f, 1f, SpriteEffects.None, 0f);
            }

            _spriteBatch.End();

            // Begin drawing source for post effects over the player's layer
            _graphicsDevice.SetRenderTarget(_postSourceOver);
            _graphicsDevice.Clear(Color.Transparent);
            _spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

            // Draw background's second half
            if (_backgroundRenderer.background != null)
            {
                _backgroundRenderer.drawSecondHalf();
            }

            // Draw tooltips
            for (int i = 0; i < tooltipComponents.Count; i++)
            {
                TooltipComponent tooltip = tooltipComponents[i];

                if (tooltip.draw)
                {
                    Vector2 tooltipPosition = (tooltip.position - screenCenter) * _scale + _halfScreen - new Vector2(0, 50f);

                    _spriteBatch.DrawString(_tooltipFont, tooltip.message, tooltipPosition + new Vector2(2, 2), Color.Black, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0001f);
                    _spriteBatch.DrawString(_tooltipFont, tooltip.message, tooltipPosition, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
                    tooltip.draw = false;
                }
            }

            _spriteBatch.End();
            _graphicsDevice.SetRenderTarget(null);
            _graphicsDevice.Clear(Color.Transparent);


            // Render fluid
            _graphicsDevice.SetRenderTarget(_fluidRenderTarget);
            _graphicsDevice.Clear(Color.Transparent);
            spriteBatch.Begin();
            int limit = fluidSystem.numActiveParticles;

            for (int i = 0; i < limit; i++)
            {
                // Current particle
                Particle particle = fluidSystem.liquid[fluidSystem.activeParticles[i]];
                Color    color    = new Color(1, particle.velocity.X < 0 ? -particle.velocity.X : particle.velocity.X, particle.velocity.Y < 0 ? -particle.velocity.Y : particle.velocity.Y);
                spriteBatch.Draw(_fluidParticleTexture, (particle.position - _cameraSystem.screenCenter) * scale + _halfScreen, _fluidParticleTexture.Bounds, color, 0, new Vector2(16, 16), 1, SpriteEffects.None, 0);
            }
            spriteBatch.End();
            _graphicsDevice.SetRenderTarget(_renderedFluid);
            _graphicsDevice.Clear(Color.Transparent);

            // Draw post-processed render target to screen
            _graphicsDevice.Textures[1] = _postSourceUnder;
            _fluidEffect.Parameters["renderSize"].SetValue(new Vector2(_renderedFluid.Width, _renderedFluid.Height));
            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, _fluidEffect);
            spriteBatch.Draw(_fluidRenderTarget, Vector2.Zero, Color.DarkBlue);
            spriteBatch.End();
            _graphicsDevice.SetRenderTarget(null);

            // Draw post source under and over
            _spriteBatch.Begin();
            _spriteBatch.Draw(_postSourceUnder, _postSourceUnder.Bounds, Color.White);
            _spriteBatch.End();

            // Draw fluid
            if (fluidSystem != null)
            {
                _spriteBatch.Begin();
                _spriteBatch.Draw(_renderedFluid, _renderedFluid.Bounds, Color.White);
                _spriteBatch.End();
            }

            _spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
            _spriteBatch.Draw(_postSourceOver, _postSourceOver.Bounds, Color.White);
            _spriteBatch.End();

            // Particle debug
            if (LoderGame.debug)
            {
                _spriteBatch.Begin();
                _spriteBatch.Draw(_debugFluid, Vector2.Zero, _debugFluid.Bounds, Color.White, 0f, Vector2.Zero, _enlargeDebugFuild ? 1f : 0.25f, SpriteEffects.None, 0f);
                _spriteBatch.End();

                /*
                 * _spriteBatch.Begin();
                 * int limit = fluidSystem.numActiveParticles;
                 * for (int i = 0; i < limit; i++)
                 * {
                 *  // Current particle
                 *  Particle particle = fluidSystem.liquid[fluidSystem.activeParticles[i]];
                 *  spriteBatch.Draw(_pixel, (particle.position - _cameraSystem.screenCenter) * scale + _halfScreen, new Rectangle(0, 0, 2, 2), Color.White, 0, new Vector2(1, 1), 1, SpriteEffects.None, 0);
                 * }
                 * _spriteBatch.End();
                 */
            }

            // AI Wander Behavior debug
            if (LoderGame.debug)
            {
                AIBehaviorSystem aiBehaviorSystem       = _systemManager.getSystem(SystemType.AIBehavior) as AIBehaviorSystem;
                List <int>       wanderBehaviorEntities = _entityManager.getEntitiesPosessing(levelUid, ComponentType.AIWanderBehavior);

                for (int i = 0; i < wanderBehaviorEntities.Count; i++)
                {
                    AIWanderBehaviorComponent wanderComponent     = _entityManager.getComponent(levelUid, wanderBehaviorEntities[i], ComponentType.AIWanderBehavior) as AIWanderBehaviorComponent;
                    List <WaypointsComponent> waypointsComponents = _entityManager.getComponents <WaypointsComponent>(levelUid, ComponentType.Waypoints);

                    if (waypointsComponents.Count > 0)
                    {
                        WaypointsComponent waypointsComponent = aiBehaviorSystem.getWaypointsComponent(wanderComponent.waypointsUid, waypointsComponents);
                        Vector2            waypointPosition   = waypointsComponent.waypoints[wanderComponent.currentWaypointIndex];

                        _spriteBatch.Begin();
                        _spriteBatch.Draw(_circle, (waypointPosition - screenCenter) * _scale + _halfScreen, _circle.Bounds, Color.Red, 0f, new Vector2(_circle.Width, _circle.Height) / 2f, 0.02f, SpriteEffects.None, 0f);
                        _spriteBatch.End();
                    }
                }
            }
        }