//
// Copyright(C) 2014-2015 Samuel Villarreal
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// DESCRIPTION:
//      Level Script For Level46.map
//

#include "scripts/common.txt"

/*
==============================================================
Script 0
==============================================================
*/

$script 0
{
    Camera.StartCinematic(CMF_LOCK_PLAYER|CMF_NO_LETTERBOX|CMF_NO_INITIAL_FADEOUT);
    Camera.SetFinalView(0);
    
    Camera.fov = 47.5f;
    
    Camera.SetEyeView(kVec3(0, -51.2f, 102.4f));
    Camera.SetFocusView(kVec3(0, 0, 102.4f));
    
    Game.CallDelayedMapScript(1, instigator, 0);
    Game.CallDelayedMapScript(2, instigator, 0);
}

/*
==============================================================
Script 1
==============================================================
*/

$script 1
{
    const kVec3 finalEye(2.56f, -245.76f, 71.68f);
    const kVec3 finalFocus(2.56f, 0.0f, 122.88f);
    
    if(finalEye.Distance(Camera.GetEyeView()) > 3.072f)
    {
        Camera.ZoomEyeViewToPosition(finalEye, 1.0f / 12.0f);
    }
    
    if(finalFocus.Distance(Camera.GetFocusView()) > 3.072f)
    {
        Camera.ZoomFocusViewToPosition(finalFocus, 1.0f / 12.0f);
    }
    
    $restart;
}

/*
==============================================================
Script 2
==============================================================
*/

$script 2
{
    if(Camera.UserInterrupted())
    {
        PlayLoop.ChangeMap("levels/level43.map");
        return;
    }
    
    $restart;
}
