Game.GameWindow.OnTick C# (CSharp) Method

OnTick() protected method

protected OnTick ( float delta ) : void
delta float
return void
        protected override void OnTick( float delta )
        {
            base.OnTick( delta );

            if( Controls.Count != 1 )
                return;

            EntitySystemWorld.Instance.Tick();

            //Shound change map
            if( GameWorld.Instance != null && GameWorld.Instance.ShouldChangeMapName != null )
            {
                GameEngineApp.Instance.ServerOrSingle_MapLoad( GameWorld.Instance.ShouldChangeMapName,
                    EntitySystemWorld.Instance.DefaultWorldType, false );
            }

            //moving free camera by keys
            if( FreeCameraEnabled && OnFreeCameraIsAllowToMove() )
            {
                float cameraVelocity;
                if( EngineApp.Instance.IsKeyPressed( EKeys.Shift ) )
                    cameraVelocity = 100.0f;
                else
                    cameraVelocity = 20.0f;

                Vec3 pos = freeCameraPosition;
                SphereDir dir = freeCameraDirection;

                float step = cameraVelocity * delta;

                bool activeConsole = EngineConsole.Instance != null && EngineConsole.Instance.Active;

                if( !activeConsole )
                {
                    if( EngineApp.Instance.IsKeyPressed( EKeys.W ) ||
                        EngineApp.Instance.IsKeyPressed( EKeys.Up ) )
                    {
                        pos += dir.GetVector() * step;
                    }
                    if( EngineApp.Instance.IsKeyPressed( EKeys.S ) ||
                        EngineApp.Instance.IsKeyPressed( EKeys.Down ) )
                    {
                        pos -= dir.GetVector() * step;
                    }
                    if( EngineApp.Instance.IsKeyPressed( EKeys.A ) ||
                        EngineApp.Instance.IsKeyPressed( EKeys.Left ) )
                    {
                        pos += new SphereDir(
                            dir.Horizontal + MathFunctions.PI / 2, 0 ).GetVector() * step;
                    }
                    if( EngineApp.Instance.IsKeyPressed( EKeys.D ) ||
                        EngineApp.Instance.IsKeyPressed( EKeys.Right ) )
                    {
                        pos += new SphereDir(
                            dir.Horizontal - MathFunctions.PI / 2, 0 ).GetVector() * step;
                    }
                    if( EngineApp.Instance.IsKeyPressed( EKeys.Q ) )
                        pos += new Vec3( 0, 0, step );
                    if( EngineApp.Instance.IsKeyPressed( EKeys.E ) )
                        pos += new Vec3( 0, 0, -step );
                }

                freeCameraPosition = pos;
            }

            if( freeCameraMouseRotating && !FreeCameraEnabled )
                freeCameraMouseRotating = false;
        }