public static bool Prefix(string weaponName, int hpIdx, LoadoutConfigurator __instance) { if (weaponName != "Nuke") { Debug.Log("Prefix 0 true"); return(true); } Debug.Log("Prefix 0 false."); Transform transform = PatcherHelper.nukeObject.transform; Debug.Log("TRANSFORM"); __instance.equips[hpIdx] = transform.GetComponent <HPEquippable>(); // Traverse traverse = Traverse.Create<LoadoutConfigurator>().Field("hpTransforms"); Transform[] transforms = __instance.wm.hardpointTransforms; transform.parent = transforms[hpIdx]; transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; transform.localScale = Vector3.one; // __instance.equips[hpIdx].OnConfigAttach(__instance); /*if (__instance.OnAttachHPIdx != null) * { * __instance.OnAttachHPIdx(hpIdx); * }*/ __instance.UpdateNodes(); return(false); }
public static void Postfix(LoadoutConfigurator __instance) { Debug.Log("Doing postfix."); Traverse traverse = Traverse.Create(__instance); GameObject gameObject = PatcherHelper.nukeObject; if (gameObject) { GameObject toInject = GameObject.Instantiate <GameObject>(gameObject); toInject.name = "Nuke"; // GameObject equipper = toInject.transform.GetChild(1).gameObject; GameObject edgeTransform = toInject.transform.GetChild(0).gameObject; Nuke nuke = gameObject.AddComponent <Nuke>(); nuke.edgeTransform = edgeTransform; nuke.equipper = GameObject.Instantiate(new GameObject()); nuke.equipper.name = "Nuke"; Debug.Log("Nuke added to EqInfo in postfix."); nuke.init(); nuke.missileLauncher.LoadAllMissiles(); toInject.SetActive(false); Debug.Log("Start eq info"); Dictionary <string, EqInfo> unlockedWeaponPrefabs = (Dictionary <string, EqInfo>)traverse.Field("unlockedWeaponPrefabs").GetValue(); Debug.Log("Got eq info."); EqInfo eq = new EqInfo(nuke.equipper, Environment.CurrentDirectory + "\\VTOLVR_ModLoader\\mods\\Nuke\\nukey"); Debug.Log("New eq"); /*eq.eq = nuke.HPEquipper; * Debug.Log("Eq.eq"); * eq.eqObject = nuke.HPEquipper.gameObject; * Debug.Log("Eq.eqObject");*/ unlockedWeaponPrefabs.Add("B61", eq); // Sadly can't prefix a method so shitty shit shit Debug.Log("Add to list."); traverse.Field("unlockedWeaponPrefabs").SetValue(unlockedWeaponPrefabs); Debug.Log("Postfix 200."); } else { Debug.LogError("Nuke not found in AssetBundle."); } }
public static bool Prefix(ref CampaignSave __result, string campaignID) { if (!(VTOLAPI.currentScene == VTOLScenes.VehicleConfiguration) || AEAT.trueSave == null) { //Debug.Log("Not spoofing this save."); return(true); } Debug.Log(AEAT.trueSave.campaignID + " will be used as a campaign save."); __result = AEAT.trueSave; if (!AEAT.buttonMade) { Debug.Log(AEAT.path + " is AEAT.path"); VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath = "hpequips/" + AEAT.path; LoadoutConfigurator config = Resources.FindObjectsOfTypeAll <LoadoutConfigurator>()[0]; config.wm.resourcePath = VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath; PilotSaveManager.currentVehicle.equipsResourcePath = "hpequips/" + AEAT.path; List <string> marsh = new List <string>(); List <GameObject> ketkev = new List <GameObject>(); 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); } 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>(); VTResources.GetScenario(PilotSaveManager.currentScenario.scenarioID, PilotSaveManager.currentCampaign).allowedEquips = marsh; __result.availableWeapons = marsh; Debug.Log("Set allowedEquips."); PilotSaveManager.currentVehicle.allEquipPrefabs = ketkev; // Don't need to reinit the config because this is prefixing the init statement } return(false); }
public static void Postfix(RearmingUnitSpawn __instance) { if (PilotSaveManager.currentScenario.equipConfigurable == false) { return; } VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath = "hpequips/" + AEAT.path; LoadoutConfigurator config = (LoadoutConfigurator)Traverse.Create(__instance).Field("config").GetValue(); 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); lol.Add(gameobject.name, new EqInfo(gameobject, AEAT.path)); } 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.Initialize(PilotSaveManager.current.GetVehicleSave(PilotSaveManager.currentVehicle.vehicleName).GetCampaignSave(PilotSaveManager.currentCampaign.campaignID), false); if (config.fullInfo != null) { config.fullInfo.CloseInfo(); } }
public static bool Prefix(int hpIdx, string weaponName, LoadoutConfigurator __instance) { if (weaponName != "Nuke") { Debug.Log("Prefix 69 true"); return(true); } Debug.Log("Prefix 69 false"); GameObject instantiated = PatcherHelper.nukeObject; instantiated.SetActive(true); Nuke nuke = instantiated.AddComponent <Nuke>(); GameObject equipper = new GameObject(); GameObject edgeTransform = instantiated.transform.GetChild(0).gameObject; nuke.edgeTransform = edgeTransform; nuke.equipper = equipper; equipper.SetActive(true); Debug.Log("Nuke added."); nuke.init(); Debug.Log("PH instantiate"); Transform weaponTf = equipper.transform; nuke.missileLauncher.LoadAllMissiles(); Debug.Log("wTf transform"); // Traverse hpTransformsTraverse = Traverse.Create<LoadoutConfigurator>().Field("hpTransforms"); Debug.Log("traverse hpTransforms"); Transform[] transforms = __instance.wm.hardpointTransforms; Debug.Log("get"); Transform hpTf = transforms[hpIdx]; Debug.Log("hpTf = transforms"); InternalWeaponBay iwb = null; Debug.Log("null iwb"); // Traverse iwbAttachTraverse = Traverse.Create<LoadoutConfigurator>().Field("iwbAttach"); MethodInfo dynMethod = __instance.GetType().GetMethod("iwbAttach", BindingFlags.NonPublic | BindingFlags.Instance); Debug.Log("dyn method"); // object iwbAttach = (InternalWeaponBay)dynMethod.Invoke(__instance, null); Debug.Log("iwb attach"); // object iwbAttach = iwbAttachTraverse.GetValue(__instance); /*for (int i = 0; i < __instance.wm.internalWeaponBays.Length; i++) * { * InternalWeaponBay internalWeaponBay = __instance.wm.internalWeaponBays[i]; * if (internalWeaponBay.hardpointIdx == hpIdx) * { * iwb = internalWeaponBay; * iwb.RegisterOpenReq(iwbAttach); * } * }*/ Debug.Log("iterator"); __instance.equips[hpIdx] = weaponTf.GetComponent <HPEquippable>(); Debug.Log("equips weaponTf"); // __instance.equips[hpIdx].OnConfigAttach(__instance); // Debug.Log("__instance,equips onconfigtattach"); weaponTf.rotation = hpTf.rotation; Debug.Log("ROTATIOENATEAITJAOTATATETED"); Vector3 localPos = new Vector3(0f, -4f, 0f); Debug.Log("create localPos"); weaponTf.position = hpTf.TransformPoint(localPos); Debug.Log("Position"); __instance.UpdateNodes(); Debug.Log("Update Nodes"); Vector3 tgt = new Vector3(0f, 0f, 0.5f); Debug.Log("tgt"); if (hpIdx == 0 || iwb) { tgt = Vector3.zero; } Debug.Log("if vector3"); while ((localPos - tgt).sqrMagnitude > 0.01f) { localPos = Vector3.Lerp(localPos, tgt, 5f * Time.deltaTime); weaponTf.position = hpTf.TransformPoint(localPos); } Debug.Log("while"); weaponTf.parent = hpTf; Debug.Log("parent"); weaponTf.localPosition = tgt; Debug.Log("localPosition = tgt"); weaponTf.localRotation = Quaternion.identity; Debug.Log("Quaternion.identity"); __instance.vehicleRb.AddForceAtPosition(Vector3.up * __instance.equipImpulse, __instance.wm.hardpointTransforms[hpIdx].position, ForceMode.Impulse); Debug.Log("ADD FORCE AT POSITION! POGGERS"); /*Traverse hpAudioSourcesTraverse = Traverse.Create<LoadoutConfigurator>().Field("hpAudioSources"); * Debug.Log("hpAudioSourcesTraverse created!"); * AudioSource[] hpAudioSources = (AudioSource[])hpTransformsTraverse.GetValue(__instance);*/ AudioSource audioSource = new GameObject("HPAudio").AddComponent <AudioSource>(); audioSource.transform.parent = __instance.gameObject.transform; audioSource.transform.position = hpTf.position; audioSource.spatialBlend = 1f; audioSource.minDistance = 4f; audioSource.maxDistance = 1000f; audioSource.dopplerLevel = 0f; Debug.Log("hpAudioSources 200"); audioSource.PlayOneShot(__instance.attachAudioClip); Debug.Log("play 1 shot"); __instance.attachPs.transform.position = hpTf.position; Debug.Log("Attach p's transform"); __instance.attachPs.FireBurst(); Debug.Log("FireBurst()"); while (weaponTf.localPosition.sqrMagnitude > 0.001f) { weaponTf.localPosition = Vector3.MoveTowards(weaponTf.localPosition, Vector3.zero, 4f * Time.deltaTime); } Debug.Log("While 2 or 3 i dont remember or give a f**k"); /*if (iwb) * { * iwb.UnregisterOpenReq(iwbAttach); * } * Debug.Log("iwb unregister");*/ weaponTf.localPosition = Vector3.zero; Debug.Log("Vector3.zero"); __instance.UpdateNodes(); Debug.Log("UpdateNodes called, we're all done! Return false time;!!!!!!!!!"); return(false); }
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); }