Пример #1
0
 public static void Postfix(UnderwaterMotor __instance, ref float __result)
 {
     if (Inventory.Get().equipment.GetCount(techType) > 0)
     {
         __result += 2.5f * __instance.currentWreckSpeedMultiplier;
     }
 }
        internal static bool PreAlterMaxSpeed(UnderwaterMotor __instance, float __result, ref float inMaxSpeed)
        {
            // AlterMaxSpeed is a complete mess and damn-near impossible to expand without transpiling a whole lot of it.
            // So I said "f**k it" and replace the entire thing.

            //Log.LogDebug($"UnderwaterMotorPatches.PreAlterMaxSpeed: inMaxSpeed = {inMaxSpeed}");
            Inventory      main           = Inventory.main;
            Equipment      equipment      = main.equipment;
            ItemsContainer container      = main.container;
            TechType       techTypeInSlot = equipment.GetTechTypeInSlot("Tank");

            inMaxSpeed += GetSpeedModifier(techTypeInSlot);

//			int count = container.GetCount(TechType.HighCapacityTank);
//			inMaxSpeed = Mathf.Max(inMaxSpeed - (float)count * 1.275f, 2f);

            TechType techTypeInSlot2 = equipment.GetTechTypeInSlot("Body");

            inMaxSpeed += GetSpeedModifier(techTypeInSlot2);

#if SUBNAUTICA_STABLE
//			float num2 = 1f;
//			global::Utils.AdjustSpeedScalarFromWeakness(ref num2);
//			inMaxSpeed *= num2;
#endif
            TechType techTypeInSlot3 = equipment.GetTechTypeInSlot("Foots");
            inMaxSpeed += GetSpeedModifier(techTypeInSlot3);

            //Log.LogDebug($"UnderwaterMotor.PreAlterMaxSpeed: got out inMaxSpeed {inMaxSpeed}");
            return(true);
        }
Пример #3
0
            static void UnderwaterMotor_UpdateMove_Postfix(UnderwaterMotor __instance)
            {
#if DEBUG
                if (!inited && (inited = true))
                {
                    pinSpeed(__instance);
                }
#endif
                if (__instance.movementInputDirection.z > 0f)
                {
                    __instance.rb.drag *= 0.5f;
                }
            }
Пример #4
0
            static void pinSpeed(UnderwaterMotor instance)
            {
                instance.StartCoroutine(_pinSpeed());

                IEnumerator _pinSpeed()
                {
                    while (true)
                    {
                        $"{instance.rb.velocity.magnitude}".onScreen("player speed");
                        yield return(null);
                    }
                }
            }
Пример #5
0
            static void UnderwaterMotor_AlterMaxSpeed_Postfix(UnderwaterMotor __instance)
            {
                if (Player.main.motorMode != Player.MotorMode.Dive)
                {
                    return;
                }

                __instance.waterAcceleration = Inventory.main.equipment.GetTechTypeInSlot("Foots") switch
                {
                    TechType.Fins => Player.main.playerController.swimWaterAcceleration * 1.2f,
                    TechType.UltraGlideFins => Player.main.playerController.swimWaterAcceleration * 1.5f,
                    _ => __instance.waterAcceleration
                };
            }
        }
        public static void Postfix(UnderwaterMotor __instance)
        {
            TechType techTypeInFootSlot = Inventory.main.equipment.GetTechTypeInSlot("Foots");

            if (techTypeInFootSlot == TechType.Fins)
            {
                __instance.rb.velocity *= _.Patch_FinsMultiplier;
            }
            else if (techTypeInFootSlot == TechType.UltraGlideFins)
            {
                __instance.rb.velocity *= _.Patch_UltraGlideFinsMultiplier;
            }
            else if (techTypeInFootSlot == AerogelFins._GetTechType())
            {
                __instance.rb.velocity *= _.Patch_AerogelFinsMultiplier;
            }
        }
