public static bool Prefix(PlayerSpawn __instance) { if (PlayerManager.selectedVehicle == "") { Debug.LogError("selected vehicle is empty"); } if (PlayerManager.selectedVehicle == "FA-26B") { PlayerManager.selectedVehicle = "F/A-26B"; } VTScenario.current.vehicle = VTResources.GetPlayerVehicle(PlayerManager.selectedVehicle); PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle(PlayerManager.selectedVehicle); VTCampaignInfo[] list = VTResources.GetBuiltInCampaigns().ToArray(); string campID = " "; if (PlayerManager.selectedVehicle == "AV-42C") { campID = "av42cQuickFlight"; } else if (PlayerManager.selectedVehicle == "FA-26B") { campID = "fa26bFreeFlight"; } else { campID = "f45-quickFlight"; } Campaign campref = VTResources.GetBuiltInCampaign(campID).ToIngameCampaign(); PilotSaveManager.currentCampaign = campref; Multiplayer._instance.buttonMade = false; return(true); }
private IEnumerator LoadFromFile() { ConfigNode qsNode = ConfigNode.LoadFromFile(PilotSaveManager.saveDataPath + "/quicksave.cfg"); ConfigNode config = qsNode.GetNode("ModdedSaveFile"); foreach (var thing in config.GetNodes()) { Debug.Log(thing + "\n"); } string scenarioID = config.GetValue <String>("scenarioID"); string campaignID = config.GetValue <String>("campaignID"); Campaign campaign = new Campaign(); campaign.campaignID = campaignID; switch (config.GetValue <string>("campaignType")) { case "builtIn": campaign.isBuiltIn = true; break; case "SSS": campaign.isSteamworksStandalone = true; break; case "SS": campaign.isSteamworksStandalone = true; break; // Other is handled by not changing any vars. } VTScenarioInfo VTSI = VTResources.GetScenario(scenarioID, campaign); if (VTSI == null) { Log(" failed"); } else { if (VTResources.GetBuiltInCampaigns() != null) { using (List <VTCampaignInfo> .Enumerator enumerator = VTResources.GetBuiltInCampaigns().GetEnumerator()) { while (enumerator.MoveNext()) { VTCampaignInfo vtcampaignInfo = enumerator.Current; if (vtcampaignInfo.campaignID == campaignID) { Debug.Log("Setting Campaign"); PilotSaveManager.currentCampaign = vtcampaignInfo.ToIngameCampaign(); Debug.Log("Setting Vehicle"); PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle(vtcampaignInfo.vehicle); Debug.Log("Set campaign"); break; } } } } foreach (CampaignScenario campaignScenario in PilotSaveManager.currentCampaign.missions) { if (campaignScenario.scenarioID == scenarioID) { PilotSaveManager.currentScenario = campaignScenario; Debug.Log("Set scenario"); break; } } VTScenario.LaunchScenario(VTSI, false); while (VTMapManager.fetch == null || !VTMapManager.fetch.scenarioReady) { yield return(null); } Debug.Log("Quick Loading"); QuicksaveManager.instance.Quickload(); } }
public static bool Prefix() { if (PilotSaveManager.currentScenario.equipConfigurable == false) { return(true); } if (AEAT.trueSave == null) { Debug.LogError("True save is null."); } PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle(AEAT.trueSave.vehicleName); Debug.Log("Current scenarioID is: " + PilotSaveManager.currentScenario.scenarioID + " campaignID is " + PilotSaveManager.currentCampaign.campaignID + " and name is " + PilotSaveManager.currentVehicle.name + " and campaign name is " + PilotSaveManager.currentCampaign.campaignName); bool gotAnything = false; if (PilotSaveManager.current.GetVehicleSave(PilotSaveManager.currentVehicle.vehicleName) != null) { Debug.Log("Got the vehicle save, pog?"); } else { Debug.Log("No save not pog."); } if (PilotSaveManager.current.GetVehicleSave(PilotSaveManager.currentVehicle.vehicleName).GetCampaignSave(PilotSaveManager.currentCampaign.campaignID) != null) { Debug.Log("welp that wasn't null."); } else { Debug.Log("Campaign save is null."); } Debug.Log((bool)Traverse.Create(EndMission.instance).Field("done").GetValue() + " is done."); foreach (CampaignSave campaignSave in PilotSaveManager.current.GetVehicleSave(PilotSaveManager.currentVehicle.vehicleName).campaignSaves) { if (campaignSave.campaignID == PilotSaveManager.currentCampaign.campaignID) { Debug.Log("Got campaign id at least."); gotAnything = true; foreach (CampaignSave.CompletedScenarioInfo completedScenarioInfo in campaignSave.completedScenarios) { if (completedScenarioInfo.scenarioID == PilotSaveManager.currentScenario.scenarioID) { Debug.Log("Got both?"); gotAnything = true; } else { Debug.Log("ScenarioID " + completedScenarioInfo.scenarioID); } } } else { Debug.Log("Campaign name " + campaignSave.campaignName + " CampaignID " + campaignSave.campaignID); } } if (!gotAnything) { Debug.Log("Got nothing rip."); } return(true); }
public static bool Prefix(HPEquippable equip) { if (PilotSaveManager.currentScenario.equipConfigurable == false) { return(true); } if (!AEAT.buttonMade && VTOLAPI.currentScene == VTOLScenes.VehicleConfiguration) { foreach (var controller in GameObject.FindObjectsOfType <VRHandController>()) { if (!controller.isLeft) { GameObject button = GameObject.Instantiate(GameObject.Find("RecenterCanvas")); button.transform.SetParent(controller.transform); button.transform.localPosition = new Vector3(0.101411f, 0.02100047f, -0.128024f); button.transform.localRotation = Quaternion.Euler(-5.834f, 283.583f, 328.957f); button.transform.localScale = new Vector3(button.transform.localScale.x * -1, button.transform.localScale.y * -1, button.transform.localScale.z); VRInteractable bInteractable = button.GetComponentInChildren <VRInteractable>(); Text text = button.GetComponentInChildren <Text>(); text.transform.localScale = text.transform.localScale * 0.75f; AEAT.path = VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath.ToLower(); AEAT.path = AEAT.path.Remove(0, 9); text.text = "A.E.A.T. Super Menu"; bInteractable.interactableName = "Switch vehicle weapons\n (Current Weapons: " + AEAT.path + ")"; bInteractable.OnInteract = new UnityEngine.Events.UnityEvent(); bInteractable.transform.localPosition = new Vector3(-141f, -62f, -3f); Transform roundButtonBase1 = bInteractable.transform.parent.Find("roundButtonBase"); roundButtonBase1.localPosition = new Vector3(-141f, -62f, -3f); LoadoutConfigurator config = Resources.FindObjectsOfTypeAll <LoadoutConfigurator>()[0]; VehicleConfigSceneSetup setup = Resources.FindObjectsOfTypeAll <VehicleConfigSceneSetup>()[0]; Traverse setupHelper = Traverse.Create(setup); bInteractable.OnInteract.AddListener(delegate { if (config == null) { config = Resources.FindObjectsOfTypeAll <LoadoutConfigurator>()[0]; } switch (AEAT.path.ToLower()) { case "abomber": AEAT.path = "afighter"; break; case "afighter": AEAT.path = "asf-30"; break; case "asf-30": AEAT.path = "asf-33"; break; case "asf-33": AEAT.path = "ebomber"; break; case "ebomber": AEAT.path = "eucav"; break; case "eucav": AEAT.path = "f45a"; break; case "f45a": AEAT.path = "gav-25"; break; case "gav-25": AEAT.path = "j4"; break; case "j4": AEAT.path = "mq-31"; break; case "mq-31": AEAT.path = "vtol"; break; case "vtol": AEAT.path = "abomber"; break; default: Debug.LogWarning("Uncaught case in vehicle switcher: " + AEAT.path); AEAT.path = "vtol"; break; } //text.text = "Weapons: " + AEAT.path; bInteractable.interactableName = "Switch vehicle weapons\n (Current Weapons: " + AEAT.path + ")"; Debug.Log(AEAT.path + " is AEAT.path"); //Debug.Log(text.text + " is weapons text"); VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath = "hpequips/" + AEAT.path; config.wm.resourcePath = VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath; Debug.Log(AEAT.path); PilotSaveManager.currentVehicle.equipsResourcePath = "hpequips/" + AEAT.path; List <string> marsh = new List <string>(); List <GameObject> ketkev = new List <GameObject>(); Dictionary <string, EqInfo> lol = new Dictionary <string, EqInfo>(); foreach (var gameobject in Resources.LoadAll <GameObject>("hpequips/" + AEAT.path)) { if (!AllowedEquips.allowedEquips.Contains(gameobject.name)) { Debug.Log("Unauthorized gameobject " + gameobject.name); continue; } marsh.Add(gameobject.name); ketkev.Add(gameobject); } config.availableEquipStrings = marsh; PilotSaveManager.currentVehicle.allEquipPrefabs = ketkev; Traverse.Create(config).Field("unlockedWeaponPrefabs").SetValue(new Dictionary <string, EqInfo>()); Traverse.Create(config).Field("allWeaponPrefabs").SetValue(new Dictionary <string, EqInfo>()); config.lockedHardpoints = new List <int>(); // making sure all hardpoints are unlocked for (int i = 0; i < config.wm.hardpointTransforms.Length; i++) { config.Detach(i); } config.Initialize(PilotSaveManager.current.GetVehicleSave(PilotSaveManager.currentVehicle.vehicleName).GetCampaignSave(PilotSaveManager.currentCampaign.campaignID), false); if (config.fullInfo != null) { config.fullInfo.CloseInfo(); } }); Debug.Log("Made right hand bottom button."); button = GameObject.Instantiate(bInteractable.gameObject, bInteractable.transform.parent); Debug.Log("Current vehicle name is " + PilotSaveManager.currentVehicle.name); button.transform.localPosition = new Vector3(147f, -62f, -3f); VRInteractable bInteractable2 = button.GetComponent <VRInteractable>(); //Text text2 = button.GetComponentInChildren<Text>(); //text2.transform.localScale = text2.transform.localScale * 0.75f; //text2.text = PilotSaveManager.currentVehicle.name; bInteractable2.interactableName = "Switch Vehicles"; bInteractable2.OnInteract = new UnityEvent(); foreach (var vehicle in VTResources.GetPlayerVehicles()) { Debug.Log(vehicle.name); Debug.Log(vehicle.vehicleName); } bInteractable2.OnInteract.AddListener(delegate { if (PilotSaveManager.currentVehicle.name == "AV-42C") { PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle("F/A-26B"); } else if (PilotSaveManager.currentVehicle.name == "FA-26B") { PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle("F-45A"); } else { PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle("AV-42C"); } //text2.text = PilotSaveManager.currentVehicle.vehicleName; AEAT.selectedVehicle = PilotSaveManager.currentVehicle; if (VTOLAPI.currentScene == VTOLScenes.VehicleConfiguration) { AEAT.buttonMade = false; Debug.Log("Resetting up scene."); SceneManager.LoadScene("VehicleConfiguration"); } }); Transform bigButton2 = GameObject.Instantiate(roundButtonBase1, roundButtonBase1.parent); bigButton2.localPosition = bInteractable2.transform.localPosition; AEAT.trueSave = PilotSaveManager.current.GetVehicleSave(PilotSaveManager.currentVehicle.vehicleName).GetCampaignSave(PilotSaveManager.currentCampaign.campaignID); Debug.Log("Made right hand top button, and true save's id is " + AEAT.trueSave.campaignID); break; } } AEAT.buttonMade = true; } equip.allowedHardpoints = "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30"; equip.unitCost = 0f; return(true); }
IEnumerator RespawnTimer() { Debug.Log("Starting respawn timer."); GameObject button = Multiplayer.CreateVehicleButton(); yield return(new WaitForSeconds(respawnTimer)); Destroy(button); Debug.Log("Finished respawn timer."); ReArmingPoint[] rearmPoints = GameObject.FindObjectsOfType <ReArmingPoint>(); ReArmingPoint rearmPoint = rearmPoints[Random.Range(0, rearmPoints.Length - 1)]; float lastRadius = 0; if (PlayerManager.carrierStart) { foreach (ReArmingPoint rep in rearmPoints) { if (rep.team == Teams.Allied) { if (rep.radius > 17.8f && rep.radius < 19.0f) { rearmPoint = rep; } } } } else { foreach (ReArmingPoint rep in rearmPoints) { Debug.Log("finding rearm pt"); if (rep.team == Teams.Allied && rep.CheckIsClear(actor)) { if (rep.radius > lastRadius) { rearmPoint = rep; lastRadius = rep.radius; } } } } //UnEject(); //PutPlayerBackInAircraft(); //RepairAircraft(); //foreach (GearAnimator gear in gears) { // gear.ExtendImmediate(); //} //GetComponent<Rigidbody>().velocity = Vector3.zero; //transform.position = rearmPoint.transform.position + Vector3.up * 10; //transform.rotation = rearmPoint.transform.rotation; Destroy(VTOLAPI.GetPlayersVehicleGameObject()); Destroy(detacher.cameraRig); Destroy(detacher.gameObject); Destroy(ejection.gameObject); Destroy(BlackoutEffect.instance); Destroy(GetComponent <PlayerSpawn>()); foreach (EngineEffects effect in effects) { Destroy(effect); } //as much stuff as im destroying, some stuff is most likely getting through, future people, look into this AudioController.instance.ClearAllOpenings(); UnitIconManager.instance.UnregisterAll(); TargetManager.instance.detectedByAllies.Clear(); TargetManager.instance.detectedByEnemies.Clear(); foreach (var actor in TargetManager.instance.allActors) { if (actor != null) { actor.discovered = false; actor.drawIcon = true; //actor.DiscoverActor(); actor.permanentDiscovery = true; Traverse.Create(actor).Field("detectedByAllied").SetValue(false); Traverse.Create(actor).Field("detectedByEnemy").SetValue(false); if (actor.team == Teams.Allied) { actor.DetectActor(Teams.Allied); actor.UpdateKnownPosition(actor.team); } //actor.DiscoverActor(); <----------------breaks and only works on every 2nd spawn // UnitIconManager.instance.RegisterIcon(actor, 0.07f * actor.iconScale, actor.iconOffset); } } if (PlayerManager.selectedVehicle == "FA-26B") { PlayerManager.selectedVehicle = "F/A-26B"; } PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle(PlayerManager.selectedVehicle); string campID; if (PlayerManager.selectedVehicle == "AV-42C") { campID = "av42cQuickFlight"; } else if (PlayerManager.selectedVehicle == "F/A-26B") { campID = "fa26bFreeFlight"; } else { campID = "f45-quickFlight"; } Campaign campref = VTResources.GetBuiltInCampaign(campID).ToIngameCampaign(); PilotSaveManager.currentCampaign = campref; if (PilotSaveManager.currentVehicle == null) { Debug.LogError("current vehicle is null"); } GameObject newPlayer = Instantiate(PilotSaveManager.currentVehicle.vehiclePrefab); if (newPlayer == null) { Debug.LogError("new vehicle is null"); } newPlayer.GetComponent <Actor>().designation = FlightSceneManager.instance.playerActor.designation;//reassigning designation FlightSceneManager.instance.playerActor = newPlayer.GetComponent <Actor>(); FlightSceneManager.instance.playerActor.flightInfo.PauseGCalculations(); FlightSceneManager.instance.playerActor.flightInfo.OverrideRecordedAcceleration(Vector3.zero); rearmPoint.voiceProfile.PlayMessage(GroundCrewVoiceProfile.GroundCrewMessages.Success); PilotSaveManager.currentScenario.totalBudget = 999999; PilotSaveManager.currentScenario.initialSpending = 0; PilotSaveManager.currentScenario.inFlightSpending = 0; PilotSaveManager.currentScenario.equipConfigurable = true; PlayerVehicleSetup pvSetup = newPlayer.GetComponent <PlayerVehicleSetup>(); pvSetup.SetupForFlight(); Rigidbody rb = newPlayer.GetComponent <Rigidbody>(); GearAnimator gearAnim = newPlayer.GetComponent <GearAnimator>(); if (gearAnim != null) { if (gearAnim.state != GearAnimator.GearStates.Extended) { gearAnim.ExtendImmediate(); } } // PlayerManager.StartRearm(rearmPoint); //rb.velocity = Vector3.zero; //rb.detectCollisions = true; PlayerManager.SpawnLocalVehicleAndInformOtherClients(newPlayer, newPlayer.transform.position, newPlayer.transform.rotation, networkUID); //PlayerManager.SetupLocalAircraft(newPlayer, newPlayer.transform.position, newPlayer.transform.rotation, networkUID); lastMessage.UID = networkUID; lastMessage.isLeftie = PlayerManager.teamLeftie; lastMessage.tagName = Steamworks.SteamFriends.GetPersonaName(); lastMessage.vehicle = VTOLAPI.GetPlayersVehicleEnum(); if (Networker.isHost) { NetworkSenderThread.Instance.SendPacketAsHostToAllClients(lastMessage, Steamworks.EP2PSend.k_EP2PSendReliable); } else { NetworkSenderThread.Instance.SendPacketToSpecificPlayer(Networker.hostID, lastMessage, Steamworks.EP2PSend.k_EP2PSendReliable); } }
public static GameObject CreateVehicleButton() { foreach (var controller in GameObject.FindObjectsOfType <VRHandController>()) { GameObject button; if (canvasButtonPrefab == null) { button = GameObject.Instantiate(GameObject.Find("RecenterCanvas")); } else { button = GameObject.Instantiate(canvasButtonPrefab); button.SetActive(true); } if (!controller.isLeft) { Debug.Log("Current vehicle name is " + PilotSaveManager.currentVehicle.name); button.transform.SetParent(controller.transform); button.transform.localPosition = new Vector3(0.101411f, 0.02100047f, -0.128024f); button.transform.localRotation = Quaternion.Euler(-5.834f, 283.583f, 328.957f); button.transform.localScale = new Vector3(button.transform.localScale.x * -1, button.transform.localScale.y * -1, button.transform.localScale.z); VRInteractable bInteractable = button.GetComponentInChildren <VRInteractable>(); Text text = button.GetComponentInChildren <Text>(); text.transform.localScale = text.transform.localScale * 0.75f; text.text = PilotSaveManager.currentVehicle.name; bInteractable.interactableName = "Switch Vehicles."; bInteractable.OnInteract = new UnityEvent(); PlayerManager.selectedVehicle = PilotSaveManager.currentVehicle.name; foreach (var vehicle in VTResources.GetPlayerVehicles()) { Debug.Log(vehicle.name); Debug.Log(vehicle.vehicleName); } bInteractable.OnInteract.AddListener(delegate { if (PilotSaveManager.currentVehicle.name == "AV-42C") { PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle("F/A-26B"); } else if (PilotSaveManager.currentVehicle.name == "FA-26B") { PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle("F-45A"); } else { PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle("AV-42C"); } text.text = PilotSaveManager.currentVehicle.name; PlayerManager.selectedVehicle = text.text; if (VTOLAPI.currentScene == VTOLScenes.VehicleConfiguration) { // BPilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle(PlayerManager.selectedVehicle); string campID; if (PlayerManager.selectedVehicle == "AV-42C") { campID = "av42cQuickFlight"; } else if (PlayerManager.selectedVehicle == "FA-26B") { campID = "fa26bFreeFlight"; } else { campID = "f45-quickFlight"; } Campaign campref = VTResources.GetBuiltInCampaign(campID).ToIngameCampaign(); PilotSaveManager.currentCampaign = campref; Multiplayer._instance.buttonMade = false; SceneManager.LoadScene("VehicleConfiguration"); } }); } if (canvasButtonPrefab == null) { canvasButtonPrefab = Instantiate(GameObject.Find("RecenterCanvas")); canvasButtonPrefab.SetActive(false); DontDestroyOnLoad(canvasButtonPrefab); } Multiplayer._instance.buttonMade = true; return(button); } return(null); }