コード例 #1
0
        public void SpawnedArm(Exosuit exosuit)
        {
            NitroxId     id           = NitroxEntity.GetId(exosuit.gameObject);
            ExosuitModel exosuitModel = vehicles.GetVehicles <ExosuitModel>(id);

            IExosuitArm rightArm = exosuit.rightArm;
            IExosuitArm leftArm  = exosuit.leftArm;

            try
            {
                GameObject rightArmGameObject = rightArm.GetGameObject();
                NitroxEntity.SetNewId(rightArmGameObject, exosuitModel.RightArmId);

                GameObject leftArmGameObject = leftArm.GetGameObject();
                NitroxEntity.SetNewId(leftArmGameObject, exosuitModel.LeftArmId);
            }
            catch (Exception e)
            {
                Log.Warn("Got error setting arm GameObjects. This is probably due to docking sync and can be ignored\nErromessage: " + e.Message + "\n" + e.StackTrace);
            }

            Log.Debug("Spawn exosuit arms for: " + id);
        }
コード例 #2
0
        private static void Postfix(Exosuit __instance)
        {
            Logger.Log("Exosuit Awake");
            var toggleLights       = __instance.GetComponent <ToggleLights>();
            var seamothPrefab      = Resources.Load <GameObject>("WorldEntities/Tools/SeaMoth");
            var toggleLightsPrefab = seamothPrefab.GetComponent <SeaMoth>().toggleLights;

            if (toggleLights == null)
            {
                toggleLights = ModUtils.CopyComponent(toggleLightsPrefab, __instance.gameObject);
            }
            else
            {
                toggleLights.lightsOnSound   = toggleLightsPrefab.lightsOnSound;
                toggleLights.lightsOffSound  = toggleLightsPrefab.lightsOffSound;
                toggleLights.onSound         = toggleLightsPrefab.onSound;
                toggleLights.offSound        = toggleLightsPrefab.offSound;
                toggleLights.energyPerSecond = toggleLightsPrefab.energyPerSecond;
            }

            toggleLights.lightsParent = __instance.transform.Find("lights_parent").gameObject;
            toggleLights.energyMixin  = __instance.GetComponent <EnergyMixin>();
        }
