Exemple #1
0
            public bool Update(TimeSpan elapsed)
            {
                this.SinceChanged += elapsed;
                switch (this.State)
                {
                case SpinAction.Idle:
                    Vector3 vector = (this.PlayerManager.Position - this.ArtObject.Position - new Vector3(0.0f, 1f, 0.0f)) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
                    vector.X += vector.Z;
                    Vector3 vector3 = FezMath.Abs(vector);
                    if (FezMath.AlmostEqual(FezMath.Abs(Vector3.Transform(Vector3.UnitZ, this.ArtObject.Rotation)), FezMath.DepthMask(this.CameraManager.Viewpoint)) && ((double)vector3.X < 0.899999976158142 && (double)vector3.Y < 1.0) && (this.PlayerManager.CarriedInstance == null && this.PlayerManager.Grounded) && (this.PlayerManager.Action != ActionType.GrabTombstone && this.InputManager.GrabThrow == FezButtonState.Pressed && this.PlayerManager.Action != ActionType.ReadingSign))
                    {
                        this.SinceChanged = TimeSpan.Zero;
                        return(true);
                    }
                    else
                    {
                        break;
                    }

                case SpinAction.Spinning:
                    double     num           = FezMath.Saturate(this.SinceChanged.TotalSeconds / 0.75);
                    Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(Vector3.UnitY, Easing.EaseIn(num < 0.949999999254942 ? num / 0.949999999254942 : 1.0 + Math.Sin((num - 0.949999999254942) / 0.0500000007450581 * 6.28318548202515 * 2.0) * 0.00999999977648258 * (1.0 - num) / 0.0500000007450581, EasingType.Linear) * 1.570796f * (float)this.SpinSign);
                    this.ArtObject.Rotation     = this.OriginalAoRotation * fromAxisAngle;
                    this.PlayerManager.Position = Vector3.Transform(this.OriginalPlayerPosition - this.ArtObject.Position, fromAxisAngle) + this.ArtObject.Position;
                    if (this.SinceChanged.TotalSeconds >= 0.75)
                    {
                        this.LastViewpoint = FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.MaxClampXZ(Vector3.Transform(Vector3.Forward, this.ArtObject.Rotation))));
                        int count = Enumerable.Count <TombstonesHost.TombstoneState>((IEnumerable <TombstonesHost.TombstoneState>) this.Host.TrackedStones, (Func <TombstonesHost.TombstoneState, bool>)(x => x.LastViewpoint == this.LastViewpoint));
                        this.TombstoneService.UpdateAlignCount(count);
                        if (count > 1)
                        {
                            this.TombstoneService.OnMoreThanOneAligned();
                        }
                        this.Host.StopSkullRotations = count == 4;
                        this.PlayerManager.Action    = ActionType.GrabTombstone;
                        this.PlayerManager.Position += 0.5f * Vector3.UnitY;
                        this.PlayerManager.Velocity  = Vector3.Down;
                        this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager);
                        this.SinceChanged -= TimeSpan.FromSeconds(0.75);
                        this.State         = SpinAction.Grabbed;
                        break;
                    }
                    else
                    {
                        break;
                    }

                case SpinAction.Grabbed:
                    if (this.PlayerManager.Action != ActionType.GrabTombstone)
                    {
                        this.State = SpinAction.Idle;
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
                return(false);
            }
    void Start()
    {
        gameObject.Play(SpinAction.Create(speed));

        // Self-destroy
        Destroy(this);
    }
Exemple #3
0
 public void GrabOnto()
 {
     this.PlayerManager.Action = ActionType.GrabTombstone;
     Waiters.Wait(0.4, (Func <float, bool>)(_ => this.PlayerManager.Action != ActionType.GrabTombstone), (Action)(() =>
     {
         if (this.PlayerManager.Action != ActionType.GrabTombstone)
         {
             return;
         }
         SoundEffectExtensions.EmitAt(this.Host.GrabSound, this.ArtObject.Position);
         this.State = SpinAction.Grabbed;
     }));
 }