Пример #7
0
        public static void ScubaRoll(Player myPlayer, bool roll)
        {
            //get active player motor
            UnderwaterMotor thisMotor = (UnderwaterMotor)myPlayer.playerController.activeController;

            if (roll)
            {
                if (Options.scubaRollUnlimited)
                {
                    MainCameraControl.main.minimumY = -10000f;
                    MainCameraControl.main.maximumY = 10000f;
                }
                else
                {
                    MainCameraControl.main.minimumY = -80f;
                    MainCameraControl.main.maximumY = 80f;
                }

                // this is the same angular drag as the Seamoth's: 4
                myPlayer.rigidBody.angularDrag = 4;
            }
            else
            {
                MainCameraControl.main.minimumY = -80f;
                MainCameraControl.main.maximumY = 80f;
                myPlayer.rigidBody.angularDrag  = 0;
                return;
            }

            void updateRots()
            {
                Rigidbody proper = myPlayer.rigidBody;

                myPlayer.transform.position = proper.position;
                myPlayer.transform.rotation = proper.rotation;
            }

            // add roll handlers
            bool portUp   = Input.GetKeyUp(Options.rollToPortKey);
            bool portHeld = Input.GetKey(Options.rollToPortKey);
            bool portDown = Input.GetKeyDown(Options.rollToPortKey);

            bool starUp   = Input.GetKeyUp(Options.rollToStarboardKey);
            bool starHeld = Input.GetKey(Options.rollToStarboardKey);
            bool starDown = Input.GetKeyDown(Options.rollToStarboardKey);

            if (portDown || portHeld)
            {
                PlayerAwakePatcher.myRollMan.startScubaRoll(true);
            }
            else if (starDown || starHeld)
            {
                PlayerAwakePatcher.myRollMan.startScubaRoll(false);
            }
            else if ((starUp && !portHeld) || (portUp && !starHeld) || (!portHeld && !starHeld))
            {
                PlayerAwakePatcher.myRollMan.stopScubaRoll();
            }

            updateRots();

            if (GameInput.GetButtonHeld(GameInput.Button.MoveUp) || GameInput.GetButtonHeld(GameInput.Button.MoveDown))
            {
                // hijack the desired velocity

                /*
                 * Here we cancel out the normal spacebar movement.
                 * We reconstruct the vector from scratch,
                 * the way Subnautica does it.
                 * I kept their naming conventions, sorry.
                 */
                Vector3 diff     = Vector3.zero;
                Vector3 velocity = myPlayer.rigidBody.velocity;
                Vector3 vector   = GameInput.GetMoveDirection();
                float   y        = vector.y;
                float   num      = Mathf.Min(1f, vector.magnitude);
                vector.y = 0f;
                vector.Normalize();
                float num2 = 0f;
                if (vector.z > 0f)
                {
                    num2 = thisMotor.forwardMaxSpeed;
                }
                else if (vector.z < 0f)
                {
                    num2 = -thisMotor.backwardMaxSpeed;
                }
                if (vector.x != 0f)
                {
                    num2 = Mathf.Max(num2, thisMotor.strafeMaxSpeed);
                }
                num2  = Mathf.Max(num2, thisMotor.verticalMaxSpeed);
                num2 *= Player.main.mesmerizedSpeedMultiplier;
                float   num3    = Mathf.Max(velocity.magnitude, num2);
                Vector3 vector2 = thisMotor.playerController.forwardReference.rotation * vector;
                vector    = vector2;
                vector.y += y;
                vector.Normalize();

                float num4 = thisMotor.acceleration;
                if (Player.main.GetBiomeString() == "wreck")
                {
                    num4 *= 0.5f;
                }
                else if (Player.main.motorMode == Player.MotorMode.Seaglide)
                {
                    num4 *= 1.45f;
                }
                float num5 = num * num4 * Time.deltaTime;
                if (num5 > 0f)
                {
                    Vector3 vector3 = velocity + vector * num5;
                    if (vector3.magnitude > num3)
                    {
                        vector3.Normalize();
                        vector3 *= num3;
                    }
                    diff = vector3 - myPlayer.rigidBody.velocity;
                    //myPlayer.rigidBody.velocity = vector3;
                }

                Vector3 origInverse = new Vector3(0f, -diff.y, 0f);
                // This call to AddForce is what cancels out the original spacebar movement.
                myPlayer.rigidBody.AddForce(origInverse, ForceMode.VelocityChange);

                // Now we can make our own movement.
                // We'll do so by constructing a new vector3
                // and adding a force again

                // I think this is already normal, but playing it safe
                Vector3 myDirection = Camera.main.transform.up.normalized;
                float   myMagnitude = origInverse.magnitude;
                Vector3 myNewVector = myDirection * myMagnitude;

                // if we're in here, we're either going up or down
                if (GameInput.GetButtonHeld(GameInput.Button.MoveUp))
                {
                    myPlayer.rigidBody.AddForce(myNewVector, ForceMode.VelocityChange);
                }
                else
                {
                    myPlayer.rigidBody.AddForce(-myNewVector, ForceMode.VelocityChange);
                }
            }
        }