コード例 #3
0
        public void OnHit()
        {
            if (Exosuit.CanPilot() && Exosuit.GetPilotingMode())
            {
                Vector3    position     = default(Vector3);
                GameObject targetObject = null;

                UWE.Utils.TraceFPSTargetPosition(Exosuit.gameObject, 6.5f, ref targetObject, ref position, true);

                if (targetObject == null)
                {
                    InteractionVolumeUser component = Player.main.gameObject.GetComponent <InteractionVolumeUser>();
                    if (component != null && component.GetMostRecent() != null)
                    {
                        targetObject = component.GetMostRecent().gameObject;
                    }
                }
                if (targetObject)
                {
                    LiveMixin liveMixin = targetObject.FindAncestor <LiveMixin>();
                    if (liveMixin)
                    {
                        bool flag = liveMixin.IsAlive();
                        liveMixin.TakeDamage(50f, position, DamageType.Normal, null);
                        Utils.PlayFMODAsset(hitFishSound, front, 50f);
                    }
                    else
                    {
                        Utils.PlayFMODAsset(hitTerrainSound, front, 50f);
                    }
                    VFXSurface component2 = targetObject.GetComponent <VFXSurface>();
                    Vector3    euler      = MainCameraControl.main.transform.eulerAngles + new Vector3(300f, 90f, 0f);
                    VFXSurfaceTypeManager.main.Play(component2, vfxEventType, position, Quaternion.Euler(euler), Exosuit.gameObject.transform);
                    targetObject.SendMessage("BashHit", this, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
コード例 #4
0
    public static void AddSuitToLoad(int suitId, SuitAsset.SuitType model_type, int Priority)
    {
        if (mInstance == null)
        {
            Debug.Log("<< mInstance is null ");
        }
        foreach (SuitAsset item in mInstance.mAssetQueue)
        {
            if (item == null)
            {
                Debug.Log("<< Suit is null " + mInstance.mAssetQueue.Count);
            }
            if (item.mSuitID == suitId && item.mModelType == model_type)
            {
                if (item.mPriority != Priority)
                {
                    item.mPriority = Priority;
                    mInstance.mAssetQueue.Sort(ComparePriority);
                }
                return;
            }
        }
        Exosuit exosuit = GameData.getExosuit(suitId);

        if (exosuit != null)
        {
            string    mSuitFileName = exosuit.mSuitFileName;
            string    str           = mSuitFileName + "_" + model_type + ".unity3d";
            SuitAsset suitAsset2    = new SuitAsset();
            suitAsset2.mSuitID    = suitId;
            suitAsset2.mPriority  = Priority;
            suitAsset2.myFilename = "suits/" + str;
            suitAsset2.mModelType = model_type;
            mInstance.mAssetQueue.Add(suitAsset2);
            mInstance.mAssetQueue.Sort(ComparePriority);
        }
    }
コード例 #5
0
        public void FixedUpdate()
        {
            if (hook.attached)
            {
                grapplingLoopSound.Play();

                Vector3 value     = hook.transform.position - front.position;
                Vector3 a         = Vector3.Normalize(value);
                float   magnitude = value.magnitude;

                if (magnitude > 1f)
                {
                    if (!IsUnderwater() && Exosuit.transform.position.y + 0.2f >= grapplingStartPos.y)
                    {
                        a.y = Mathf.Min(a.y, 0f);
                    }

                    Exosuit.GetComponent <Rigidbody>().AddForce(a * exosuitGrapplingAccel, ForceMode.Acceleration);
                    hook.GetComponent <Rigidbody>().AddForce(-a * 400f, ForceMode.Force);
                }

                rope.SetIsHooked();
            }
            else if (hook.flying)
            {
                if ((hook.transform.position - front.position).magnitude > maxDistance)
                {
                    ResetHook();
                }
                grapplingLoopSound.Play();
            }
            else
            {
                grapplingLoopSound.Stop();
            }
        }
コード例 #6
0
        public void Awake()
        {
            thisExosuit     = GetComponent <Exosuit>();
            energyMixin     = thisExosuit.GetComponent <EnergyMixin>();
            handReticleMain = HandReticle.main;

            scan_loop       = ScriptableObject.CreateInstance <FMODAsset>();
            scan_loop.name  = "scan_loop";
            scan_loop.path  = "event:/tools/scanner/scan_loop";
            scanSound       = gameObject.AddComponent <FMOD_CustomLoopingEmitter>();
            scanSound.asset = scan_loop;

            completeSound      = ScriptableObject.CreateInstance <FMODAsset>();
            completeSound.name = "scan_complete";
            completeSound.path = "event:/tools/scanner/scan_complete";

            thisExosuit.onToggle             += OnToggle;
            thisExosuit.modules.onAddItem    += OnAddItem;
            thisExosuit.modules.onRemoveItem += OnRemoveItem;

            Player.main.playerMotorModeChanged.AddHandler(this, new Event <Player.MotorMode> .HandleFunction(OnPlayerMotorModeChanged));

            moduleCount = thisExosuit.modules.GetCount(ScannerModulePrefab.TechTypeID);
        }
コード例 #7
0
    private void showAvailableSuits()
    {
        Hashtable             masterSuitList = GameData.MasterSuitList;
        IDictionaryEnumerator enumerator     = masterSuitList.GetEnumerator();
        int num  = 0;
        int num2 = 0;

        while (enumerator.MoveNext())
        {
            Exosuit exosuit = (Exosuit)enumerator.Value;
            if (exosuit.mSuitId == GameData.MySuitID)
            {
                factId = exosuit.mFactionId - 1;
                if (exosuit.mFactionId == 1)
                {
                    suitId = num2;
                }
                else
                {
                    suitId = num;
                }
            }
            if (exosuit.mFactionId == 1)
            {
                suitsBanzai[num2] = exosuit.mSuitName;
                banzaiLookup.Add(num2, exosuit.mSuitId);
                num2++;
            }
            else
            {
                suitsAtlas[num] = exosuit.mSuitName;
                atlasLookup.Add(num, exosuit.mSuitId);
                num++;
            }
        }
    }
コード例 #8
0
        static bool Prefix(Exosuit __instance, bool canPickup, bool canDrill)
        {
            GameObject target = null;

            if (canPickup || canDrill)
            {
                Targeting.GetTarget(__instance.gameObject, 6f, out target, out float num, null);
            }
            if (target)
            {
                GameObject root = UWE.Utils.GetEntityRoot(target);
                root = root != null ? root : target;

                if (canPickup && root.GetComponentProfiled <Pickupable>())
                {
                    target = root;
                }
                else if (canDrill && root.GetComponentProfiled <Drillable>())
                {
                    target = root;
                }
                else
                {
                    target = null;
                }
            }
            __instance.activeTarget = target;
            GUIHand component = Player.main.GetComponent <GUIHand>();

            if (__instance.activeTarget)
            {
                GUIHand.Send(__instance.activeTarget, HandTargetEventType.Hover, component);
            }

            return(false);
        }
コード例 #9
0
        public void OnPickup()
        {
            GameObject activeTarget = Exosuit.GetActiveTarget();

            if (activeTarget)
            {
                Pickupable pickupable = activeTarget.GetComponent <Pickupable>();
                PickPrefab component  = activeTarget.GetComponent <PickPrefab>();

                bool hasRoomForItem = Exosuit.storageContainer.container.HasRoomFor(pickupable);

                if (pickupable != null && pickupable.isPickupable && hasRoomForItem)
                {
                    pickupable = pickupable.Initialize();
                    InventoryItem item = new InventoryItem(pickupable);
                    Exosuit.storageContainer.container.UnsafeAdd(item);
                    Utils.PlayFMODAsset(pickupSound, front, 5f);
                }
                else if (component != null && component.AddToContainer(Exosuit.storageContainer.container))
                {
                    component.SetPickedUp();
                }
            }
        }
コード例 #10
0
 private static bool Prefix(Exosuit __instance)
 {
     return(true);
 }
コード例 #11
0
ファイル: MultiplayerExosuit.cs プロジェクト: yawaraka/Nitrox
 protected override void Awake()
 {
     SteeringControl = exosuit = GetComponent <Exosuit>();
     base.Awake();
 }
コード例 #12
0
 internal static void PostExosuitOnUpgradeModuleChange(ref Exosuit __instance, TechType techType)
 {
     QuickLogger.Debug($"{nameof(PostExosuitOnUpgradeModuleChange)} {techType.AsString()}", true);
     //__instance.gameObject.EnsureComponent<VehicleUpgrader>().UpgradeVehicle(techType, ref __instance);
     CoroutineHost.StartCoroutine(DeferUpgrade(__instance, techType));
 }
コード例 #13
0
        internal static void DisplayVehicleInfoForPSTD(Exosuit thisExosuit)
        {
            GameObject gameObject  = GameObject.Find("HUD");
            GameObject gameObject2 = GameObject.Find("AirVentsDisplayUI");

            if (Player.main.currentMountedVehicle == thisExosuit)
            {
                if (gameObject2 == null)
                {
                    gameObject2 = new GameObject("AirVentsDisplayUI");
                }

                gameObject2.transform.SetParent(gameObject.transform, false);
                Text text = gameObject2.GetComponent <Text>();

                if (text == null)
                {
                    text = gameObject2.gameObject.AddComponent <Text>();
                }

                text.font      = Player.main.textStyle.font;
                text.fontSize  = Mathf.RoundToInt(Config.AirVentsFontSizeSliderValue);
                text.alignment = TextAnchor.LowerCenter;
                text.color     = Color.white;
                RectTransform component = text.GetComponent <RectTransform>();
                component.localPosition = AirVentHUDPosition;
                component.sizeDelta     = AirVentHUDSize;
                AirVentDisplayText      = text;
                gameObject = gameObject2;
                StringBuilder stringBuilder = new StringBuilder();

                // Air vents display
                if (Player.main.GetDepth() > DepthDetection)
                {
                    if (Config.AirVentsAutoToggleValue)
                    {
                        stringBuilder.Append(colorYellow);
                        stringBuilder.Append(AirVentHUDTextAutoClosed);
                        stringBuilder.Append(colorEnd);
                    }
                    //AirVentDisplayText.text = colorYellow + AirVentHUDTextAutoClosed + colorEnd;
                    else
                    //AirVentDisplayText.text = colorYellow + AirVentHUDTextClosed + colorEnd;
                    {
                        stringBuilder.Append(colorYellow);
                        stringBuilder.Append(AirVentHUDTextClosed);
                        stringBuilder.Append(colorEnd);
                    }
                }
                else
                {
                    if (Config.AirVentsAutoToggleValue)
                    {
                        // AirVentDisplayText.text = colorYellow + AirVentHUDTextAutoOpened + colorEnd;
                        stringBuilder.Append(colorYellow);
                        stringBuilder.Append(AirVentHUDTextAutoOpened);
                        stringBuilder.Append(colorEnd);
                    }
                    else
                    {
                        if (!AirVentsOn)
                        {
                            stringBuilder.Append(colorRed);
                            stringBuilder.Append(AirVentHUDTextPromptOpen);
                            stringBuilder.Append(colorEnd);
                            stringBuilder.AppendFormat("(<color=#ADF8FFFF>{0}</color>)", Config.ToggleAirVentsKeybindValue.ToString());
                            //AirVentDisplayText.text = AirVentDisplayText.text + stringBuilder.ToString();
                        }
                        else
                        {
                            stringBuilder.Append(AirVentHUDTextPromptClose);
                            stringBuilder.AppendFormat("(<color=#ADF8FFFF>{0}</color>)", Config.ToggleAirVentsKeybindValue.ToString());
                            //AirVentDisplayText.text = AirVentDisplayText.text + stringBuilder.ToString();
                        }
                    }
                }

                if (OtherModsInfo.Rm_VehicleLightsImprovedPresent)
                {
                    stringBuilder.Append('\n');
                    stringBuilder.Append("Exit ");
                    stringBuilder.AppendFormat("(<color=#ADF8FFFF>{0}</color>)", KeyCodeUtils.KeyCodeToString(KeyCode.E));
                    stringBuilder.Append('\n');

                    stringBuilder.Append("Toggle lights ");
                    string displayMidMouseButton = uGUI.GetDisplayTextForBinding("MouseButtonMiddle");
                    stringBuilder.AppendFormat("(<color=#ADF8FFFF>{0}</color>)", displayMidMouseButton);
                }

                // AirVentDisplayText.text = AirVentDisplayText.text + stringBuilder.ToString();
                AirVentDisplayText.text = stringBuilder.ToString();

                gameObject2.SetActive(true);
            }
            else
            {
                if (gameObject2 != null)
                {
                    gameObject2.SetActive(false);
                }
            }
        }
コード例 #14
0
 public static void Postfix(Exosuit __instance)
 {
     __instance.BroadcastMessage("ResetColors", SendMessageOptions.DontRequireReceiver);
 }
コード例 #15
0
        private Optional<VehicleMovementData> GetVehicleMovement()
        {
            Vehicle vehicle = Player.main.GetVehicle();
            SubRoot sub = Player.main.GetCurrentSub();

            NitroxId id;
            Vector3 position;
            Quaternion rotation;
            Vector3 velocity;
            Vector3 angularVelocity;
            TechType techType;
            float steeringWheelYaw = 0f, steeringWheelPitch = 0f;
            bool appliedThrottle = false;
            Vector3 leftArmPosition = new Vector3(0, 0, 0);
            Vector3 rightArmPosition = new Vector3(0, 0, 0);

            if (vehicle != null)
            {
                id = NitroxEntity.GetId(vehicle.gameObject);
                position = vehicle.gameObject.transform.position;
                rotation = vehicle.gameObject.transform.rotation;
                techType = CraftData.GetTechType(vehicle.gameObject);

                Rigidbody rigidbody = vehicle.gameObject.GetComponent<Rigidbody>();

                velocity = rigidbody.velocity;
                angularVelocity = rigidbody.angularVelocity;

                // Required because vehicle is either a SeaMoth or an Exosuit, both types which can't see the fields either.
                steeringWheelYaw = (float)vehicle.ReflectionGet<Vehicle, Vehicle>("steeringWheelYaw");
                steeringWheelPitch = (float)vehicle.ReflectionGet<Vehicle, Vehicle>("steeringWheelPitch");

                // Vehicles (or the SeaMoth at least) do not have special throttle animations. Instead, these animations are always playing because the player can't even see them (unlike the cyclops which has cameras).
                // So, we need to hack in and try to figure out when thrust needs to be applied.
                if (vehicle && AvatarInputHandler.main.IsEnabled())
                {
                    if (techType == TechType.Seamoth)
                    {
                        bool flag = vehicle.transform.position.y < Ocean.main.GetOceanLevel() && vehicle.transform.position.y < vehicle.worldForces.waterDepth && !vehicle.precursorOutOfWater;
                        appliedThrottle = flag && GameInput.GetMoveDirection().sqrMagnitude > .1f;
                    }
                    else if (techType == TechType.Exosuit)
                    {
                        Exosuit exosuit = vehicle as Exosuit;
                        if (exosuit)
                        {
                            appliedThrottle = (bool)exosuit.ReflectionGet("_jetsActive") && (float)exosuit.ReflectionGet("thrustPower") > 0f;

                            Transform leftAim = (Transform)exosuit.ReflectionGet("aimTargetLeft", true);
                            Transform rightAim = (Transform)exosuit.ReflectionGet("aimTargetRight", true);

                            Vector3 eulerAngles = exosuit.transform.eulerAngles;
                            eulerAngles.x = MainCamera.camera.transform.eulerAngles.x;
                            Quaternion quaternion = Quaternion.Euler(eulerAngles.x, eulerAngles.y, eulerAngles.z);

                            leftArmPosition = leftAim.transform.position = MainCamera.camera.transform.position + quaternion * Vector3.forward * 100f;
                            rightArmPosition = rightAim.transform.position = MainCamera.camera.transform.position + quaternion * Vector3.forward * 100f;
                        }
                    }
                }
            }
            else if (sub != null && Player.main.isPiloting)
            {
                id = NitroxEntity.GetId(sub.gameObject);
                position = sub.gameObject.transform.position;
                rotation = sub.gameObject.transform.rotation;
                Rigidbody rigidbody = sub.GetComponent<Rigidbody>();
                velocity = rigidbody.velocity;
                angularVelocity = rigidbody.angularVelocity;
                techType = TechType.Cyclops;

                SubControl subControl = sub.GetComponent<SubControl>();
                steeringWheelYaw = (float)subControl.ReflectionGet("steeringWheelYaw");
                steeringWheelPitch = (float)subControl.ReflectionGet("steeringWheelPitch");
                appliedThrottle = subControl.appliedThrottle && (bool)subControl.ReflectionGet("canAccel");
            }
            else
            {
                return Optional.Empty;
            }

            VehicleMovementData model = VehicleMovementFactory.GetVehicleMovementData(techType,
                                                                                        id,
                                                                                        position,
                                                                                        rotation,
                                                                                        velocity,
                                                                                        angularVelocity,
                                                                                        steeringWheelYaw,
                                                                                        steeringWheelPitch,
                                                                                        appliedThrottle,
                                                                                        leftArmPosition,
                                                                                        rightArmPosition);
            return Optional.Of(model);
        }
コード例 #16
0
 public static void PreUpdate(ref Exosuit __instance)
 {
     __instance.gameObject.EnsureComponent <ExosuitUpdater>().PreUpdate();
     //Vector3 vector = AvatarInputHandler.main.IsEnabled() ? GameInput.GetMoveDirection() : Vector3.zero;
 }
コード例 #17
0
 internal static void Postfix(ref Exosuit __instance, TechType techType)
 {
     QuickLogger.Debug($"{nameof(Exosuit_OnUpgradeModuleChange_Patcher)} {techType.AsString()}");
     __instance.gameObject.EnsureComponent <VehicleUpgrader>().UpgradeVehicle(techType, ref __instance);
 }
コード例 #18
0
 internal static void ApplyJumpForce(Exosuit instance)
 {
     ApplyJumpForceMethod.Invoke(instance, null);
 }
コード例 #19
0
 public static void Postfix(Exosuit __instance)
 {
     __instance.gameObject.EnsureComponent <RepairModuleControl>();
 }
コード例 #20
0
 internal static float GetThrustPower(Exosuit instance)
 {
     return((float)thrustPowerField.GetValue(instance));
 }
コード例 #21
0
 internal static void Postfix(Exosuit __instance)
 {
     __instance.gameObject.AddIfNeedComponent <ExosuitOverDrive>();
 }
コード例 #22
0
    private void OnGUI()
    {
        GUIUtil.GUIEnable(bEnable: true);
        GUI.skin = SharedHudSkin;
        if ((mTextureBundles.isDone && mTextureBundles.assetBundle == null) || mTextureBundles.error != null)
        {
            GUI.Box(screenSpace, GUIContent.none, "blackbox");
            GUI.Label(new Rect(0f, screenSpace.height / 2f, screenSpace.width, 150f), "Loading Assets Error.", "MissionHeader");
            Logger.traceError(mTextureBundles.error);
            return;
        }
        GUI.Box(screenSpace, GUIContent.none, "blackbox");
        GUI.Label(new Rect(0f, screenSpace.height / 2f, screenSpace.width, 30f), "Loading Assets: " + mTextureBundles.progress * 100f + "%", GUIUtil.mInstance.mShowcaseSkin.GetStyle("SuitLoadStyle"));
        if (mTextureBundles.isDone && !bTexturesLoaded)
        {
            return;
        }
        GUI.BeginGroup(screenSpace);
        string b = (Event.current.type != EventType.Repaint) ? lastHover : string.Empty;

        if (bLoading)
        {
            MessageBox.Local("Loading...", "Please wait.", null, false, MessageBox.MessageType.MB_NoButtons);
        }
        Vector2 mousePosition = Event.current.mousePosition;
        float   num           = 0f;

        if (StartAnim == -1)
        {
            if (mFactionSelected == -1)
            {
                num = fMiddle;
            }
            else if (mFactionSelected == 0)
            {
                if (bViewFaction)
                {
                    Vector2 mousePosition2 = Event.current.mousePosition;
                    num = Mathf.Clamp((0f - mousePosition2.x) / (float)Screen.width * 3.25f + 4.55f, 1.75f, 4f);
                }
                else
                {
                    num = 1.75f;
                }
            }
            else if (mFactionSelected == 1)
            {
                if (bViewFaction)
                {
                    Vector2 mousePosition3 = Event.current.mousePosition;
                    num = Mathf.Clamp((0f - mousePosition3.x) / (float)Screen.width * 3.55f - 1.25f, -4f, -1.45f);
                }
                else
                {
                    num = -1.45f;
                }
            }
            mCurrentScroll += (num - mCurrentScroll) * Time.deltaTime;
        }
        num = mCurrentScroll;
        float num2 = num * ScrollFactor;
        float num3 = screenSpace.width / 2f + num2;

        GUI.color = Color.white;
        GUI.DrawTexture(new Rect(((0f - screenSpace.height) * 4.5f + screenSpace.width) / 2f + num2, 0f, screenSpace.height * 4.5f, screenSpace.height), mBackground);
        if (StartAnim != -1)
        {
            if (StartAnim == 3)
            {
                GUI.DrawTexture(new Rect(0f, 0f, screenSpace.width, 23f), ChooseYourFaction);
            }
            GUI.color = new Color(1f, 1f, 1f, 1f - BlackFade);
            GUI.Box(screenSpace, GUIContent.none, "blackbox");
            GUI.color = Color.white;
            GUI.EndGroup();
            return;
        }
        GUI.color = OutlineColor;
        for (int i = 0; i < DrawBanzaiOutlines.Length; i++)
        {
            if (DrawBanzaiOutlines[i])
            {
                GUI.DrawTexture(new Rect(num3 + fObjectOffsetX * BanzaiSuitOutlineRects[i].x, fObjectOffsetX * BanzaiSuitOutlineRects[i].y, fObjectOffsetX * (float)BanzaiSuitOutlineTextures[i].width, fObjectOffsetX * (float)BanzaiSuitOutlineTextures[i].height), BanzaiSuitOutlineTextures[i]);
            }
        }
        GUI.color = Color.white;
        for (int j = 0; j < DrawBanzaiOutlines.Length; j++)
        {
            if (!DrawBanzaiOutlines[j])
            {
                continue;
            }
            GUI.DrawTexture(new Rect(num3 + fObjectOffsetX * BanzaiSuitRects[j].x, fObjectOffsetX * BanzaiSuitRects[j].y, fObjectOffsetX * (float)BanzaiSuitTextures[j].width, fObjectOffsetX * (float)BanzaiSuitTextures[j].height), BanzaiSuitTextures[j]);
            if (Event.current.type != EventType.MouseUp || !(fIgnoreClick <= 0f))
            {
                continue;
            }
            if (mFactionSelected == -1)
            {
                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Suit_Chooser_Change_Column);
                mFadeLeft        = 1f;
                mFactionSelected = 0;
                mSuitSelected    = -1;
                for (int k = 0; k < mNameTimer.Length; k++)
                {
                    mNameTimer[k] = 1f;
                }
                break;
            }
            if (mFactionSelected == 0 && mSuitSelected == -1)
            {
                mSuitSelected = mBanzaiSuits[j];
                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Equip_Press);
            }
        }
        GUI.color = OutlineColor;
        for (int l = 0; l < DrawAtlasOutlines.Length; l++)
        {
            if (DrawAtlasOutlines[l])
            {
                GUI.DrawTexture(new Rect(num3 + fObjectOffsetX * AtlasSuitOutlineRects[l].x, fObjectOffsetX * AtlasSuitOutlineRects[l].y, fObjectOffsetX * (float)AtlasSuitOutlineTextures[l].width, fObjectOffsetX * (float)AtlasSuitOutlineTextures[l].height), AtlasSuitOutlineTextures[l]);
            }
        }
        GUI.color = Color.white;
        for (int m = 0; m < DrawAtlasOutlines.Length; m++)
        {
            if (!DrawAtlasOutlines[m])
            {
                continue;
            }
            GUI.DrawTexture(new Rect(num3 + fObjectOffsetX * AtlasSuitRects[m].x, fObjectOffsetX * AtlasSuitRects[m].y, fObjectOffsetX * (float)AtlasSuitTextures[m].width, fObjectOffsetX * (float)AtlasSuitTextures[m].height), AtlasSuitTextures[m]);
            if (Event.current.type != EventType.MouseUp || !(fIgnoreClick <= 0f))
            {
                continue;
            }
            if (mFactionSelected == -1)
            {
                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Suit_Chooser_Change_Column);
                mFadeLeft        = 1f;
                mFactionSelected = 1;
                mSuitSelected    = -1;
                for (int n = 0; n < mNameTimer.Length; n++)
                {
                    mNameTimer[n] = 1f;
                }
                break;
            }
            if (mFactionSelected == 1 && mSuitSelected == -1)
            {
                mSuitSelected = mAtlasSuits[m];
                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Equip_Press);
            }
        }
        if (mFactionSelected == -1)
        {
            GUI.DrawTexture(new Rect(0f, 0f, screenSpace.width, 23f), ChooseYourFaction);
            int num4 = -1;
            for (int num5 = 0; num5 < FactionButtons.Length; num5++)
            {
                Rect rect = FactionButtons[num5];
                rect.x       = num3 + fObjectOffsetX * rect.x;
                rect.y      *= fObjectOffsetX;
                rect.height *= fObjectOffsetX;
                rect.width  *= fObjectOffsetX;
                if (rect.Contains(mousePosition))
                {
                    num4 = num5;
                }
            }
            if (num4 != -1 && mFactionHovered != num4)
            {
                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Suit_Chooser_Over);
            }
            mFactionHovered = num4;
            for (int num6 = 0; num6 < DrawBanzaiOutlines.Length; num6++)
            {
                DrawBanzaiOutlines[num6] = (mFactionHovered == 0);
            }
            for (int num7 = 0; num7 < DrawAtlasOutlines.Length; num7++)
            {
                DrawAtlasOutlines[num7] = (mFactionHovered == 1);
            }
        }
        else
        {
            if (!bViewFaction)
            {
                GUI.DrawTexture(new Rect(0f, 0f, screenSpace.width, 23f), ChooseYourExosuit);
            }
            Rect[] array  = null;
            bool[] array2 = null;
            if (mFactionSelected == 0)
            {
                if (!bViewFaction)
                {
                    for (int num8 = 0; num8 < BanzaiSuitIcons.Length; num8++)
                    {
                        Rect position = BanzaiSuitIconRect[num8];
                        position.x      *= fObjectOffsetX;
                        position.y      *= fObjectOffsetX;
                        position.width  *= fObjectOffsetX;
                        position.height *= fObjectOffsetX;
                        position.x      += num3 + (float)(int)(position.width * mFadeLeft);
                        position.width   = (int)(position.width * (1f - mFadeLeft));
                        GUI.BeginGroup(position);
                        Rect position2 = new Rect((0f - BanzaiSuitIconRect[num8].width) * fObjectOffsetX * mFadeLeft, 0f, (float)BanzaiSuitIcons[num8].width * fObjectOffsetX, (float)BanzaiSuitIcons[num8].height * fObjectOffsetX);
                        GUI.DrawTexture(position2, BanzaiSuitIcons[num8]);
                        GUI.EndGroup();
                        Rect position3 = new Rect(position.x, position.y, (int)((float)FactionTextBG[0].width * fObjectOffsetX * (1f - mNameTimer[num8])), (float)FactionTextBG[0].height * fObjectOffsetX);
                        position3.x -= position3.width;
                        GUI.BeginGroup(position3);
                        GUI.DrawTexture(new Rect((int)((float)(-FactionTextBG[0].width) * fObjectOffsetX * mNameTimer[num8]), 0f, (float)FactionTextBG[0].width * fObjectOffsetX, (float)FactionTextBG[0].height * fObjectOffsetX), FactionTextBG[0]);
                        GUI.DrawTexture(new Rect((float)(int)((float)(-FactionTextBG[0].width) * fObjectOffsetX * mNameTimer[num8]) + ((float)FactionTextBG[0].width * fObjectOffsetX - (float)BanzaiSuitText[num8].width * fObjectOffsetX) / 2f, 10f, (float)BanzaiSuitText[num8].width * fObjectOffsetX, (float)BanzaiSuitText[num8].height * fObjectOffsetX), BanzaiSuitText[num8]);
                        GUI.EndGroup();
                    }
                    switch (GUIUtil.Button(new Rect(10f, 10f, 80f, 38f), "BACK", "ModalButton"))
                    {
                    case GUIUtil.GUIState.Hover:
                    case GUIUtil.GUIState.Active:
                        if (Event.current.type == EventType.Repaint)
                        {
                            b = "BACK";
                            if (lastHover != b)
                            {
                                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Over);
                            }
                        }
                        break;

                    case GUIUtil.GUIState.Click:
                        b = "BACK";
                        GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Press);
                        mFactionSelected = -1;
                        mSuitSelected    = -1;
                        mFadeLeft        = 1f;
                        GUI.EndGroup();
                        return;
                    }
                }
                array  = BanzaiButtons;
                array2 = DrawBanzaiOutlines;
                switch (GUIUtil.Button(new Rect(10f, screenSpace.height - 48f, 120f, 38f), (!bViewFaction) ? "VIEW FACTION" : "BACK TO SUITS", "ModalButton"))
                {
                case GUIUtil.GUIState.Hover:
                case GUIUtil.GUIState.Active:
                    if (Event.current.type == EventType.Repaint)
                    {
                        b = "BACK TO SUITS";
                        if (lastHover != b)
                        {
                            GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Over);
                        }
                    }
                    break;

                case GUIUtil.GUIState.Click:
                    b = "BACK TO SUITS";
                    GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Press);
                    bViewFaction  = !bViewFaction;
                    mSuitSelected = -1;
                    GUI.EndGroup();
                    return;
                }
            }
            else if (mFactionSelected == 1)
            {
                if (!bViewFaction)
                {
                    for (int num9 = 0; num9 < AtlasSuitIcons.Length; num9++)
                    {
                        Rect position4 = AtlasSuitIconRect[num9];
                        position4.x      *= fObjectOffsetX;
                        position4.y      *= fObjectOffsetX;
                        position4.width  *= fObjectOffsetX;
                        position4.height *= fObjectOffsetX;
                        position4.x      += num3;
                        position4.width  *= 1f - mFadeLeft;
                        GUI.BeginGroup(position4);
                        GUI.DrawTexture(new Rect(0f, 0f, (float)AtlasSuitIcons[num9].width * fObjectOffsetX, (float)AtlasSuitIcons[num9].height * fObjectOffsetX), AtlasSuitIcons[num9]);
                        GUI.EndGroup();
                        Rect position5 = new Rect(position4.x + position4.width, position4.y, (float)FactionTextBG[1].width * fObjectOffsetX * (1f - mNameTimer[num9]), (float)FactionTextBG[1].height * fObjectOffsetX);
                        GUI.BeginGroup(position5);
                        GUI.DrawTexture(new Rect(0f, 0f, (float)FactionTextBG[1].width * fObjectOffsetX, (float)FactionTextBG[1].height * fObjectOffsetX), FactionTextBG[1]);
                        GUI.DrawTexture(new Rect(((float)FactionTextBG[1].width * fObjectOffsetX - (float)AtlasSuitText[num9].width * fObjectOffsetX) / 2f, 10f, (float)AtlasSuitText[num9].width * fObjectOffsetX, (float)AtlasSuitText[num9].height * fObjectOffsetX), AtlasSuitText[num9]);
                        GUI.EndGroup();
                    }
                    switch (GUIUtil.Button(new Rect(screenSpace.width - 90f, 10f, 80f, 38f), "BACK", "ModalButton"))
                    {
                    case GUIUtil.GUIState.Hover:
                    case GUIUtil.GUIState.Active:
                        if (Event.current.type == EventType.Repaint)
                        {
                            b = "BACK";
                            if (lastHover != b)
                            {
                                GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Over);
                            }
                        }
                        break;

                    case GUIUtil.GUIState.Click:
                        b = "BACK";
                        GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Press);
                        mFactionSelected = -1;
                        mSuitSelected    = -1;
                        mFadeLeft        = 1f;
                        GUI.EndGroup();
                        return;
                    }
                }
                array  = AtlasButtons;
                array2 = DrawAtlasOutlines;
                switch (GUIUtil.Button(new Rect(screenSpace.width - 130f, screenSpace.height - 48f, 120f, 38f), (!bViewFaction) ? "VIEW FACTION" : "BACK TO SUITS", "ModalButton"))
                {
                case GUIUtil.GUIState.Hover:
                case GUIUtil.GUIState.Active:
                    if (Event.current.type == EventType.Repaint)
                    {
                        b = "BACK TO SUITS";
                        if (lastHover != b)
                        {
                            GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Over);
                        }
                    }
                    break;

                case GUIUtil.GUIState.Click:
                    b = "BACK TO SUITS";
                    GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Press);
                    bViewFaction  = !bViewFaction;
                    mSuitSelected = -1;
                    GUI.EndGroup();
                    return;
                }
            }
            if (mSuitSelected == -1 && !bViewFaction)
            {
                for (int num10 = 0; num10 < array.Length; num10++)
                {
                    Rect rect2 = array[num10];
                    rect2.x      *= fObjectOffsetX;
                    rect2.y      *= fObjectOffsetX;
                    rect2.width  *= fObjectOffsetX;
                    rect2.height *= fObjectOffsetX;
                    rect2.x      += num2;
                    if (rect2.Contains(mousePosition))
                    {
                        if (!array2[num10])
                        {
                            GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Suit_Chooser_Over);
                        }
                        array2[num10] = true;
                    }
                    else
                    {
                        array2[num10] = false;
                    }
                }
            }
            SuitInspector.TempSuitInfo tempSuitInfo = new SuitInspector.TempSuitInfo();
            GUIUtil.GUIEnable(bEnable: true);
            if (mSuitSelected != -1)
            {
                tempSuitInfo.mSuitName = GameData.getExosuit(mSuitSelected).mSuitName;
                Exosuit exosuit = GameData.getExosuit(mSuitSelected);
                tempSuitInfo.mSuitShow    = exosuit.mShowName;
                tempSuitInfo.mSuitName    = exosuit.mSuitName;
                tempSuitInfo.mIndex       = mSuitSelected;
                tempSuitInfo.mDescription = exosuit.mDescription;
                tempSuitInfo.mShieldPower = exosuit.mBaseHealth;
                tempSuitInfo.mShieldRegen = exosuit.mBaseRegenHealth;
                tempSuitInfo.mJetpack     = exosuit.mBaseJetFuel;
                tempSuitInfo.mSpeed       = exosuit.mBaseSpeed;
                tempSuitInfo.mTech        = exosuit.mBaseTech;
                Rect position6 = new Rect(150f, 60f, screenSpace.width - 300f, screenSpace.height - 120f);
                GUI.BeginGroup(position6);
                mSuitInspector.DrawSuitInfo(tempSuitInfo, bDraw3D: true);
                float num11 = 230f + (position6.width - 230f) / 2f;
                if (GameData.getExosuit(mSuitSelected).getHighPolyModel() == null)
                {
                    GUI.Label(new Rect(num11 - 200f, position6.height / 2f - 90f, 400f, 40f), "Loading Suit: " + (int)(AssetLoader.GetSuitLoadProgress(tempSuitInfo.mIndex, AssetLoader.SuitAsset.SuitType.high) * 100f) + "%", GUIUtil.mInstance.mShowcaseSkin.GetStyle("SuitLoadStyle"));
                    GUIUtil.DrawLoadingAnim(new Rect(num11 - 64f, (Screen.height - 128) / 2, 128f, 128f), 1);
                }
                GUI.color = Color.white;
                switch (GUIUtil.Button(new Rect(num11 - 70f, position6.height - 45f, 140f, 34f), "CHOOSE EXOSUIT", "ModalButton"))
                {
                case GUIUtil.GUIState.Hover:
                case GUIUtil.GUIState.Active:
                    if (Event.current.type == EventType.Repaint)
                    {
                        b = "CHOOSE EXOSUIT";
                        if (lastHover != b)
                        {
                            GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Over);
                        }
                    }
                    break;

                case GUIUtil.GUIState.Click:
                    b = "CHOOSE EXOSUIT";
                    GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Press);
                    MessageBox.ResetWindowPosition();
                    MessageBox.AddMessageCustom("Join " + GameData.getFactionDisplayName(mFactionSelected + 1) + "?", "Once you pledge your allegiance to a faction, you can not switch sides. Are you sure you want to select the " + tempSuitInfo.mSuitName + " and join " + GameData.getFactionDisplayName(mFactionSelected + 1) + "?", null, true, OnJoinConfirm, "Yes, Join", "No, Cancel");
                    break;
                }
                switch (GUIUtil.Button(new Rect(position6.width - 64f, 0f, 64f, 42f), GUIContent.none, "Close"))
                {
                case GUIUtil.GUIState.Hover:
                case GUIUtil.GUIState.Active:
                    if (Event.current.type == EventType.Repaint)
                    {
                        b = "Close";
                        if (lastHover != b)
                        {
                            GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Global_Button_Over);
                        }
                    }
                    break;

                case GUIUtil.GUIState.Click:
                    b = "Close";
                    GUIUtil.PlayGUISound(GUIUtil.GUISoundClips.TT_Hangar_Button_Inactive);
                    mSuitSelected = -1;
                    break;
                }
                GUI.EndGroup();
            }
        }
        GUI.EndGroup();
        if (Event.current.type == EventType.MouseUp)
        {
            fIgnoreClick = 0.05f;
        }
        lastHover = b;
    }