Exemple #4
0
 public void TrySpin()
 {
     if (this.State != SpinAction.Grabbed)
     {
         return;
     }
     if (this.PlayerManager.Action != ActionType.GrabTombstone)
     {
         this.State = SpinAction.Idle;
     }
     else
     {
         if (!this.PlayerManager.Animation.Timing.Ended || this.CameraManager.Viewpoint == Viewpoint.Perspective || this.CameraManager.LastViewpoint == this.CameraManager.Viewpoint)
         {
             return;
         }
         this.SpinSign = FezMath.GetDistance(this.CameraManager.LastViewpoint, this.CameraManager.Viewpoint);
         if (this.SpinSign == 1)
         {
             SoundEffectExtensions.EmitAt(this.Host.TurnRight, this.ArtObject.Position);
         }
         else
         {
             SoundEffectExtensions.EmitAt(this.Host.TurnLeft, this.ArtObject.Position);
         }
         int num;
         if (!this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num))
         {
             this.GameState.SaveData.ThisLevel.PivotRotations.Add(this.ArtObject.Id, this.SpinSign);
         }
         else
         {
             this.GameState.SaveData.ThisLevel.PivotRotations[this.ArtObject.Id] = num + this.SpinSign;
         }
         this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.LastViewpoint) + this.ArtObject.Position * FezMath.DepthMask(this.CameraManager.LastViewpoint) + -FezMath.ForwardVector(this.CameraManager.LastViewpoint);
         this.OriginalPlayerPosition = this.PlayerManager.Position;
         this.OriginalAoRotation     = this.ArtObject.Rotation;
         this.SinceChanged           = TimeSpan.Zero;
         this.State = SpinAction.Spinning;
         this.PlayerManager.Action = ActionType.PivotTombstone;
     }
 }
 public void TrySpin()
 {
   if (this.State != SpinAction.Grabbed)
     return;
   if (this.PlayerManager.Action != ActionType.GrabTombstone)
   {
     this.State = SpinAction.Idle;
   }
   else
   {
     if (!this.PlayerManager.Animation.Timing.Ended || this.CameraManager.Viewpoint == Viewpoint.Perspective || this.CameraManager.LastViewpoint == this.CameraManager.Viewpoint)
       return;
     this.SpinSign = FezMath.GetDistance(this.CameraManager.LastViewpoint, this.CameraManager.Viewpoint);
     if (this.IsBolt)
     {
       Vector3 vector3_1 = new Vector3(2f);
       Vector3 vector3_2 = this.ArtObject.Position + this.CenterOffset;
       BoundingBox box = new BoundingBox(vector3_2 - vector3_1, vector3_2 + vector3_1);
       foreach (ArtObjectInstance artObjectInstance in (IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
       {
         if (artObjectInstance.ArtObject.ActorType == ActorType.BoltNutBottom && this.SpinSign == -1)
         {
           Vector3 vector3_3 = artObjectInstance.ArtObject.Size / 2f + Vector3.Up / 32f;
           if (new BoundingBox(artObjectInstance.Position - vector3_3, artObjectInstance.Position + vector3_3).Intersects(box))
           {
             this.CameraManager.CancelViewTransition();
             return;
           }
         }
         else if (artObjectInstance.ArtObject.ActorType == ActorType.BoltNutTop && this.SpinSign == 1)
         {
           Vector3 vector3_3 = artObjectInstance.Position + Vector3.Up * 3.5f;
           Vector3 vector3_4 = artObjectInstance.ArtObject.Size / 2f + Vector3.Up / 32f;
           if (new BoundingBox(vector3_3 - vector3_4, vector3_3 + vector3_4).Intersects(box))
           {
             this.CameraManager.CancelViewTransition();
             return;
           }
         }
       }
     }
     if (this.IsTimeswitch && this.SpinSign == -1)
     {
       this.CameraManager.CancelViewTransition();
     }
     else
     {
       if (this.IsBolt)
       {
         if (this.SpinSign == 1)
           SoundEffectExtensions.EmitAt(this.Host.BoltScrew, this.ArtObject.Position);
         else
           SoundEffectExtensions.EmitAt(this.Host.BoltUnscrew, this.ArtObject.Position);
       }
       else if (this.IsTimeswitch)
         SoundEffectExtensions.EmitAt(this.Host.TimeSwitchWind, this.ArtObject.Position);
       else if (this.SpinSign == 1)
         SoundEffectExtensions.EmitAt(this.Host.ValveScrew, this.ArtObject.Position);
       else
         SoundEffectExtensions.EmitAt(this.Host.ValveUnscrew, this.ArtObject.Position);
       int num;
       if (!this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num))
         this.GameState.SaveData.ThisLevel.PivotRotations.Add(this.ArtObject.Id, this.SpinSign);
       else
         this.GameState.SaveData.ThisLevel.PivotRotations[this.ArtObject.Id] = num + this.SpinSign;
       Viewpoint lastViewpoint = this.CameraManager.LastViewpoint;
       Vector3 vector3_1 = FezMath.ScreenSpaceMask(lastViewpoint);
       Vector3 vector3_2 = FezMath.ForwardVector(lastViewpoint);
       Vector3 vector3_3 = FezMath.DepthMask(lastViewpoint);
       Vector3 vector3_4 = (this.ArtObject.Position + this.CenterOffset) * vector3_3;
       this.OriginalPlayerPosition = this.PlayerManager.Position = this.PlayerManager.Position * vector3_1 + vector3_3 * vector3_4 - vector3_2 * 2f;
       this.OriginalAoRotation = this.ArtObject.Rotation;
       this.OriginalAoPosition = this.IsTimeswitch ? this.TimeswitchScrewAo.Position : this.ArtObject.Position;
       if (this.IsTimeswitch)
         this.OriginalScrewRotation = this.TimeswitchScrewAo.Rotation;
       if (this.AttachedGroup != null)
         this.OriginalGroupTrilePositions = Enumerable.ToArray<Vector3>(Enumerable.Select<TrileInstance, Vector3>((IEnumerable<TrileInstance>) this.AttachedGroup.Triles, (Func<TrileInstance, Vector3>) (x => x.Position)));
       this.SinceChanged = TimeSpan.Zero;
       this.State = SpinAction.Spinning;
       this.PlayerManager.Action = ActionType.PivotTombstone;
       if (this.IsTimeswitch)
       {
         if (this.SpinSign != 1 || (double) this.ScrewHeight > 0.0)
           return;
         this.TimeswitchService.OnScrewedOut(this.ArtObject.Id);
       }
       else if (this.SpinSign == -1)
         this.ValveService.OnUnscrew(this.ArtObject.Id);
       else
         this.ValveService.OnScrew(this.ArtObject.Id);
     }
   }
 }
 public void GrabOnto()
 {
   this.PlayerManager.Action = ActionType.GrabTombstone;
   Waiters.Wait(0.4, (Func<float, bool>) (_ => this.PlayerManager.Action != ActionType.GrabTombstone), (Action) (() =>
   {
     if (this.PlayerManager.Action != ActionType.GrabTombstone)
       return;
     SoundEffectExtensions.EmitAt(this.Host.GrabSound, this.ArtObject.Position);
     this.State = SpinAction.Grabbed;
   }));
 }
 public bool Update(TimeSpan elapsed)
 {
   if (this.MovingToHeight)
     return false;
   this.SinceChanged += elapsed;
   Vector3 vector3_1 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
   switch (this.State)
   {
     case SpinAction.Idle:
       Vector3 vector = (this.PlayerManager.Position - this.ArtObject.Position - new Vector3(0.0f, 1f, 0.0f) + this.CenterOffset) * vector3_1;
       vector.X += vector.Z;
       Vector3 vector3_2 = FezMath.Abs(vector);
       bool flag = this.IsBolt || this.IsTimeswitch ? (double) vector3_2.X > 0.75 && (double) vector3_2.X < 1.75 && (double) vector3_2.Y < 1.0 : (double) vector3_2.X < 1.0 && (double) vector3_2.Y < 1.0;
       if (this.LevelManager.Flat)
         flag = (double) vector3_2.X < 1.5 && (double) vector3_2.Y < 1.0;
       if (flag && this.PlayerManager.CarriedInstance == null && (this.PlayerManager.Grounded && this.PlayerManager.Action != ActionType.GrabTombstone) && (this.InputManager.GrabThrow == FezButtonState.Pressed && this.PlayerManager.Action != ActionType.ReadingSign && (this.PlayerManager.Action != ActionType.Dying && this.PlayerManager.Action != ActionType.FreeFalling)))
       {
         Vector3 vector3_3 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
         Vector3 vector3_4 = FezMath.DepthMask(this.CameraManager.Viewpoint);
         Vector3 vector3_5 = (this.ArtObject.Position + this.CenterOffset) * vector3_4;
         this.PlayerManager.Position = this.PlayerManager.Position * vector3_1 + vector3_4 * vector3_5 - vector3_3 * 1.5f;
         this.SinceChanged = TimeSpan.Zero;
         return true;
       }
       else if (this.IsTimeswitch && (double) this.ScrewHeight >= 0.0 && (double) this.ScrewHeight <= 2.0)
       {
         float num1 = (double) this.ArtObject.ActorSettings.TimeswitchWindBackSpeed == 0.0 ? 4f : this.ArtObject.ActorSettings.TimeswitchWindBackSpeed;
         float num2 = (float) (elapsed.TotalSeconds / ((double) num1 - 0.25) * 2.0);
         this.RewindSpeed = this.SinceChanged.TotalSeconds < 0.5 ? MathHelper.Lerp(0.0f, num2, (float) this.SinceChanged.TotalSeconds * 2f) : num2;
         float num3 = this.ScrewHeight;
         this.ScrewHeight = MathHelper.Clamp(this.ScrewHeight - this.RewindSpeed, 0.0f, 2f);
         float num4 = num3 - this.ScrewHeight;
         if ((double) this.ScrewHeight == 0.0 && (double) num4 != 0.0)
         {
           SoundEffectExtensions.EmitAt(this.Host.TimeswitchEndWindBackSound, this.ArtObject.Position);
           this.TimeswitchService.OnHitBase(this.ArtObject.Id);
           if (this.eTimeswitchWindBack != null && !this.eTimeswitchWindBack.Dead && this.eTimeswitchWindBack.Cue.State == SoundState.Playing)
             this.eTimeswitchWindBack.Cue.Pause();
         }
         else if ((double) num4 != 0.0)
         {
           if (this.eTimeswitchWindBack != null && !this.eTimeswitchWindBack.Dead && this.eTimeswitchWindBack.Cue.State == SoundState.Paused)
             this.eTimeswitchWindBack.Cue.Resume();
           this.eTimeswitchWindBack.VolumeFactor = FezMath.Saturate(num4 * 20f * this.ArtObject.ActorSettings.TimeswitchWindBackSpeed);
         }
         else
         {
           this.eTimeswitchWindBack.VolumeFactor = 0.0f;
           if (this.eTimeswitchWindBack != null && !this.eTimeswitchWindBack.Dead && this.eTimeswitchWindBack.Cue.State == SoundState.Playing)
             this.eTimeswitchWindBack.Cue.Pause();
         }
         this.TimeswitchScrewAo.Position -= Vector3.UnitY * num4;
         this.TimeswitchScrewAo.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitY, (float) ((double) num4 * 1.57079637050629 * -4.0));
         break;
       }
       else
         break;
     case SpinAction.Spinning:
       float num5 = (float) FezMath.Saturate(this.SinceChanged.TotalSeconds / 0.75);
       Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(Vector3.UnitY, num5 * 1.570796f * (float) this.SpinSign);
       this.ArtObject.Rotation = this.OriginalAoRotation * fromAxisAngle;
       this.PlayerManager.Position = Vector3.Transform(this.OriginalPlayerPosition - this.ArtObject.Position, fromAxisAngle) + this.ArtObject.Position;
       if (this.IsBolt)
       {
         Vector3 vector3_3 = num5 * (this.SpinSign == 1 ? 1f : -1f) * Vector3.Up;
         this.ArtObject.Position = this.OriginalAoPosition + vector3_3;
         int num1 = 0;
         foreach (TrileInstance instance in this.AttachedGroup.Triles)
         {
           instance.Position = this.OriginalGroupTrilePositions[num1++] + vector3_3;
           this.LevelManager.UpdateInstance(instance);
         }
         this.PlayerManager.Position += vector3_3;
       }
       if (this.IsTimeswitch)
       {
         float num1 = num5;
         if (this.SpinSign == -1 && (double) this.ScrewHeight <= 0.5)
           num1 = Math.Min(this.ScrewHeight, num5 / 2f) * 2f;
         else if (this.SpinSign == 1 && (double) this.ScrewHeight >= 1.5)
           num1 = Math.Min(2f - this.ScrewHeight, num5 / 2f) * 2f;
         this.TimeswitchScrewAo.Position = this.OriginalAoPosition + num1 * (this.SpinSign == 1 ? 1f : -1f) * Vector3.Up / 2f;
         this.TimeswitchScrewAo.Rotation = this.OriginalScrewRotation * Quaternion.CreateFromAxisAngle(Vector3.UnitY, (float) ((double) num1 * 1.57079637050629 * (double) this.SpinSign * 2.0));
       }
       if (this.SinceChanged.TotalSeconds >= 0.75)
       {
         this.PlayerManager.Position += 0.5f * Vector3.UnitY;
         IPlayerManager playerManager = this.PlayerManager;
         Vector3 vector3_3 = playerManager.Velocity - Vector3.UnitY;
         playerManager.Velocity = vector3_3;
         this.PhysicsManager.Update((IComplexPhysicsEntity) this.PlayerManager);
         FezMath.ForwardVector(this.CameraManager.Viewpoint);
         Vector3 vector3_4 = (this.ArtObject.Position + this.CenterOffset) * FezMath.DepthMask(this.CameraManager.Viewpoint);
         this.ScrewHeight = MathHelper.Clamp(this.ScrewHeight + (float) this.SpinSign / 2f, 0.0f, 2f);
         if ((double) this.ScrewHeight == 0.0 && this.SpinSign == -1)
           this.TimeswitchService.OnHitBase(this.ArtObject.Id);
         this.PlayerManager.Action = ActionType.GrabTombstone;
         this.SinceChanged -= TimeSpan.FromSeconds(0.75);
         this.State = SpinAction.Grabbed;
         break;
       }
       else
         break;
     case SpinAction.Grabbed:
       this.RewindSpeed = 0.0f;
       if (this.PlayerManager.Action != ActionType.GrabTombstone)
         this.State = SpinAction.Idle;
       if (this.IsTimeswitch)
       {
         this.SinceChanged = TimeSpan.Zero;
         this.eTimeswitchWindBack.VolumeFactor = 0.0f;
         if (this.eTimeswitchWindBack != null && !this.eTimeswitchWindBack.Dead && this.eTimeswitchWindBack.Cue.State == SoundState.Playing)
         {
           this.eTimeswitchWindBack.Cue.Pause();
           break;
         }
         else
           break;
       }
       else
         break;
   }
   return false;
 }
