static bool Prefix(MFDVehicleOptions __instance)
    {
        Traverse mfdTraverse = new Traverse(__instance);

        Debug.Log("measurements");
        MeasurementManager measurements = (MeasurementManager)mfdTraverse.Field("measurements").GetValue();

        Debug.Log("mfdPage");
        object  obj1    = mfdTraverse.Field("mfdPage").GetValue();
        MFDPage mfdPage = null;

        if (obj1 != null)
        {
            mfdPage = (MFDPage)obj1;
        }

        Debug.Log("portalPage");
        object        obj2       = mfdTraverse.Field("portalPage").GetValue();
        MFDPortalPage portalPage = null;

        if (obj2 != null)
        {
            portalPage = (MFDPortalPage)obj2;
        }

        Bananaspersecond.speedMode = (Bananaspersecond.speedMode + 1) % Bananaspersecond.units.measurementSpeedUnits.Count;
        Bananaspersecond.UpdateDisplay(measurements, mfdPage, portalPage);
        return(false);
    }
예제 #2
0
    public static void UpdateDisplay(MeasurementManager measurements, MFDPage mfdPage, MFDPortalPage portalPage)
    {
        string text  = units.measurementAltUnits[altMode].name;
        string text2 = units.measurementDistUnits[distMode].name;
        string text3 = units.measurementSpeedUnits[speedMode].name;

        if (mfdPage)
        {
            mfdPage.SetText("AltModeText", text);
            mfdPage.SetText("DistModeText", text2);
            mfdPage.SetText("SpeedModeText", text3);
            return;
        }
        if (portalPage)
        {
            portalPage.SetText("AltModeText", text);
            portalPage.SetText("DistModeText", text2);
            portalPage.SetText("SpeedModeText", text3);
        }
    }
