private void Update()
 {
     if (this.m_hasBeenTriggered)
     {
         this.m_currentPosition += this.m_currentVelocity * BraveTime.DeltaTime;
         if (this.m_currentPosition.z <= 0f)
         {
             this.m_currentPosition.z = 0f;
             this.OnLanded();
         }
         base.transform.position     = BraveUtility.QuantizeVector(this.m_currentPosition.WithZ(this.m_currentPosition.y - this.m_currentPosition.z), (float)PhysicsEngine.Instance.PixelsPerUnit);
         base.sprite.HeightOffGround = this.m_currentPosition.z;
         base.sprite.UpdateZDepth();
     }
 }
Example #2
0
        private static void HandleGunAttachPointInternalHook(Action <PlayerController, Gun, bool> orig, PlayerController self, Gun targetGun, bool isSecondary = false)
        {
            if (self.characterIdentity == (PlayableCharacters)274131)
            {
                FieldInfo _startingAttachPointPosition = typeof(PlayerController).GetField("m_startingAttachPointPosition", BindingFlags.NonPublic | BindingFlags.Instance);
                FieldInfo _spriteDimensions            = typeof(PlayerController).GetField("m_spriteDimensions", BindingFlags.NonPublic | BindingFlags.Instance);
                FieldInfo _currentGunAngle             = typeof(PlayerController).GetField("m_currentGunAngle", BindingFlags.NonPublic | BindingFlags.Instance);

                if (targetGun == null)
                {
                    return;
                }



                Vector3 vector  = ((Vector3)_startingAttachPointPosition.GetValue(self));
                Vector3 vector2 = self.downwardAttachPointPosition;
                if (targetGun.IsForwardPosition)
                {
                    vector  = vector.WithX(((Vector3)_spriteDimensions.GetValue(self)).x - vector.x);
                    vector2 = vector2.WithX(((Vector3)_spriteDimensions.GetValue(self)).x - vector2.x);
                }
                if (self.SpriteFlipped)
                {
                    vector  = vector.WithX(((Vector3)_spriteDimensions.GetValue(self)).x - vector.x);
                    vector2 = vector2.WithX(((Vector3)_spriteDimensions.GetValue(self)).x - vector2.x);
                }
                float   num = (float)((!self.SpriteFlipped) ? 1 : -1);
                Vector3 a   = targetGun.GetCarryPixelOffset(self.characterIdentity).ToVector3();
                vector  += Vector3.Scale(a, new Vector3(num, 1f, 1f)) * 0.0625f;
                vector2 += Vector3.Scale(a, new Vector3(num, 1f, 1f)) * 0.0625f;
                if (targetGun.Handedness == GunHandedness.NoHanded && self.SpriteFlipped)
                {
                    vector  += Vector3.Scale(targetGun.leftFacingPixelOffset.ToVector3(), new Vector3(num, 1f, 1f)) * 0.0625f;
                    vector2 += Vector3.Scale(targetGun.leftFacingPixelOffset.ToVector3(), new Vector3(num, 1f, 1f)) * 0.0625f;
                }
                if (isSecondary)
                {
                    if (targetGun.transform.parent != self.SecondaryGunPivot)
                    {
                        targetGun.transform.parent        = self.SecondaryGunPivot;
                        targetGun.transform.localRotation = Quaternion.identity;
                        targetGun.HandleSpriteFlip(self.SpriteFlipped);
                        targetGun.UpdateAttachTransform();
                    }
                    self.SecondaryGunPivot.position = self.gunAttachPoint.position + num * new Vector3(-0.75f, 0f, 0f);
                }
                else
                {
                    if (targetGun.transform.parent != self.gunAttachPoint)
                    {
                        targetGun.transform.parent        = self.gunAttachPoint;
                        targetGun.transform.localRotation = Quaternion.identity;
                        targetGun.HandleSpriteFlip(self.SpriteFlipped);
                        targetGun.UpdateAttachTransform();
                    }
                    if (targetGun.IsHeroSword)
                    {
                        float t = 1f - Mathf.Abs((float)_currentGunAngle.GetValue(self) - 90f) / 90f;
                        self.gunAttachPoint.localPosition = BraveUtility.QuantizeVector(Vector3.Slerp(vector, vector2, t), 16f);
                    }
                    else if (targetGun.Handedness == GunHandedness.TwoHanded)
                    {
                        float   t2      = Mathf.PingPong(Mathf.Abs(1f - Mathf.Abs((float)_currentGunAngle.GetValue(self) + 90f) / 90f), 1f);
                        Vector2 vector3 = Vector2.zero;
                        if ((float)_currentGunAngle.GetValue(self) > 0f)
                        {
                            vector3 = Vector2.Scale(targetGun.carryPixelUpOffset.ToVector2(), new Vector2(num, 1f)) * 0.0625f;
                        }
                        else
                        {
                            vector3 = Vector2.Scale(targetGun.carryPixelDownOffset.ToVector2(), new Vector2(num, 1f)) * 0.0625f;
                        }
                        if (targetGun.LockedHorizontalOnCharge)
                        {
                            vector3 = Vector3.Slerp(vector3, Vector2.zero, targetGun.GetChargeFraction());
                        }
                        if ((float)_currentGunAngle.GetValue(self) < 0f)
                        {
                            self.gunAttachPoint.localPosition = BraveUtility.QuantizeVector(Vector3.Slerp(vector, vector2 + vector3.ToVector3ZUp(0f), t2), 16f);
                        }
                        else
                        {
                            self.gunAttachPoint.localPosition = BraveUtility.QuantizeVector(Vector3.Slerp(vector, vector + vector3.ToVector3ZUp(0f), t2), 16f);
                        }
                    }
                    else
                    {
                        self.gunAttachPoint.localPosition = BraveUtility.QuantizeVector(vector, 16f);
                    }
                }
            }
            else
            {
                orig(self, targetGun, isSecondary);
            }
        }