Exemple #8
0
 public void TrySpin()
 {
     if (this.State != SpinAction.Grabbed)
     {
         return;
     }
     if (this.PlayerManager.Action != ActionType.GrabTombstone)
     {
         this.State = SpinAction.Idle;
     }
     else
     {
         if (!this.PlayerManager.Animation.Timing.Ended || this.CameraManager.Viewpoint == Viewpoint.Perspective || this.CameraManager.LastViewpoint == this.CameraManager.Viewpoint)
         {
             return;
         }
         this.SpinSign = FezMath.GetDistance(this.CameraManager.LastViewpoint, this.CameraManager.Viewpoint);
         if (this.IsBolt)
         {
             Vector3     vector3_1 = new Vector3(2f);
             Vector3     vector3_2 = this.ArtObject.Position + this.CenterOffset;
             BoundingBox box       = new BoundingBox(vector3_2 - vector3_1, vector3_2 + vector3_1);
             foreach (ArtObjectInstance artObjectInstance in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
             {
                 if (artObjectInstance.ArtObject.ActorType == ActorType.BoltNutBottom && this.SpinSign == -1)
                 {
                     Vector3 vector3_3 = artObjectInstance.ArtObject.Size / 2f + Vector3.Up / 32f;
                     if (new BoundingBox(artObjectInstance.Position - vector3_3, artObjectInstance.Position + vector3_3).Intersects(box))
                     {
                         this.CameraManager.CancelViewTransition();
                         return;
                     }
                 }
                 else if (artObjectInstance.ArtObject.ActorType == ActorType.BoltNutTop && this.SpinSign == 1)
                 {
                     Vector3 vector3_3 = artObjectInstance.Position + Vector3.Up * 3.5f;
                     Vector3 vector3_4 = artObjectInstance.ArtObject.Size / 2f + Vector3.Up / 32f;
                     if (new BoundingBox(vector3_3 - vector3_4, vector3_3 + vector3_4).Intersects(box))
                     {
                         this.CameraManager.CancelViewTransition();
                         return;
                     }
                 }
             }
         }
         if (this.IsTimeswitch && this.SpinSign == -1)
         {
             this.CameraManager.CancelViewTransition();
         }
         else
         {
             if (this.IsBolt)
             {
                 if (this.SpinSign == 1)
                 {
                     SoundEffectExtensions.EmitAt(this.Host.BoltScrew, this.ArtObject.Position);
                 }
                 else
                 {
                     SoundEffectExtensions.EmitAt(this.Host.BoltUnscrew, this.ArtObject.Position);
                 }
             }
             else if (this.IsTimeswitch)
             {
                 SoundEffectExtensions.EmitAt(this.Host.TimeSwitchWind, this.ArtObject.Position);
             }
             else if (this.SpinSign == 1)
             {
                 SoundEffectExtensions.EmitAt(this.Host.ValveScrew, this.ArtObject.Position);
             }
             else
             {
                 SoundEffectExtensions.EmitAt(this.Host.ValveUnscrew, this.ArtObject.Position);
             }
             int num;
             if (!this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num))
             {
                 this.GameState.SaveData.ThisLevel.PivotRotations.Add(this.ArtObject.Id, this.SpinSign);
             }
             else
             {
                 this.GameState.SaveData.ThisLevel.PivotRotations[this.ArtObject.Id] = num + this.SpinSign;
             }
             Viewpoint lastViewpoint = this.CameraManager.LastViewpoint;
             Vector3   vector3_1     = FezMath.ScreenSpaceMask(lastViewpoint);
             Vector3   vector3_2     = FezMath.ForwardVector(lastViewpoint);
             Vector3   vector3_3     = FezMath.DepthMask(lastViewpoint);
             Vector3   vector3_4     = (this.ArtObject.Position + this.CenterOffset) * vector3_3;
             this.OriginalPlayerPosition = this.PlayerManager.Position = this.PlayerManager.Position * vector3_1 + vector3_3 * vector3_4 - vector3_2 * 2f;
             this.OriginalAoRotation     = this.ArtObject.Rotation;
             this.OriginalAoPosition     = this.IsTimeswitch ? this.TimeswitchScrewAo.Position : this.ArtObject.Position;
             if (this.IsTimeswitch)
             {
                 this.OriginalScrewRotation = this.TimeswitchScrewAo.Rotation;
             }
             if (this.AttachedGroup != null)
             {
                 this.OriginalGroupTrilePositions = Enumerable.ToArray <Vector3>(Enumerable.Select <TrileInstance, Vector3>((IEnumerable <TrileInstance>) this.AttachedGroup.Triles, (Func <TrileInstance, Vector3>)(x => x.Position)));
             }
             this.SinceChanged         = TimeSpan.Zero;
             this.State                = SpinAction.Spinning;
             this.PlayerManager.Action = ActionType.PivotTombstone;
             if (this.IsTimeswitch)
             {
                 if (this.SpinSign != 1 || (double)this.ScrewHeight > 0.0)
                 {
                     return;
                 }
                 this.TimeswitchService.OnScrewedOut(this.ArtObject.Id);
             }
             else if (this.SpinSign == -1)
             {
                 this.ValveService.OnUnscrew(this.ArtObject.Id);
             }
             else
             {
                 this.ValveService.OnScrew(this.ArtObject.Id);
             }
         }
     }
 }
