public void Update(TimeSpan elapsed) { if (this.ArtObject.ActorSettings.Inactive && this.State == SpinBlocksHost.SpinState.Idle) return; this.SinceChanged += elapsed; switch (this.State) { case SpinBlocksHost.SpinState.Idle: if (this.SinceChanged.TotalSeconds < (double) this.ArtObject.ActorSettings.SpinEvery - 0.5 - 0.100000001490116) break; this.OriginalRotation = this.ArtObject.Rotation; this.SinceChanged -= TimeSpan.FromSeconds((double) this.ArtObject.ActorSettings.SpinEvery - 0.5 - 0.100000001490116); this.State = SpinBlocksHost.SpinState.Warning; Vector3 right = this.CameraManager.InverseView.Right; Vector3 interpolatedCenter = this.CameraManager.InterpolatedCenter; float num1 = new Vector2() { X = FezMath.Dot(this.ArtObject.Position - interpolatedCenter, right), Y = (interpolatedCenter.Y - this.ArtObject.Position.Y) }.Length(); if (((double) num1 > 10.0 ? 0.600000023841858 / (((double) num1 - 10.0) / 5.0 + 1.0) : 1.0 - (double) Easing.EaseIn((double) num1 / 10.0, EasingType.Quadratic) * 0.400000005960464) <= 0.0500000007450581) break; this.Emitter = SoundEffectExtensions.EmitAt(this.SoundEffect, this.ArtObject.Position, RandomHelper.Centered(0.0799999982118607)); if (!this.IsRotato) break; this.Emitter.PauseViewTransitions = false; break; case SpinBlocksHost.SpinState.Warning: Quaternion fromAxisAngle1 = Quaternion.CreateFromAxisAngle(FezMath.ForwardVector(this.ArtObject.ActorSettings.SpinView), (float) (-1.57079637050629 * Math.Sin(FezMath.Saturate(this.SinceChanged.TotalSeconds / 0.100000001490116) * 0.785398185253143) * 0.100000001490116)); this.ArtObject.Rotation = fromAxisAngle1 * this.OriginalRotation; this.ArtObject.Position = this.OriginalPosition + Vector3.Transform(-this.RotationOffset, this.SpinAccumulatedRotation * fromAxisAngle1) + this.RotationOffset; if (this.SinceChanged.TotalSeconds < 0.100000001490116) break; this.SinceChanged -= TimeSpan.FromSeconds(0.100000001490116); this.State = SpinBlocksHost.SpinState.Spinning; break; case SpinBlocksHost.SpinState.Spinning: double num2 = FezMath.Saturate(this.SinceChanged.TotalSeconds / 0.5); float num3 = this.IsRotato ? Easing.EaseInOut(FezMath.Saturate(num2 / 0.75), EasingType.Quartic, EasingType.Quadratic) : Easing.EaseIn(num2 < 0.75 ? num2 / 0.75 : 1.0 + Math.Sin((num2 - 0.75) / 0.25 * 6.28318548202515) * 0.0149999996647239, EasingType.Quintic); bool flag1 = this.PlayerManager.Grounded && this.Triles.Contains(this.PlayerManager.Ground.First); if (flag1) { if (!this.IsRotato) { IPlayerManager playerManager = this.PlayerManager; Vector3 vector3 = playerManager.Velocity + FezMath.RightVector(this.ArtObject.ActorSettings.SpinView) * num3 * 0.1f; playerManager.Velocity = vector3; if ((double) num3 > 0.25) this.PlayerManager.Position -= 0.01f * Vector3.UnitY; } else if ((double) num3 > 0.0 && !this.hasRotated) { this.PlayerManager.IsOnRotato = true; this.Rotate(); this.OriginalPlayerPosition = this.PlayerManager.Position; this.CameraManager.ChangeViewpoint(FezMath.GetRotatedView(this.CameraManager.Viewpoint, this.ArtObject.ActorSettings.SpinView == Viewpoint.Up ? 1 : -1), 0.5f); this.hasRotated = true; } } if (!this.IsRotato) { foreach (TrileInstance trileInstance in this.Triles) trileInstance.Enabled = (double) num3 <= 0.25; } bool flag2 = ActionTypeExtensions.IsOnLedge(this.PlayerManager.Action) && this.Triles.Contains(this.PlayerManager.HeldInstance); if (flag2) { if (!this.IsRotato) { IPlayerManager playerManager = this.PlayerManager; Vector3 vector3 = playerManager.Velocity + FezMath.RightVector(this.ArtObject.ActorSettings.SpinView) * num3 * 0.1f; playerManager.Velocity = vector3; if ((double) num3 > 0.25) { this.PlayerManager.Action = ActionType.Falling; this.PlayerManager.HeldInstance = (TrileInstance) null; } } else if ((double) num3 > 0.0 && (double) num3 < 0.5 && !this.hasRotated) { this.PlayerManager.IsOnRotato = true; this.Rotate(); this.OriginalPlayerPosition = this.PlayerManager.Position; this.CameraManager.ChangeViewpoint(FezMath.GetRotatedView(this.CameraManager.Viewpoint, this.ArtObject.ActorSettings.SpinView == Viewpoint.Up ? 1 : -1), 0.5f); this.hasRotated = true; } } this.TrixelParticleSystems.PropagateEnergy(this.ArtObject.Position - FezMath.RightVector(this.ArtObject.ActorSettings.SpinView), num3 * 0.1f); Quaternion fromAxisAngle2 = Quaternion.CreateFromAxisAngle(FezMath.ForwardVector(this.ArtObject.ActorSettings.SpinView), (float) (1.57079637050629 * (double) num3 * 1.10000002384186 - 0.157079637050629)); this.ArtObject.Rotation = fromAxisAngle2 * this.OriginalRotation; this.ArtObject.Position = this.OriginalPosition + Vector3.Transform(-this.RotationOffset, this.SpinAccumulatedRotation * fromAxisAngle2) + this.RotationOffset; if (this.IsRotato && (flag1 || flag2)) { Vector3 vector3 = this.ArtObject.ActorSettings.RotationCenter; if (!this.ArtObject.ActorSettings.OffCenter) vector3 = this.ArtObject.Position; this.PlayerManager.Position = Vector3.Transform(this.OriginalPlayerPosition - vector3, fromAxisAngle2) + vector3; } if (this.SinceChanged.TotalSeconds < 0.5) break; foreach (TrileInstance trileInstance in this.Triles) trileInstance.Enabled = true; if ((!this.IsRotato || !this.hasRotated) && (double) this.Triles.Count != (double) this.ArtObject.ArtObject.Size.X * (double) this.ArtObject.ArtObject.Size.Y * (double) this.ArtObject.ArtObject.Size.Z) this.Rotate(); this.SpinAccumulatedRotation = this.SpinAccumulatedRotation * fromAxisAngle2; this.State = SpinBlocksHost.SpinState.Idle; this.hasRotated = false; this.SinceChanged -= TimeSpan.FromSeconds(0.5); this.PlayerManager.IsOnRotato = false; break; } }
public void Update(TimeSpan elapsed) { if (this.ArtObject.ActorSettings.Inactive && this.State == SpinBlocksHost.SpinState.Idle) { return; } this.SinceChanged += elapsed; switch (this.State) { case SpinBlocksHost.SpinState.Idle: if (this.SinceChanged.TotalSeconds < (double)this.ArtObject.ActorSettings.SpinEvery - 0.5 - 0.100000001490116) { break; } this.OriginalRotation = this.ArtObject.Rotation; this.SinceChanged -= TimeSpan.FromSeconds((double)this.ArtObject.ActorSettings.SpinEvery - 0.5 - 0.100000001490116); this.State = SpinBlocksHost.SpinState.Warning; Vector3 right = this.CameraManager.InverseView.Right; Vector3 interpolatedCenter = this.CameraManager.InterpolatedCenter; float num1 = new Vector2() { X = FezMath.Dot(this.ArtObject.Position - interpolatedCenter, right), Y = (interpolatedCenter.Y - this.ArtObject.Position.Y) }.Length(); if (((double)num1 > 10.0 ? 0.600000023841858 / (((double)num1 - 10.0) / 5.0 + 1.0) : 1.0 - (double)Easing.EaseIn((double)num1 / 10.0, EasingType.Quadratic) * 0.400000005960464) <= 0.0500000007450581) { break; } this.Emitter = SoundEffectExtensions.EmitAt(this.SoundEffect, this.ArtObject.Position, RandomHelper.Centered(0.0799999982118607)); if (!this.IsRotato) { break; } this.Emitter.PauseViewTransitions = false; break; case SpinBlocksHost.SpinState.Warning: Quaternion fromAxisAngle1 = Quaternion.CreateFromAxisAngle(FezMath.ForwardVector(this.ArtObject.ActorSettings.SpinView), (float)(-1.57079637050629 * Math.Sin(FezMath.Saturate(this.SinceChanged.TotalSeconds / 0.100000001490116) * 0.785398185253143) * 0.100000001490116)); this.ArtObject.Rotation = fromAxisAngle1 * this.OriginalRotation; this.ArtObject.Position = this.OriginalPosition + Vector3.Transform(-this.RotationOffset, this.SpinAccumulatedRotation * fromAxisAngle1) + this.RotationOffset; if (this.SinceChanged.TotalSeconds < 0.100000001490116) { break; } this.SinceChanged -= TimeSpan.FromSeconds(0.100000001490116); this.State = SpinBlocksHost.SpinState.Spinning; break; case SpinBlocksHost.SpinState.Spinning: double num2 = FezMath.Saturate(this.SinceChanged.TotalSeconds / 0.5); float num3 = this.IsRotato ? Easing.EaseInOut(FezMath.Saturate(num2 / 0.75), EasingType.Quartic, EasingType.Quadratic) : Easing.EaseIn(num2 < 0.75 ? num2 / 0.75 : 1.0 + Math.Sin((num2 - 0.75) / 0.25 * 6.28318548202515) * 0.0149999996647239, EasingType.Quintic); bool flag1 = this.PlayerManager.Grounded && this.Triles.Contains(this.PlayerManager.Ground.First); if (flag1) { if (!this.IsRotato) { IPlayerManager playerManager = this.PlayerManager; Vector3 vector3 = playerManager.Velocity + FezMath.RightVector(this.ArtObject.ActorSettings.SpinView) * num3 * 0.1f; playerManager.Velocity = vector3; if ((double)num3 > 0.25) { this.PlayerManager.Position -= 0.01f * Vector3.UnitY; } } else if ((double)num3 > 0.0 && !this.hasRotated) { this.PlayerManager.IsOnRotato = true; this.Rotate(); this.OriginalPlayerPosition = this.PlayerManager.Position; this.CameraManager.ChangeViewpoint(FezMath.GetRotatedView(this.CameraManager.Viewpoint, this.ArtObject.ActorSettings.SpinView == Viewpoint.Up ? 1 : -1), 0.5f); this.hasRotated = true; } } if (!this.IsRotato) { foreach (TrileInstance trileInstance in this.Triles) { trileInstance.Enabled = (double)num3 <= 0.25; } } bool flag2 = ActionTypeExtensions.IsOnLedge(this.PlayerManager.Action) && this.Triles.Contains(this.PlayerManager.HeldInstance); if (flag2) { if (!this.IsRotato) { IPlayerManager playerManager = this.PlayerManager; Vector3 vector3 = playerManager.Velocity + FezMath.RightVector(this.ArtObject.ActorSettings.SpinView) * num3 * 0.1f; playerManager.Velocity = vector3; if ((double)num3 > 0.25) { this.PlayerManager.Action = ActionType.Falling; this.PlayerManager.HeldInstance = (TrileInstance)null; } } else if ((double)num3 > 0.0 && (double)num3 < 0.5 && !this.hasRotated) { this.PlayerManager.IsOnRotato = true; this.Rotate(); this.OriginalPlayerPosition = this.PlayerManager.Position; this.CameraManager.ChangeViewpoint(FezMath.GetRotatedView(this.CameraManager.Viewpoint, this.ArtObject.ActorSettings.SpinView == Viewpoint.Up ? 1 : -1), 0.5f); this.hasRotated = true; } } this.TrixelParticleSystems.PropagateEnergy(this.ArtObject.Position - FezMath.RightVector(this.ArtObject.ActorSettings.SpinView), num3 * 0.1f); Quaternion fromAxisAngle2 = Quaternion.CreateFromAxisAngle(FezMath.ForwardVector(this.ArtObject.ActorSettings.SpinView), (float)(1.57079637050629 * (double)num3 * 1.10000002384186 - 0.157079637050629)); this.ArtObject.Rotation = fromAxisAngle2 * this.OriginalRotation; this.ArtObject.Position = this.OriginalPosition + Vector3.Transform(-this.RotationOffset, this.SpinAccumulatedRotation * fromAxisAngle2) + this.RotationOffset; if (this.IsRotato && (flag1 || flag2)) { Vector3 vector3 = this.ArtObject.ActorSettings.RotationCenter; if (!this.ArtObject.ActorSettings.OffCenter) { vector3 = this.ArtObject.Position; } this.PlayerManager.Position = Vector3.Transform(this.OriginalPlayerPosition - vector3, fromAxisAngle2) + vector3; } if (this.SinceChanged.TotalSeconds < 0.5) { break; } foreach (TrileInstance trileInstance in this.Triles) { trileInstance.Enabled = true; } if ((!this.IsRotato || !this.hasRotated) && (double)this.Triles.Count != (double)this.ArtObject.ArtObject.Size.X * (double)this.ArtObject.ArtObject.Size.Y * (double)this.ArtObject.ArtObject.Size.Z) { this.Rotate(); } this.SpinAccumulatedRotation = this.SpinAccumulatedRotation * fromAxisAngle2; this.State = SpinBlocksHost.SpinState.Idle; this.hasRotated = false; this.SinceChanged -= TimeSpan.FromSeconds(0.5); this.PlayerManager.IsOnRotato = false; break; } }