コード例 #23
0
 static void Postfix(Exosuit __instance) => __instance.GetComponent <PrawnSonarControl>()?.setPlayerInside(false);
コード例 #24
0
 protected ExosuitArmsManager(Exosuit exosuit)
 {
     _exosuit = exosuit;
 }
コード例 #25
0
 internal static void Postfix(ref Exosuit __instance, TechType techType)
 {
     VehicleUpgrader.GetUpgrader(__instance)?.UpgradeVehicle(techType);
 }
コード例 #26
0
 public static ExosuitArmsManager CreateFromExosuit(Exosuit exosuit) => new ExosuitArmsManager(exosuit);
コード例 #27
0
        public void UpdateVehiclePosition(VehicleMovementData vehicleModel, Optional <RemotePlayer> player)
        {
            Vector3    remotePosition  = vehicleModel.Position;
            Vector3    remoteVelocity  = vehicleModel.Velocity;
            Quaternion remoteRotation  = vehicleModel.Rotation;
            Vector3    angularVelocity = vehicleModel.AngularVelocity;

            Vehicle vehicle = null;
            SubRoot subRoot = null;

            Optional <GameObject> opGameObject = NitroxEntity.GetObjectFrom(vehicleModel.Id);

            if (opGameObject.HasValue)
            {
                GameObject gameObject = opGameObject.Value;

                vehicle = gameObject.GetComponent <Vehicle>();
                subRoot = gameObject.GetComponent <SubRoot>();

                MultiplayerVehicleControl mvc = null;

                if (subRoot != null)
                {
                    mvc = subRoot.gameObject.EnsureComponent <MultiplayerCyclops>();
                    subRoot.GetComponent <LiveMixin>().health = vehicleModel.Health;
                }
                else if (vehicle != null)
                {
                    SeaMoth seamoth = vehicle as SeaMoth;
                    Exosuit exosuit = vehicle as Exosuit;

                    if (seamoth)
                    {
                        mvc = seamoth.gameObject.EnsureComponent <MultiplayerSeaMoth>();
                    }
                    else if (exosuit)
                    {
                        mvc = exosuit.gameObject.EnsureComponent <MultiplayerExosuit>();
                        if (vehicleModel.GetType() == typeof(ExosuitMovementData))
                        {
                            ExosuitMovementData exoSuitMovement = (ExosuitMovementData)vehicleModel;
                            mvc.SetArmPositions(exoSuitMovement.LeftAimTarget, exoSuitMovement.RightAimTarget);
                        }
                        else
                        {
                            Log.Error($"{nameof(Vehicles)}: Got exosuit vehicle but no ExosuitMovementData");
                        }
                    }

                    vehicle.GetComponent <LiveMixin>().health = vehicleModel.Health;
                }

                if (mvc != null)
                {
                    mvc.SetPositionVelocityRotation(remotePosition, remoteVelocity, remoteRotation, angularVelocity);
                    mvc.SetThrottle(vehicleModel.AppliedThrottle);
                    mvc.SetSteeringWheel(vehicleModel.SteeringWheelYaw, vehicleModel.SteeringWheelPitch);
                }
            }

            if (player.HasValue)
            {
                RemotePlayer playerInstance = player.Value;
                playerInstance.SetVehicle(vehicle);
                playerInstance.SetSubRoot(subRoot);
                playerInstance.SetPilotingChair(subRoot?.GetComponentInChildren <PilotingChair>());
                playerInstance.AnimationController.UpdatePlayerAnimations = false;
            }
        }