Exemple #9
0
            public bool Update(TimeSpan elapsed)
            {
                if (this.MovingToHeight)
                {
                    return(false);
                }
                this.SinceChanged += elapsed;
                Vector3 vector3_1 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);

                switch (this.State)
                {
                case SpinAction.Idle:
                    Vector3 vector = (this.PlayerManager.Position - this.ArtObject.Position - new Vector3(0.0f, 1f, 0.0f) + this.CenterOffset) * vector3_1;
                    vector.X += vector.Z;
                    Vector3 vector3_2 = FezMath.Abs(vector);
                    bool    flag      = this.IsBolt || this.IsTimeswitch ? (double)vector3_2.X > 0.75 && (double)vector3_2.X < 1.75 && (double)vector3_2.Y < 1.0 : (double)vector3_2.X < 1.0 && (double)vector3_2.Y < 1.0;
                    if (this.LevelManager.Flat)
                    {
                        flag = (double)vector3_2.X < 1.5 && (double)vector3_2.Y < 1.0;
                    }
                    if (flag && this.PlayerManager.CarriedInstance == null && (this.PlayerManager.Grounded && this.PlayerManager.Action != ActionType.GrabTombstone) && (this.InputManager.GrabThrow == FezButtonState.Pressed && this.PlayerManager.Action != ActionType.ReadingSign && (this.PlayerManager.Action != ActionType.Dying && this.PlayerManager.Action != ActionType.FreeFalling)))
                    {
                        Vector3 vector3_3 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
                        Vector3 vector3_4 = FezMath.DepthMask(this.CameraManager.Viewpoint);
                        Vector3 vector3_5 = (this.ArtObject.Position + this.CenterOffset) * vector3_4;
                        this.PlayerManager.Position = this.PlayerManager.Position * vector3_1 + vector3_4 * vector3_5 - vector3_3 * 1.5f;
                        this.SinceChanged           = TimeSpan.Zero;
                        return(true);
                    }
                    else if (this.IsTimeswitch && (double)this.ScrewHeight >= 0.0 && (double)this.ScrewHeight <= 2.0)
                    {
                        float num1 = (double)this.ArtObject.ActorSettings.TimeswitchWindBackSpeed == 0.0 ? 4f : this.ArtObject.ActorSettings.TimeswitchWindBackSpeed;
                        float num2 = (float)(elapsed.TotalSeconds / ((double)num1 - 0.25) * 2.0);
                        this.RewindSpeed = this.SinceChanged.TotalSeconds < 0.5 ? MathHelper.Lerp(0.0f, num2, (float)this.SinceChanged.TotalSeconds * 2f) : num2;
                        float num3 = this.ScrewHeight;
                        this.ScrewHeight = MathHelper.Clamp(this.ScrewHeight - this.RewindSpeed, 0.0f, 2f);
                        float num4 = num3 - this.ScrewHeight;
                        if ((double)this.ScrewHeight == 0.0 && (double)num4 != 0.0)
                        {
                            SoundEffectExtensions.EmitAt(this.Host.TimeswitchEndWindBackSound, this.ArtObject.Position);
                            this.TimeswitchService.OnHitBase(this.ArtObject.Id);
                            if (this.eTimeswitchWindBack != null && !this.eTimeswitchWindBack.Dead && this.eTimeswitchWindBack.Cue.State == SoundState.Playing)
                            {
                                this.eTimeswitchWindBack.Cue.Pause();
                            }
                        }
                        else if ((double)num4 != 0.0)
                        {
                            if (this.eTimeswitchWindBack != null && !this.eTimeswitchWindBack.Dead && this.eTimeswitchWindBack.Cue.State == SoundState.Paused)
                            {
                                this.eTimeswitchWindBack.Cue.Resume();
                            }
                            this.eTimeswitchWindBack.VolumeFactor = FezMath.Saturate(num4 * 20f * this.ArtObject.ActorSettings.TimeswitchWindBackSpeed);
                        }
                        else
                        {
                            this.eTimeswitchWindBack.VolumeFactor = 0.0f;
                            if (this.eTimeswitchWindBack != null && !this.eTimeswitchWindBack.Dead && this.eTimeswitchWindBack.Cue.State == SoundState.Playing)
                            {
                                this.eTimeswitchWindBack.Cue.Pause();
                            }
                        }
                        this.TimeswitchScrewAo.Position -= Vector3.UnitY * num4;
                        this.TimeswitchScrewAo.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitY, (float)((double)num4 * 1.57079637050629 * -4.0));
                        break;
                    }
                    else
                    {
                        break;
                    }

                case SpinAction.Spinning:
                    float      num5          = (float)FezMath.Saturate(this.SinceChanged.TotalSeconds / 0.75);
                    Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(Vector3.UnitY, num5 * 1.570796f * (float)this.SpinSign);
                    this.ArtObject.Rotation     = this.OriginalAoRotation * fromAxisAngle;
                    this.PlayerManager.Position = Vector3.Transform(this.OriginalPlayerPosition - this.ArtObject.Position, fromAxisAngle) + this.ArtObject.Position;
                    if (this.IsBolt)
                    {
                        Vector3 vector3_3 = num5 * (this.SpinSign == 1 ? 1f : -1f) * Vector3.Up;
                        this.ArtObject.Position = this.OriginalAoPosition + vector3_3;
                        int num1 = 0;
                        foreach (TrileInstance instance in this.AttachedGroup.Triles)
                        {
                            instance.Position = this.OriginalGroupTrilePositions[num1++] + vector3_3;
                            this.LevelManager.UpdateInstance(instance);
                        }
                        this.PlayerManager.Position += vector3_3;
                    }
                    if (this.IsTimeswitch)
                    {
                        float num1 = num5;
                        if (this.SpinSign == -1 && (double)this.ScrewHeight <= 0.5)
                        {
                            num1 = Math.Min(this.ScrewHeight, num5 / 2f) * 2f;
                        }
                        else if (this.SpinSign == 1 && (double)this.ScrewHeight >= 1.5)
                        {
                            num1 = Math.Min(2f - this.ScrewHeight, num5 / 2f) * 2f;
                        }
                        this.TimeswitchScrewAo.Position = this.OriginalAoPosition + num1 * (this.SpinSign == 1 ? 1f : -1f) * Vector3.Up / 2f;
                        this.TimeswitchScrewAo.Rotation = this.OriginalScrewRotation * Quaternion.CreateFromAxisAngle(Vector3.UnitY, (float)((double)num1 * 1.57079637050629 * (double)this.SpinSign * 2.0));
                    }
                    if (this.SinceChanged.TotalSeconds >= 0.75)
                    {
                        this.PlayerManager.Position += 0.5f * Vector3.UnitY;
                        IPlayerManager playerManager = this.PlayerManager;
                        Vector3        vector3_3     = playerManager.Velocity - Vector3.UnitY;
                        playerManager.Velocity = vector3_3;
                        this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager);
                        FezMath.ForwardVector(this.CameraManager.Viewpoint);
                        Vector3 vector3_4 = (this.ArtObject.Position + this.CenterOffset) * FezMath.DepthMask(this.CameraManager.Viewpoint);
                        this.ScrewHeight = MathHelper.Clamp(this.ScrewHeight + (float)this.SpinSign / 2f, 0.0f, 2f);
                        if ((double)this.ScrewHeight == 0.0 && this.SpinSign == -1)
                        {
                            this.TimeswitchService.OnHitBase(this.ArtObject.Id);
                        }
                        this.PlayerManager.Action = ActionType.GrabTombstone;
                        this.SinceChanged        -= TimeSpan.FromSeconds(0.75);
                        this.State = SpinAction.Grabbed;
                        break;
                    }
                    else
                    {
                        break;
                    }

                case SpinAction.Grabbed:
                    this.RewindSpeed = 0.0f;
                    if (this.PlayerManager.Action != ActionType.GrabTombstone)
                    {
                        this.State = SpinAction.Idle;
                    }
                    if (this.IsTimeswitch)
                    {
                        this.SinceChanged = TimeSpan.Zero;
                        this.eTimeswitchWindBack.VolumeFactor = 0.0f;
                        if (this.eTimeswitchWindBack != null && !this.eTimeswitchWindBack.Dead && this.eTimeswitchWindBack.Cue.State == SoundState.Playing)
                        {
                            this.eTimeswitchWindBack.Cue.Pause();
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                return(false);
            }
Exemple #10
0
 public void TrySpin()
 {
   if (this.State != SpinAction.Grabbed)
     return;
   if (this.PlayerManager.Action != ActionType.GrabTombstone)
   {
     this.State = SpinAction.Idle;
   }
   else
   {
     if (!this.PlayerManager.Animation.Timing.Ended || this.CameraManager.Viewpoint == Viewpoint.Perspective || this.CameraManager.LastViewpoint == this.CameraManager.Viewpoint)
       return;
     this.SpinSign = FezMath.GetDistance(this.CameraManager.LastViewpoint, this.CameraManager.Viewpoint);
     if (this.SpinSign == 1)
       SoundEffectExtensions.EmitAt(this.Host.TurnRight, this.ArtObject.Position);
     else
       SoundEffectExtensions.EmitAt(this.Host.TurnLeft, this.ArtObject.Position);
     int num;
     if (!this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num))
       this.GameState.SaveData.ThisLevel.PivotRotations.Add(this.ArtObject.Id, this.SpinSign);
     else
       this.GameState.SaveData.ThisLevel.PivotRotations[this.ArtObject.Id] = num + this.SpinSign;
     this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.LastViewpoint) + this.ArtObject.Position * FezMath.DepthMask(this.CameraManager.LastViewpoint) + -FezMath.ForwardVector(this.CameraManager.LastViewpoint);
     this.OriginalPlayerPosition = this.PlayerManager.Position;
     this.OriginalAoRotation = this.ArtObject.Rotation;
     this.SinceChanged = TimeSpan.Zero;
     this.State = SpinAction.Spinning;
     this.PlayerManager.Action = ActionType.PivotTombstone;
   }
 }
