Esempio n. 1
0
 public void Rotate(int id, bool clockwise, int turns)
 {
     if (!this.Enabled)
     {
         return;
     }
     foreach (RotatingGroupsHost.RotatingGroupState rotatingGroupState in this.RotatingGroups)
     {
         if (rotatingGroupState.Group.Id == id)
         {
             RotatingGroupsHost.RotatingGroupState cached = rotatingGroupState;
             Waiters.Wait((Func <bool>)(() => cached.Action == SpinAction.Idle), (Action)(() =>
             {
                 cached.Rotate(clockwise, turns);
                 cached.SinceChanged = 0.0f;
             }));
         }
     }
 }
Esempio n. 2
0
            public void Update(float elapsedSeconds)
            {
                if (!this.Enabled && this.Action == SpinAction.Idle)
                {
                    return;
                }
                this.SinceChanged += elapsedSeconds;
                float spinFrequency = this.Group.SpinFrequency;

                switch (this.Action)
                {
                case SpinAction.Idle:
                    if ((double)this.SinceChanged < (double)spinFrequency)
                    {
                        break;
                    }
                    this.SinceChanged -= spinFrequency;
                    this.Rotate(this.Group.SpinClockwise, this.Group.Spin180Degrees ? 2 : 1);
                    break;

                case SpinAction.Spinning:
                    float      num1           = Easing.EaseInOut((double)FezMath.Saturate(FezMath.Saturate(this.SinceChanged / (0.75f * (float)this.Turns)) / 0.75f), EasingType.Quartic, EasingType.Quadratic);
                    float      angle          = num1 * 1.570796f * (float)this.SpinSign * (float)this.Turns;
                    Matrix     fromAxisAngle1 = Matrix.CreateFromAxisAngle(Vector3.UnitY, angle);
                    Quaternion fromAxisAngle2 = Quaternion.CreateFromAxisAngle(Vector3.UnitY, angle);
                    if (!this.PlayerManager.IsOnRotato && (double)num1 < 0.5)
                    {
                        RotatingGroupsHost.RotatingGroupState rotatingGroupState1 = this;
                        int num2 = rotatingGroupState1.HeldOnto | this.Group.Triles.Contains(this.PlayerManager.HeldInstance) ? 1 : 0;
                        rotatingGroupState1.HeldOnto = num2 != 0;
                        RotatingGroupsHost.RotatingGroupState rotatingGroupState2 = this;
                        int num3 = (rotatingGroupState2.GroundedOn ? 1 : 0) | (!this.PlayerManager.Grounded ? 0 : (this.TopLayer.Contains(this.PlayerManager.Ground.First) ? 1 : 0));
                        rotatingGroupState2.GroundedOn = num3 != 0;
                        if (this.GroundedOn || this.HeldOnto)
                        {
                            this.OriginalPlayerPosition   = this.PlayerManager.Position;
                            this.PlayerManager.IsOnRotato = true;
                        }
                    }
                    if ((this.GroundedOn || this.HeldOnto) && ((double)num1 > 0.100000001490116 && !this.CameraManager.ForceTransition))
                    {
                        if (this.HeldOnto && this.Group.FallOnRotate)
                        {
                            this.PlayerManager.Action       = ActionType.Idle;
                            this.PlayerManager.HeldInstance = (TrileInstance)null;
                            this.PlayerManager.IsOnRotato   = false;
                            this.HeldOnto = false;
                        }
                        else
                        {
                            this.CameraManager.ForceTransition = true;
                            this.CameraManager.ChangeViewpoint(FezMath.GetRotatedView(this.CameraManager.Viewpoint, this.SpinSign * this.Turns), -1f);
                            this.CameraManager.Direction = -FezMath.ForwardVector(this.CameraManager.LastViewpoint);
                            this.CameraManager.RebuildView();
                        }
                    }
                    Vector3 vector3_1 = new Vector3(this.Center.X - 0.5f, this.Center.Y - 0.5f, this.Center.Z - 0.5f);
                    for (int index = 0; index < this.OriginalStates.Length; ++index)
                    {
                        TrileInstance instance  = this.Group.Triles[index];
                        Vector4       vector4   = this.OriginalStates[index];
                        Vector3       vector3_2 = Vector3.Transform(new Vector3(vector4.X, vector4.Y, vector4.Z), fromAxisAngle1);
                        instance.Position = new Vector3(vector3_2.X + vector3_1.X, vector3_2.Y + vector3_1.Y, vector3_2.Z + vector3_1.Z);
                        instance.SetPhiLight(vector4.W + angle);
                        this.CachedMaterializers[index].UpdateInstance(instance);
                    }
                    for (int index = 0; index < this.AttachedArtObjects.Length; ++index)
                    {
                        this.AttachedArtObjects[index].Rotation = this.AttachedAoRotations[index] * fromAxisAngle2;
                        this.AttachedArtObjects[index].Position = Vector3.Transform(this.AttachedAoOrigins[index] - this.Center, fromAxisAngle1) + this.Center;
                    }
                    if (this.GroundedOn || this.HeldOnto)
                    {
                        Vector3 position  = this.PlayerManager.Position;
                        Vector3 vector3_2 = Vector3.Transform(this.OriginalPlayerPosition - this.Center, fromAxisAngle1) + this.Center;
                        if (!this.HeldOnto || !this.Group.FallOnRotate)
                        {
                            this.CameraManager.Center   += vector3_2 - position;
                            this.CameraManager.Direction = Vector3.Transform(-this.OriginalForward, fromAxisAngle1);
                        }
                        this.PlayerManager.Position += vector3_2 - position;
                    }
                    if ((double)this.SinceChanged < 0.75 * (double)this.Turns)
                    {
                        break;
                    }
                    if (this.GroundedOn || this.HeldOnto)
                    {
                        this.PlayerManager.IsOnRotato = false;
                        this.RotateTriles();
                        this.CameraManager.ForceTransition = false;
                        this.PlayerManager.ForceOverlapsDetermination();
                    }
                    else
                    {
                        this.RotateTriles();
                    }
                    this.SinceChanged -= 0.75f;
                    this.Action        = SpinAction.Idle;
                    break;
                }
            }