예제 #3
0
    private IEnumerator main()
    {
        while (VTMapManager.fetch == null || !VTMapManager.fetch.scenarioReady || FlightSceneManager.instance.switchingScene)
        {
            yield return(null);
        }
        // Main code here
        buttonMade = false;
        Debug.Log("AAAAAAAA");
        wm             = VTOLAPI.GetPlayersVehicleGameObject().GetComponent <WeaponManager>();
        inf            = VTOLAPI.GetPlayersVehicleGameObject().AddComponent <infAmmo>();
        inf.enabled    = false;
        paired         = VTOLAPI.GetPlayersVehicleGameObject().AddComponent <PairedGuns>();
        paired.enabled = false;
        if (VTOLAPI.GetPlayersVehicleEnum() != VTOLVehicles.F45A)
        {
            WeaponManagerUI wmUI = wm.ui;
            Debug.Log("wmUI");
            mfd = wmUI.mfdPage;
            if (mfd == null)
            {
                Debug.LogError("OOPIES.");
            }
            mfd.OnActivatePage.AddListener(new UnityAction(() =>
            {
                lastMFD = mfd.mfd;
                Debug.Log("=");
                MFDPage.MFDButtonInfo[] allButtons = mfd.buttons;
                MFDPage.MFDButtonInfo newButton    = new MFDPage.MFDButtonInfo();
                newButton.button  = MFD.MFDButtons.T4;
                newButton.toolTip = "Toggle infinite ammo";
                newButton.label   = "infAmmo";
                newButton.OnPress.AddListener(new UnityAction(() =>
                {
                    AEAT.inf.enabled = !AEAT.inf.enabled;
                    mfd.mfd.buttons[13].GetComponentInChildren <Text>().color = AEAT.inf.enabled ? Color.green : Color.red;
                }));
                if (mfd.mfd == null)
                {
                    Debug.LogError("FOUND YA!");
                }
                MFDPage.MFDButtonInfo newButton2 = new MFDPage.MFDButtonInfo();
                newButton2.button  = MFD.MFDButtons.T2;
                newButton2.toolTip = "Pair all guns";
                newButton2.label   = "pairGuns";
                newButton2.OnPress.AddListener(new UnityAction(() =>
                {
                    AEAT.paired.enabled = !AEAT.paired.enabled;
                    Debug.Log("Button pressed.");
                    mfd.mfd.buttons[11].GetComponentInChildren <Text>().color = AEAT.paired.enabled && wm.equippedGun ? Color.green : Color.red;
                }));
                mfd.SetPageButton(newButton);
                mfd.SetPageButton(newButton2);
                mfd.mfd.buttons[13].GetComponentInChildren <Text>().color = AEAT.inf.enabled ? Color.green : Color.red;
                mfd.mfd.buttons[11].GetComponentInChildren <Text>().color = AEAT.paired.enabled ? Color.green : Color.red;
            }));
            mfd.OnDeactivatePage.AddListener(new UnityAction(() =>
            {
                if (lastMFD != null)
                {
                    lastMFD.buttons[13].GetComponentInChildren <Text>().color = Color.white;
                    lastMFD.buttons[11].GetComponentInChildren <Text>().color = Color.white;
                    lastMFD = null;
                }
            }));
        }
        else
        {
            AEAT.MFDP = wm.gameObject.GetComponentInChildren <MFDPortalManager>();
            MFDPStoresManagement MFDP = (MFDPStoresManagement)AEAT.MFDP.gameObject.GetComponentInChildren <MFDPortalManager>().pages[5];
            Debug.Log("got MFPD");
            GameObject toCopy = null;
            foreach (var resource in Resources.FindObjectsOfTypeAll <VRInteractable>())
            {
                if (resource.interactableName == "Weapon Bay Door Overrides")
                {
                    toCopy = resource.gameObject;
                    break;
                }
            }
            if (toCopy == null)
            {
                Debug.LogError("To copy is null");
            }
            GameObject    emptyButton = Instantiate(toCopy, MFDP.displayObj.gameObject.transform);
            RectTransform rt          = emptyButton.GetComponent <RectTransform>();
            AEAT.text1       = emptyButton.gameObject.GetComponentInChildren <Text>();
            rt.localPosition = new Vector3(rt.localPosition.x - 50, rt.localPosition.y, rt.localPosition.z);
            rt.localScale    = new Vector3(rt.localScale.x * 0.85f, rt.localScale.y * 0.85f, rt.localScale.z * 0.85f);
            rt.GetComponentInChildren <Image>().color = Color.black;
            Debug.Log("instantiate");
            VRInteractable interactable = emptyButton.GetComponentInChildren <VRInteractable>();
            Debug.Log("vr interactable");
            Text text = emptyButton.GetComponentInChildren <Text>();
            Debug.Log("text");
            text.text = "infAmmo";
            Debug.Log("infAmmo");
            interactable.OnInteract = new UnityEvent();
            Debug.Log("new UnityEvent()");
            interactable.interactableName = "Toggle infinite ammo";
            Debug.Log("toggle infinite ammo");
            interactable.OnInteract.AddListener(new UnityAction(() =>
            {
                AEAT.inf.enabled = !AEAT.inf.enabled;
                AEAT.MFDP.PlayInputSound();
                AEAT.text1.color = AEAT.inf.enabled ? Color.green : Color.red;
            }));
            Debug.Log("listener");
            AEAT.text1.color = AEAT.inf.enabled ? Color.green : Color.red;

            GameObject    emptyButton2 = Instantiate(toCopy, MFDP.displayObj.gameObject.transform);
            RectTransform rt2          = emptyButton2.GetComponent <RectTransform>();
            rt2.localPosition = new Vector3(rt2.localPosition.x - 85, rt.localPosition.y, rt.localPosition.z);
            rt2.localScale    = new Vector3(rt2.localScale.x * 0.85f, rt2.localScale.y * 0.85f, rt2.localScale.z * 0.85f);
            rt2.GetComponentInChildren <Image>().color = Color.black;
            Debug.Log("instantiate");
            VRInteractable interactable2 = emptyButton2.GetComponentInChildren <VRInteractable>();
            Debug.Log("vr interactable");
            text2 = emptyButton2.GetComponentInChildren <Text>();
            Debug.Log("text");
            text2.text = "pairGuns";
            Debug.Log("pairGuns");
            interactable2.OnInteract = new UnityEvent();
            Debug.Log("new UnityEvent()");
            interactable2.interactableName = "Pair All Guns";
            Debug.Log("Pair all guns");
            interactable2.OnInteract.AddListener(new UnityAction(() =>
            {
                AEAT.paired.enabled = !AEAT.paired.enabled;
                AEAT.MFDP.PlayInputSound();
                AEAT.text2.color = AEAT.paired.enabled ? Color.green : Color.red;
            }));
            AEAT.text2.color = AEAT.paired.enabled ? Color.green : Color.red;
        }
    }