Exemple #11
0
 public bool Update(TimeSpan elapsed)
 {
   this.SinceChanged += elapsed;
   switch (this.State)
   {
     case SpinAction.Idle:
       Vector3 vector = (this.PlayerManager.Position - this.ArtObject.Position - new Vector3(0.0f, 1f, 0.0f)) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
       vector.X += vector.Z;
       Vector3 vector3 = FezMath.Abs(vector);
       if (FezMath.AlmostEqual(FezMath.Abs(Vector3.Transform(Vector3.UnitZ, this.ArtObject.Rotation)), FezMath.DepthMask(this.CameraManager.Viewpoint)) && ((double) vector3.X < 0.899999976158142 && (double) vector3.Y < 1.0) && (this.PlayerManager.CarriedInstance == null && this.PlayerManager.Grounded) && (this.PlayerManager.Action != ActionType.GrabTombstone && this.InputManager.GrabThrow == FezButtonState.Pressed && this.PlayerManager.Action != ActionType.ReadingSign))
       {
         this.SinceChanged = TimeSpan.Zero;
         return true;
       }
       else
         break;
     case SpinAction.Spinning:
       double num = FezMath.Saturate(this.SinceChanged.TotalSeconds / 0.75);
       Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(Vector3.UnitY, Easing.EaseIn(num < 0.949999999254942 ? num / 0.949999999254942 : 1.0 + Math.Sin((num - 0.949999999254942) / 0.0500000007450581 * 6.28318548202515 * 2.0) * 0.00999999977648258 * (1.0 - num) / 0.0500000007450581, EasingType.Linear) * 1.570796f * (float) this.SpinSign);
       this.ArtObject.Rotation = this.OriginalAoRotation * fromAxisAngle;
       this.PlayerManager.Position = Vector3.Transform(this.OriginalPlayerPosition - this.ArtObject.Position, fromAxisAngle) + this.ArtObject.Position;
       if (this.SinceChanged.TotalSeconds >= 0.75)
       {
         this.LastViewpoint = FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.MaxClampXZ(Vector3.Transform(Vector3.Forward, this.ArtObject.Rotation))));
         int count = Enumerable.Count<TombstonesHost.TombstoneState>((IEnumerable<TombstonesHost.TombstoneState>) this.Host.TrackedStones, (Func<TombstonesHost.TombstoneState, bool>) (x => x.LastViewpoint == this.LastViewpoint));
         this.TombstoneService.UpdateAlignCount(count);
         if (count > 1)
           this.TombstoneService.OnMoreThanOneAligned();
         this.Host.StopSkullRotations = count == 4;
         this.PlayerManager.Action = ActionType.GrabTombstone;
         this.PlayerManager.Position += 0.5f * Vector3.UnitY;
         this.PlayerManager.Velocity = Vector3.Down;
         this.PhysicsManager.Update((IComplexPhysicsEntity) this.PlayerManager);
         this.SinceChanged -= TimeSpan.FromSeconds(0.75);
         this.State = SpinAction.Grabbed;
         break;
       }
       else
         break;
     case SpinAction.Grabbed:
       if (this.PlayerManager.Action != ActionType.GrabTombstone)
       {
         this.State = SpinAction.Idle;
         break;
       }
       else
         break;
   }
   return false;
 }