コード例 #28
0
ファイル: PlayerMovement.cs プロジェクト: dsmedeiros/Nitrox
        private Optional <VehicleModel> GetVehicleModel()
        {
            Vehicle vehicle = Player.main.GetVehicle();
            SubRoot sub     = Player.main.GetCurrentSub();

            string     guid;
            Vector3    position;
            Quaternion rotation;
            Vector3    velocity;
            Vector3    angularVelocity;
            TechType   techType;
            float      steeringWheelYaw = 0f, steeringWheelPitch = 0f;
            bool       appliedThrottle = false;

            if (vehicle != null)
            {
                guid     = GuidHelper.GetGuid(vehicle.gameObject);
                position = vehicle.gameObject.transform.position;
                rotation = vehicle.gameObject.transform.rotation;
                techType = CraftData.GetTechType(vehicle.gameObject);

                Rigidbody rigidbody = vehicle.gameObject.GetComponent <Rigidbody>();

                velocity        = rigidbody.velocity;
                angularVelocity = rigidbody.angularVelocity;

                // Required because vehicle is either a SeaMoth or an Exosuit, both types which can't see the fields either.
                steeringWheelYaw   = (float)vehicle.ReflectionGet <Vehicle, Vehicle>("steeringWheelYaw");
                steeringWheelPitch = (float)vehicle.ReflectionGet <Vehicle, Vehicle>("steeringWheelPitch");

                // Vehicles (or the SeaMoth at least) do not have special throttle animations. Instead, these animations are always playing because the player can't even see them (unlike the cyclops which has cameras).
                // So, we need to hack in and try to figure out when thrust needs to be applied.
                if (vehicle && AvatarInputHandler.main.IsEnabled())
                {
                    if (techType == TechType.Seamoth)
                    {
                        bool flag = vehicle.transform.position.y < Ocean.main.GetOceanLevel() && vehicle.transform.position.y < vehicle.worldForces.waterDepth && !vehicle.precursorOutOfWater;
                        appliedThrottle = flag && GameInput.GetMoveDirection().sqrMagnitude > .1f;
                    }
                    else if (techType == TechType.Exosuit)
                    {
                        Exosuit exosuit = vehicle as Exosuit;
                        if (exosuit)
                        {
                            appliedThrottle = (bool)exosuit.ReflectionGet("_jetsActive") && (float)exosuit.ReflectionGet("thrustPower") > 0f;
                        }
                    }
                }
            }
            else if (sub != null && Player.main.isPiloting)
            {
                guid     = GuidHelper.GetGuid(sub.gameObject);
                position = sub.gameObject.transform.position;
                rotation = sub.gameObject.transform.rotation;
                Rigidbody rigidbody = sub.GetComponent <Rigidbody>();
                velocity        = rigidbody.velocity;
                angularVelocity = rigidbody.angularVelocity;
                techType        = TechType.Cyclops;

                SubControl subControl = sub.GetComponent <SubControl>();
                steeringWheelYaw   = (float)subControl.ReflectionGet("steeringWheelYaw");
                steeringWheelPitch = (float)subControl.ReflectionGet("steeringWheelPitch");
                appliedThrottle    = subControl.appliedThrottle && (bool)subControl.ReflectionGet("canAccel");
            }
            else
            {
                return(Optional <VehicleModel> .Empty());
            }

            VehicleModel model = new VehicleModel(techType,
                                                  guid,
                                                  position,
                                                  rotation,
                                                  velocity,
                                                  angularVelocity,
                                                  steeringWheelYaw,
                                                  steeringWheelPitch,
                                                  appliedThrottle);

            return(Optional <VehicleModel> .Of(model));
        }
コード例 #29
0
 internal static void Postfix(Exosuit __instance)
 {
     __instance.gameObject.AddIfNeedComponent <SlotExtenderZero>();
 }
コード例 #30
0
        private static void Postfix(Exosuit __instance)
        {
            int height = Mod.config.Exosuit.baseHeight + (Mod.config.Exosuit.heightPerStorageModule * __instance.modules.GetCount(TechType.VehicleStorageModule));

            __instance.storageContainer.Resize(Mod.config.Exosuit.width, height);
        }