//-------------------------------------------------------------------
//
//  This code is copyright 2001 by G5 Software.
//  Any unauthorized usage, either in part or in whole of this code
//  is strictly prohibited. Violators WILL be prosecuted to the
//  maximum extent allowed by law.
//
//-------------------------------------------------------------------

class CFireworksMission extends
  CBaseMission, CFireworksMissionObjectList, CFireworksMission_Strings, CNavPointUser
{
  int GetAutoGeneratedUnitsQty()
  {
    return 6;
  }

  void CFireworksMission()
  {
    BaseMission_InitMission();

    BaseMission_UpdateLoadProgress();
    CreateComponent("DebugCamera", "GameObject", "CDebugCamera");
    SetComponentPosition("DebugCamera",
      matrix(
        1.0, 0.0, 0.0, 8000.0,
        0.0, 1.0, 0.0, 8000.0,
        0.0, 0.0, 1.0,  600.0,
        0.0, 0.0, 0.0,    1.0
      ));

    // CreateComponent(IDToRegister, ComponentID, ScriptName | FileName | "")
    BaseMission_UpdateLoadProgress();
    CreateComponent("Atmosphere", "Atmosphere", "CFireworksMission_Atmosphere");

    BaseMission_UpdateLoadProgress();
    CreateComponent("Sky", "SkyObject", "CFireworksMission_Sky");

    BaseMission_UpdateLoadProgress();
    CreateComponent("Terrain", "ProgressiveTerrainObject", "CFireworksMission_Terrain");

    BaseMission_UpdateLoadProgress();
    CreateComponent("Forest", "Forest", "CFireworksMission_Forest");

    BaseMission_UpdateLoadProgress();
    CreateComponent("AIController", "AIController", "CBaseAIController");

    BaseMission_CreateObjects();

    //
    //  Mission specific
    //

    // count how many objectives' objects are in the mission
    array m_Objects = GetObjectsIDs();

    m_HangarsCount  = 0;

    for (int i = 0; i < m_Objects.size(); i = i + 1)
    {
      if (Core_IsStringStartsWith(m_Objects[i], "Hangar"))
        m_HangarsCount = m_HangarsCount + 1;
    }
  }

  int  m_HangarsCount;

  array m_MissionObjectivesStatuses =
          array(
            str_ObjectiveInProgress
          );

  array m_BonusMissionObjectivesStatuses =
          array();

  //
  //  'virtual' methods
  //

  //
  //  Mission statistics

  string GetMissionStatistics()
  {
    return str_StatisticsTitle;
  }

  //
  //  Mission navpoints

  array GetNavPoints()
  {
    array navpoints =
      array(
          GetNavPoint("NavPoint_Airdrome")
//        vector(4587.0, 5908.0, 600.0)
      );
    return navpoints;
  }

  //
  //  Mission map skin file

  string GetMapSkinFileName()
  {
    return "Missions/Mission_3/Map.skin";
  }

  //
  //  Mission specific event handlers
  //

  //
  //  Object destroyed event handler
  //

  void OnGameObjectDestroyed(string _id)
  {
    BaseMission_OnGameObjectDestroyed(_id);

    if (Core_IsStringStartsWith(_id, "Hangar"))
    {
      m_HangarsCount = m_HangarsCount - 1;

      if (m_HangarsCount > 0)
      {
        string message = str_MessageTitle + m_HangarsCount;

        Core_BroadcastEvent(
          "OnDisplayMessage",
          message,
          m_GoodNewsColor
        );
      }
    }

    // check for main objective
    if (m_HangarsCount == 0)
    {
      BaseMission_CompleteObjective(0);
    }
  }

  void OnMissionLoaded()
  {
    Core_SendEventTo("Helicopter", "OnInitiallyEnableTargetScreen", false);

    // Start mission music playing
    Core_SendEventTo(SOID_MusicController, "PlayMissionMusic", 3);
  }
}
