示例#1
0
    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);
    }
 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);
 }