//$reference Campaign.dll
//-$debug
using System;
using maddox.game;
using maddox.game.world;
using System.Collections.Generic;

public class Mission : maddox.game.campaign.Mission {

    public override void OnBattleStarted() {
        base.OnBattleStarted();
    }

    public override void OnTrigger(int missionNumber, string shortName, bool active) {
        if ("trigger01".Equals(shortName) && active) {
            
            AiAction action = GamePlay.gpGetAction(ActorName.Full(missionNumber, "JG26_17"));
            if (action != null)
                action.Do();
	if (Campaign != null) {
        if (Campaign.battleSuccess != null)
        return;
        Campaign.battleSuccess = true;


            GamePlay.gpGetTrigger(shortName).Enable = false;
        }
    }

    public override bool IsMissionListener(int missionNumber) {
            return true;
    }


  private void checkLanded(AiAircraft aircraft) {
      if (GamePlay.gpPlayer().Place() != aircraft)
          return;
      GamePlay.gpHUDLogCenter("Press Esc to end mission.");
  }

  public override void OnAircraftLanded(int missionNumber, string shortName, AiAircraft aircraft) {
      checkLanded(aircraft);
  }

  public override void OnAircraftCrashLanded(int missionNumber, string shortName, AiAircraft aircraft) {
      checkLanded(aircraft);
  }

}
