Advertisement
Marsh_Mello

VTOLVR Loading into level

Jan 5th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.95 KB | None | 0 0
  1.     private IEnumerator LoadLevel()
  2.     {
  3.         state = ConnectionState.Loading;
  4.         Console.Log("Connection State == Loading");
  5.         VTMapManager.nextLaunchMode = VTMapManager.MapLaunchModes.Scenario;
  6.         LoadingSceneController.LoadScene(7);
  7.  
  8.         yield return new WaitForSeconds(5);
  9.         //After here we should be in the loader scene
  10.  
  11.         Console.Log("Setting Pilot");
  12.         PilotSaveManager.current = PilotSaveManager.pilots[pilotName];
  13.         Console.Log("Going though All built in campaigns");
  14.         if (VTResources.GetBuiltInCampaigns() != null)
  15.         {
  16.             foreach (VTCampaignInfo info in VTResources.GetBuiltInCampaigns())
  17.             {
  18.  
  19.                 if (vehicle == Vehicle.AV42C && info.campaignID == "av42cQuickFlight")
  20.                 {
  21.                     Console.Log("Setting Campaign");
  22.                     PilotSaveManager.currentCampaign = info.ToIngameCampaign();
  23.                     Console.Log("Setting Vehicle");
  24.                     PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle(info.vehicle);
  25.                     break;
  26.                 }
  27.  
  28.                 if (vehicle == Vehicle.FA26B && info.campaignID == "fa26bFreeFlight")
  29.                 {
  30.                     Console.Log("Setting Campaign");
  31.                     PilotSaveManager.currentCampaign = info.ToIngameCampaign();
  32.                     Console.Log("Setting Vehicle");
  33.                     PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle(info.vehicle);
  34.                     break;
  35.                 }
  36.             }
  37.         }
  38.         else
  39.             Console.Log("Campaigns are null");
  40.  
  41.         Console.Log("Going though All missions in that campaign");
  42.         foreach (CampaignScenario cs in PilotSaveManager.currentCampaign.missions)
  43.         {
  44.             Console.Log("CampaignScenario == " + cs.scenarioID);
  45.             if (cs.scenarioID == "freeFlight" || cs.scenarioID == "Free Flight")
  46.             {
  47.                 Console.Log("Setting Scenario");
  48.                 PilotSaveManager.currentScenario = cs;
  49.                 break;
  50.             }
  51.         }
  52.  
  53.         VTScenario.currentScenarioInfo = VTResources.GetScenario(PilotSaveManager.currentScenario.scenarioID, PilotSaveManager.currentCampaign);
  54.  
  55.         Console.Log(string.Format("Loading into game, Pilot:{3}, Campaign:{0}, Scenario:{1}, Vehicle:{2}",
  56.             PilotSaveManager.currentCampaign.campaignName, PilotSaveManager.currentScenario.scenarioName,
  57.             PilotSaveManager.currentVehicle.vehicleName, pilotName));
  58.  
  59.         LoadingSceneController.instance.PlayerReady(); //<< Auto Ready
  60.  
  61.         while (SceneManager.GetActiveScene().buildIndex != 7)
  62.         {
  63.             //Pausing this method till the loader scene is unloaded
  64.             yield return null;
  65.         }
  66.  
  67.         //Adding the networking script to the game which will handle all of the other stuff
  68.         gameObject.AddComponent<NetworkingManager>().mod = this;
  69.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement