Beispiel #1
0
 private void OnChaserExitSurface(Vector3 point, Vector3 surfaceNormal)
 {
     if (!NetworkServer.active)
     {
         Debug.LogWarning("[Server] function 'System.Void RoR2.WormBodyPositions2::OnChaserExitSurface(UnityEngine.Vector3,UnityEngine.Vector3)' called on client");
         return;
     }
     if (this.warningEffectPrefab)
     {
         EffectManager.instance.SpawnEffect(this.warningEffectPrefab, new EffectData
         {
             origin   = point,
             rotation = Util.QuaternionSafeLookRotation(surfaceNormal)
         }, true);
     }
     this.AddTravelCallback(new WormBodyPositions2.TravelCallback
     {
         time     = WormBodyPositions2.GetSynchronizedTimeStamp() + this.followDelay,
         callback = delegate()
         {
             this.OnExitSurface(point, surfaceNormal);
         }
     });
     this.AddTravelCallback(new WormBodyPositions2.TravelCallback
     {
         time     = WormBodyPositions2.GetSynchronizedTimeStamp() + this.followDelay - 0.5f,
         callback = new Action(this.RpcPlaySurfaceImpactSound)
     });
 }
Beispiel #2
0
 // Token: 0x060017C2 RID: 6082 RVA: 0x00071338 File Offset: 0x0006F538
 private void FixedUpdate()
 {
     if (NetworkServer.active)
     {
         this.enterTriggerCooldownTimer -= Time.fixedDeltaTime;
         this.exitTriggerCooldownTimer  -= Time.fixedDeltaTime;
         Vector3 position   = this.referenceTransform.position;
         float   d          = this.characterBody.moveSpeed * this.speedMultiplier;
         Vector3 normalized = (position - this.chasePosition).normalized;
         float   num        = (this.underground ? this.maxTurnSpeed : (this.maxTurnSpeed * this.turnRateCoefficientAboveGround)) * 0.017453292f;
         Vector3 vector     = new Vector3(this.velocity.x, 0f, this.velocity.z);
         Vector3 a          = new Vector3(normalized.x, 0f, normalized.z);
         vector = Vector3.RotateTowards(vector, a * d, num * Time.fixedDeltaTime, float.PositiveInfinity);
         vector = vector.normalized * d;
         float num2 = position.y - this.chasePosition.y;
         float num3 = -this.velocity.y * this.yDamperConstant;
         float num4 = num2 * this.ySpringConstant;
         if (Mathf.Abs(this.velocity.y) < this.yShoveVelocityThreshold && Mathf.Abs(num2) < this.yShovePositionThreshold)
         {
             this.velocity.y = this.velocity.y + this.yShoveForce * Time.fixedDeltaTime;
         }
         if (!this.underground)
         {
             num4 *= this.wormForceCoefficientAboveGround;
             num3 *= this.wormForceCoefficientAboveGround;
         }
         this.velocity.y     = this.velocity.y + (num4 + num3) * Time.fixedDeltaTime;
         this.velocity      += Physics.gravity * Time.fixedDeltaTime;
         this.velocity       = new Vector3(vector.x, this.velocity.y, vector.z);
         this.chasePosition += this.velocity * Time.fixedDeltaTime;
         this.chasePositionVisualizer.position = this.chasePosition;
         this.underground              = (-num2 < this.undergroundTestYOffset);
         this.keyFrameGenerationTimer -= Time.deltaTime;
         if (this.keyFrameGenerationTimer <= 0f)
         {
             this.keyFrameGenerationTimer = this.keyFrameGenerationInterval;
             this.AttemptToGenerateKeyFrame(this.chasePosition);
         }
         this.SurfaceTest();
         float synchronizedTimeStamp = WormBodyPositions2.GetSynchronizedTimeStamp();
         while (this.travelCallbacks.Count > 0 && this.travelCallbacks[0].time <= synchronizedTimeStamp)
         {
             ref WormBodyPositions2.TravelCallback ptr = this.travelCallbacks[0];
             this.travelCallbacks.RemoveAt(0);
             ptr.callback();
         }
     }
Beispiel #3
0
        // Token: 0x060017B6 RID: 6070 RVA: 0x00070BA8 File Offset: 0x0006EDA8
        private void UpdateHeadOffset()
        {
            float num  = this.headDistance;
            int   num2 = this.keyFrames.Count - 1;
            float num3 = 0f;
            float num4 = WormBodyPositions2.GetSynchronizedTimeStamp() - this.followDelay;

            for (int i = 0; i < num2; i++)
            {
                float time   = this.keyFrames[i + 1].time;
                float length = this.keyFrames[i].length;
                if (time < num4)
                {
                    num = num3 + length * Mathf.InverseLerp(this.keyFrames[i].time, time, num4);
                    break;
                }
                num3 += length;
            }
            this.OnTravel(this.headDistance - num);
        }
Beispiel #4
0
 private void OnChaserEnterSurface(Vector3 point, Vector3 surfaceNormal)
 {
     if (!NetworkServer.active)
     {
         Debug.LogWarning("[Server] function 'System.Void RoR2.WormBodyPositions2::OnChaserEnterSurface(UnityEngine.Vector3,UnityEngine.Vector3)' called on client");
         return;
     }
     this.AddTravelCallback(new WormBodyPositions2.TravelCallback
     {
         time     = WormBodyPositions2.GetSynchronizedTimeStamp() + this.followDelay,
         callback = delegate()
         {
             this.OnEnterSurface(point, surfaceNormal);
         }
     });
     this.AddTravelCallback(new WormBodyPositions2.TravelCallback
     {
         time     = WormBodyPositions2.GetSynchronizedTimeStamp() + this.followDelay - 0.5f,
         callback = new Action(this.RpcPlaySurfaceImpactSound)
     });
 }
Beispiel #5
0
        private void AttemptToGenerateKeyFrame(Vector3 position)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.WormBodyPositions2::AttemptToGenerateKeyFrame(UnityEngine.Vector3)' called on client");
                return;
            }
            WormBodyPositions2.KeyFrame keyFrame = this.newestKeyFrame;
            CubicBezier3 curve  = CubicBezier3.FromVelocities(keyFrame.curve.p1, -keyFrame.curve.v1, position, -this.velocity * (this.keyFrameGenerationInterval * 0.25f));
            float        length = curve.ApproximateLength(50);

            WormBodyPositions2.KeyFrame keyFrame2 = new WormBodyPositions2.KeyFrame
            {
                curve  = curve,
                length = length,
                time   = WormBodyPositions2.GetSynchronizedTimeStamp()
            };
            if (keyFrame2.length >= 0f)
            {
                this.headDistance += keyFrame2.length;
                this.AddKeyFrame(ref keyFrame2);
            }
        }