Exemple #12
0
 public void Spin()
 {
     this.PlayerManager.Action = ActionType.PushingPivot;
     Waiters.Wait(0.5, (Func <float, bool>)(_ => this.PlayerManager.Action != ActionType.PushingPivot), (Action)(() =>
     {
         if (this.PlayerManager.Action != ActionType.PushingPivot)
         {
             return;
         }
         this.SinceChanged = TimeSpan.Zero;
         this.OriginalAoRotation = this.HandleAo.Rotation;
         foreach (TrileInstance item_0 in this.Group.Triles)
         {
             if (item_0.InstanceId == -1)
             {
                 this.LevelMaterializer.CullInstanceIn(item_0);
             }
         }
         Vector3 local_1 = (this.PlayerManager.Position - this.HandleAo.Position - new Vector3(0.0f, 1.5f, 0.0f)) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
         local_1.X += local_1.Z;
         this.SpinSign = this.HandleAo.ArtObject.ActorType != ActorType.Bookcase ? (int)((double)FezMath.Dot(FezMath.Sign(FezMath.RightVector(this.CameraManager.Viewpoint)), Vector3.One) * (double)Math.Sign(local_1.X)) : 1;
         if (this.SpinSign == 1)
         {
             SoundEffectExtensions.Emit(this.Host.RightSound);
         }
         else
         {
             SoundEffectExtensions.Emit(this.Host.LeftSound);
         }
         this.AttachedTriles.Clear();
         foreach (TrileInstance item_1 in this.TopLayer)
         {
             this.AddSupportedTrilesOver(item_1);
         }
         this.OriginalStates = Enumerable.ToArray <Vector4>(Enumerable.Select <TrileInstance, Vector4>(Enumerable.Union <TrileInstance>((IEnumerable <TrileInstance>) this.Group.Triles, (IEnumerable <TrileInstance>) this.AttachedTriles), (Func <TrileInstance, Vector4>)(x => new Vector4(x.Position, x.Phi))));
         for (int local_3 = 0; local_3 < this.AttachedArtObjects.Length; ++local_3)
         {
             this.AttachedAoRotations[local_3] = this.AttachedArtObjects[local_3].Rotation;
             this.AttachedAoOrigins[local_3] = this.AttachedArtObjects[local_3].Position;
         }
         int local_4;
         if (!this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.HandleAo.Id, out local_4))
         {
             this.GameState.SaveData.ThisLevel.PivotRotations.Add(this.HandleAo.Id, this.SpinSign);
         }
         else
         {
             this.GameState.SaveData.ThisLevel.PivotRotations[this.HandleAo.Id] = local_4 + this.SpinSign;
         }
         if (this.SpinSign == 1)
         {
             this.PivotService.OnRotateRight(this.HandleAo.Id);
         }
         else
         {
             this.PivotService.OnRotateLeft(this.HandleAo.Id);
         }
         this.HasShaken = false;
         this.State = SpinAction.Spinning;
         if (this.HandleAo.ArtObject.ActorType != ActorType.Bookcase)
         {
             return;
         }
         this.HandleAo.Enabled = false;
         this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(this.HandleAo.Id);
     }));
 }
