# File generated by Wizard 2.9.0 on Sep 19, 2025.
advanced_behavior behavior_engage
   script_variables
      WsfWeapon missile;
      #WsfTaskManager taskManager=(WsfTaskManager)PROCESSOR;
      
   end_script_variables
   
   on_init
      missile = PLATFORM.Weapon("sam"); 
      writeln("on_init");
   end_on_init
   
   on_message
      default
         script
            WsfControlMessage msg=(WsfControlMessage)MESSAGE;
            writeln("receive",msg.AuxDataString("task"));
         end_script
   end_on_message
   
   precondition
      # writeln("precondition");
      return true;
#      return (taskManager.TasksReceivedFor(WsfTrackId(), "ENGAGE") > 0);
   end_precondition
      
   execute
#      WsfTaskList engageTasks = taskManager.ReceivedTaskList(WsfTrackId(), "ENGAGE");
#      WsfTask myTask = engageTasks.Entry(0);
#      WsfTrackId trackId = myTask.TrackId();
#      WsfLocalTrackList trackList = PLATFORM.TrackList("data_mgr");
#      WsfTrack track = trackList.FindTrack(trackId);
#      WsfTrack targetTrack = WsfSimulation.FindTrack();
#      missile.Fire(track);
#      writeln("Successfully engaged target");
      return Success();
   end_execute
   
end_advanced_behavior