Exemple #13
0
            public bool Update(TimeSpan elapsed)
            {
                this.SinceChanged += elapsed;
                switch (this.State)
                {
                case SpinAction.Idle:
                    bool flag;
                    if (this.HandleAo.ArtObject.ActorType == ActorType.Bookcase)
                    {
                        Vector3 vector3 = this.PlayerManager.Position - this.HandleAo.Position;
                        flag = (double)vector3.Z <2.75 && (double)vector3.Z> -0.25 && ((double)vector3.Y <-3.0 && (double)vector3.Y> -4.0) && this.CameraManager.Viewpoint == Viewpoint.Left;
                    }
                    else
                    {
                        Vector3 vector = (this.PlayerManager.Position - this.HandleAo.Position - new Vector3(0.0f, 1.5f, 0.0f)) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
                        vector.X += vector.Z;
                        Vector3 vector3 = FezMath.Abs(vector);
                        flag = (double)vector3.X > 0.75 && (double)vector3.X < 1.75 && (double)vector3.Y < 1.0;
                    }
                    if (this.HandleAo.Enabled && flag && (this.PlayerManager.Grounded && this.PlayerManager.Action != ActionType.PushingPivot) && (FezButtonStateExtensions.IsDown(this.InputManager.GrabThrow) && this.PlayerManager.Action != ActionType.ReadingSign && (this.PlayerManager.Action != ActionType.FreeFalling && this.PlayerManager.Action != ActionType.Dying)))
                    {
                        this.SinceChanged = TimeSpan.Zero;
                        return(true);
                    }
                    else
                    {
                        break;
                    }

                case SpinAction.Spinning:
                    double     num           = FezMath.Saturate(this.SinceChanged.TotalSeconds / 1.5);
                    float      angle         = Easing.EaseIn(num < 0.799999997019768 ? num / 0.799999997019768 : 1.0 + Math.Sin((num - 0.799999997019768) / 0.200000002980232 * 6.28318548202515 * 2.0) * 0.00999999977648258 * (1.0 - num) / 0.200000002980232, EasingType.Quartic) * 1.570796f * (float)this.SpinSign;
                    Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(Vector3.UnitY, angle);
                    Vector3    position      = this.HandleAo.Position;
                    for (int index = 0; index < this.OriginalStates.Length; ++index)
                    {
                        TrileInstance instance = index < this.Group.Triles.Count ? this.Group.Triles[index] : this.AttachedTriles[index - this.Group.Triles.Count];
                        Vector4       vector   = this.OriginalStates[index];
                        instance.Position = Vector3.Transform(FezMath.XYZ(vector) + new Vector3(0.5f) - position, fromAxisAngle) + position - new Vector3(0.5f);
                        instance.Phi      = FezMath.WrapAngle(vector.W + angle);
                        this.LevelMaterializer.GetTrileMaterializer(instance.Trile).UpdateInstance(instance);
                    }
                    if (!this.HasShaken && num > 0.799999997019768)
                    {
                        ServiceHelper.AddComponent((IGameComponent) new CamShake(ServiceHelper.Game)
                        {
                            Distance = 0.25f,
                            Duration = TimeSpan.FromSeconds(0.200000002980232)
                        });
                        this.HasShaken = true;
                    }
                    this.HandleAo.Rotation = this.OriginalAoRotation * fromAxisAngle;
                    for (int index = 0; index < this.AttachedArtObjects.Length; ++index)
                    {
                        this.AttachedArtObjects[index].Rotation = this.AttachedAoRotations[index] * fromAxisAngle;
                        this.AttachedArtObjects[index].Position = Vector3.Transform(this.AttachedAoOrigins[index] - position, fromAxisAngle) + position;
                    }
                    if (this.SinceChanged.TotalSeconds >= 1.5)
                    {
                        this.RotateTriles();
                        this.SinceChanged -= TimeSpan.FromSeconds(1.5);
                        this.State         = SpinAction.Idle;
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
                return(false);
            }
Exemple #14
0
 public void Spin()
 {
   this.PlayerManager.Action = ActionType.PushingPivot;
   Waiters.Wait(0.5, (Func<float, bool>) (_ => this.PlayerManager.Action != ActionType.PushingPivot), (Action) (() =>
   {
     if (this.PlayerManager.Action != ActionType.PushingPivot)
       return;
     this.SinceChanged = TimeSpan.Zero;
     this.OriginalAoRotation = this.HandleAo.Rotation;
     foreach (TrileInstance item_0 in this.Group.Triles)
     {
       if (item_0.InstanceId == -1)
         this.LevelMaterializer.CullInstanceIn(item_0);
     }
     Vector3 local_1 = (this.PlayerManager.Position - this.HandleAo.Position - new Vector3(0.0f, 1.5f, 0.0f)) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
     local_1.X += local_1.Z;
     this.SpinSign = this.HandleAo.ArtObject.ActorType != ActorType.Bookcase ? (int) ((double) FezMath.Dot(FezMath.Sign(FezMath.RightVector(this.CameraManager.Viewpoint)), Vector3.One) * (double) Math.Sign(local_1.X)) : 1;
     if (this.SpinSign == 1)
       SoundEffectExtensions.Emit(this.Host.RightSound);
     else
       SoundEffectExtensions.Emit(this.Host.LeftSound);
     this.AttachedTriles.Clear();
     foreach (TrileInstance item_1 in this.TopLayer)
       this.AddSupportedTrilesOver(item_1);
     this.OriginalStates = Enumerable.ToArray<Vector4>(Enumerable.Select<TrileInstance, Vector4>(Enumerable.Union<TrileInstance>((IEnumerable<TrileInstance>) this.Group.Triles, (IEnumerable<TrileInstance>) this.AttachedTriles), (Func<TrileInstance, Vector4>) (x => new Vector4(x.Position, x.Phi))));
     for (int local_3 = 0; local_3 < this.AttachedArtObjects.Length; ++local_3)
     {
       this.AttachedAoRotations[local_3] = this.AttachedArtObjects[local_3].Rotation;
       this.AttachedAoOrigins[local_3] = this.AttachedArtObjects[local_3].Position;
     }
     int local_4;
     if (!this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.HandleAo.Id, out local_4))
       this.GameState.SaveData.ThisLevel.PivotRotations.Add(this.HandleAo.Id, this.SpinSign);
     else
       this.GameState.SaveData.ThisLevel.PivotRotations[this.HandleAo.Id] = local_4 + this.SpinSign;
     if (this.SpinSign == 1)
       this.PivotService.OnRotateRight(this.HandleAo.Id);
     else
       this.PivotService.OnRotateLeft(this.HandleAo.Id);
     this.HasShaken = false;
     this.State = SpinAction.Spinning;
     if (this.HandleAo.ArtObject.ActorType != ActorType.Bookcase)
       return;
     this.HandleAo.Enabled = false;
     this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(this.HandleAo.Id);
   }));
 }
Exemple #15
0
 public bool Update(TimeSpan elapsed)
 {
   this.SinceChanged += elapsed;
   switch (this.State)
   {
     case SpinAction.Idle:
       bool flag;
       if (this.HandleAo.ArtObject.ActorType == ActorType.Bookcase)
       {
         Vector3 vector3 = this.PlayerManager.Position - this.HandleAo.Position;
         flag = (double) vector3.Z < 2.75 && (double) vector3.Z > -0.25 && ((double) vector3.Y < -3.0 && (double) vector3.Y > -4.0) && this.CameraManager.Viewpoint == Viewpoint.Left;
       }
       else
       {
         Vector3 vector = (this.PlayerManager.Position - this.HandleAo.Position - new Vector3(0.0f, 1.5f, 0.0f)) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
         vector.X += vector.Z;
         Vector3 vector3 = FezMath.Abs(vector);
         flag = (double) vector3.X > 0.75 && (double) vector3.X < 1.75 && (double) vector3.Y < 1.0;
       }
       if (this.HandleAo.Enabled && flag && (this.PlayerManager.Grounded && this.PlayerManager.Action != ActionType.PushingPivot) && (FezButtonStateExtensions.IsDown(this.InputManager.GrabThrow) && this.PlayerManager.Action != ActionType.ReadingSign && (this.PlayerManager.Action != ActionType.FreeFalling && this.PlayerManager.Action != ActionType.Dying)))
       {
         this.SinceChanged = TimeSpan.Zero;
         return true;
       }
       else
         break;
     case SpinAction.Spinning:
       double num = FezMath.Saturate(this.SinceChanged.TotalSeconds / 1.5);
       float angle = Easing.EaseIn(num < 0.799999997019768 ? num / 0.799999997019768 : 1.0 + Math.Sin((num - 0.799999997019768) / 0.200000002980232 * 6.28318548202515 * 2.0) * 0.00999999977648258 * (1.0 - num) / 0.200000002980232, EasingType.Quartic) * 1.570796f * (float) this.SpinSign;
       Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(Vector3.UnitY, angle);
       Vector3 position = this.HandleAo.Position;
       for (int index = 0; index < this.OriginalStates.Length; ++index)
       {
         TrileInstance instance = index < this.Group.Triles.Count ? this.Group.Triles[index] : this.AttachedTriles[index - this.Group.Triles.Count];
         Vector4 vector = this.OriginalStates[index];
         instance.Position = Vector3.Transform(FezMath.XYZ(vector) + new Vector3(0.5f) - position, fromAxisAngle) + position - new Vector3(0.5f);
         instance.Phi = FezMath.WrapAngle(vector.W + angle);
         this.LevelMaterializer.GetTrileMaterializer(instance.Trile).UpdateInstance(instance);
       }
       if (!this.HasShaken && num > 0.799999997019768)
       {
         ServiceHelper.AddComponent((IGameComponent) new CamShake(ServiceHelper.Game)
         {
           Distance = 0.25f,
           Duration = TimeSpan.FromSeconds(0.200000002980232)
         });
         this.HasShaken = true;
       }
       this.HandleAo.Rotation = this.OriginalAoRotation * fromAxisAngle;
       for (int index = 0; index < this.AttachedArtObjects.Length; ++index)
       {
         this.AttachedArtObjects[index].Rotation = this.AttachedAoRotations[index] * fromAxisAngle;
         this.AttachedArtObjects[index].Position = Vector3.Transform(this.AttachedAoOrigins[index] - position, fromAxisAngle) + position;
       }
       if (this.SinceChanged.TotalSeconds >= 1.5)
       {
         this.RotateTriles();
         this.SinceChanged -= TimeSpan.FromSeconds(1.5);
         this.State = SpinAction.Idle;
         break;
       }
       else
         break;
   }
   return false;
 }