private void DoLoad(bool dummy) { this.LevelManager.ChangeLevel(this.NextLevel); this.GameState.ScheduleLoadEnd = true; this.State = EnterPipe.States.FadeIn; Volume volume = Enumerable.FirstOrDefault <Volume>((IEnumerable <Volume>) this.LevelManager.Volumes.Values, (Func <Volume, bool>)(v => { int local_0 = v.Id; int?local_1 = Enumerable.First <Script>((IEnumerable <Script>) this.LevelManager.Scripts.Values, (Func <Script, bool>)(s => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a => a.Operation == "AllowPipeChangeLevel")))).Triggers[0].Object.Identifier; if (local_0 == local_1.GetValueOrDefault()) { return(local_1.HasValue); } else { return(false); } })); if (volume == null) { throw new InvalidOperationException("Missing pipe volume in destination level!"); } Vector3 a = (volume.From + volume.To) / 2f; this.PlayerManager.Action = ActionType.EnteringPipe; this.PlayerManager.Position = a + Vector3.UnitY * 1.25f * (this.Descending ? 1f : -1f); this.PlayerManager.Velocity = Vector3.Zero; this.PlayerManager.RecordRespawnInformation(); this.Depth = FezMath.Dot(a, FezMath.DepthMask(this.CameraManager.Viewpoint)); }
protected override bool Act(TimeSpan elapsed) { if (this.PlayerManager.HeldInstance == null) { this.PlayerManager.Action = ActionType.Idle; return(false); } else { if (this.PlayerManager.HeldInstance.PhysicsState != null) { this.camOrigin += this.PlayerManager.HeldInstance.PhysicsState.Velocity; } Vector3 vector3_1 = FezMath.SideMask(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.DepthMask(this.CameraManager.Viewpoint); Vector3 vector3_3 = FezMath.ForwardVector(this.CameraManager.Viewpoint); this.PlayerManager.Position = this.PlayerManager.Position * vector3_1 + this.PlayerManager.HeldInstance.Center * (Vector3.UnitY + vector3_2) + vector3_3 * (float)-(0.5 + (double)this.PlayerManager.Size.X / 2.0) + this.PlayerManager.HeldInstance.Trile.Size.Y / 2f * Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor); this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + this.PlayerManager.HeldInstance.Center * vector3_2 + vector3_3 * -(this.PlayerManager.HeldInstance.TransformedSize / 2f + this.PlayerManager.Size.X * vector3_2 / 4f); this.PhysicsManager.HugWalls((IPhysicsEntity)this.PlayerManager, false, false, true); Vector3 vector3_4 = this.PlayerManager.Size.Y / 2f * Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor); if (!this.CameraManager.StickyCam && !this.CameraManager.Constrained) { this.CameraManager.Center = Vector3.Lerp(this.camOrigin, this.camOrigin - vector3_4, this.PlayerManager.Animation.Timing.NormalizedStep); } this.PlayerManager.SplitUpCubeCollectorOffset = vector3_4 * (1f - this.PlayerManager.Animation.Timing.NormalizedStep); if (!this.PlayerManager.Animation.Timing.Ended) { return(true); } this.PlayerManager.SplitUpCubeCollectorOffset = Vector3.Zero; this.PlayerManager.Action = ActionType.GrabLedgeBack; return(false); } }
private void TryAssembleCube() { if (this.AssembleScheduled || this.GameState.SaveData.CollectedParts != 8) { return; } this.AssembleScheduled = true; Waiters.Wait((Func <bool>)(() => { if (!this.GameState.Loading && ActionTypeExtensions.AllowsLookingDirectionChange(this.PlayerManager.Action) && (this.SpeechBubble.Hidden && !this.GameState.ForceTimePaused) && (this.PlayerManager.CanControl && !ActionTypeExtensions.DisallowsRespawn(this.PlayerManager.Action) && (this.CameraManager.ViewTransitionReached && !this.PlayerManager.InDoorTransition))) { return(this.PlayerManager.CarriedInstance == null); } else { return(false); } }), (Action)(() => Waiters.Wait(0.0, (Action)(() => { Vector3 local_0 = FezMath.DepthMask(this.CameraManager.Viewpoint); Vector3 local_1 = FezMath.ForwardVector(this.CameraManager.Viewpoint); TrileInstance local_3 = new TrileInstance((this.PlayerManager.Position + Vector3.UnitY * (float)(Math.Sin(this.timeAcc.TotalSeconds * 3.14159274101257) * 0.100000001490116 + 2.0) - FezMath.HalfVector) * (Vector3.One - local_0) - local_1 * (this.LevelManager.Size / 2f - local_0 * 2f) + local_0 * this.LevelManager.Size / 2f, Enumerable.Last <Trile>((IEnumerable <Trile>) this.LevelManager.TrileSet.Triles.Values, (Func <Trile, bool>)(x => x.ActorSettings.Type == ActorType.CubeShard)).Id); this.LevelManager.RestoreTrile(local_3); this.LevelMaterializer.CullInstanceIn(local_3); this.PlayerManager.ForcedTreasure = local_3; this.PlayerManager.Action = ActionType.FindingTreasure; this.AssembleScheduled = false; })))); }
private Vector3 GetDestination() { TrileInstance pushedInstance = this.PlayerManager.PushedInstance; Vector3 vector = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection); Vector3 vector3_1 = FezMath.Abs(vector); Vector3 vector3_2 = FezMath.DepthMask(this.CameraManager.Viewpoint); return((pushedInstance.Center * vector3_1 + this.PlayerManager.Position * vector3_2) * FezMath.XZMask + -pushedInstance.TransformedSize / 2f * vector + -7.0 / 16.0 * vector + this.PlayerManager.Position * Vector3.UnitY); }
private Vector3 GetDestination() { if (!this.PlayerManager.DoorVolume.HasValue || !this.LevelManager.Volumes.ContainsKey(this.PlayerManager.DoorVolume.Value)) { return(this.PlayerManager.Position); } Volume volume = this.LevelManager.Volumes[this.PlayerManager.DoorVolume.Value]; return(this.PlayerManager.Position * (Vector3.UnitY + FezMath.DepthMask(this.CameraManager.Viewpoint)) + (volume.From + volume.To) / 2f * FezMath.SideMask(this.CameraManager.Viewpoint)); }
private void CheckInput() { Vector3 vector3_1 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.DepthMask(this.CameraManager.Viewpoint); Vector3 vector3_3 = this.CodeMachineAO.ArtObject.Size * vector3_1; Vector3 vector3_4 = this.CodeMachineAO.Position * vector3_1; if (new BoundingBox(vector3_4 - vector3_3 - Vector3.UnitY * 2f, vector3_4 + vector3_3 + vector3_2).Contains(this.PlayerManager.Position * vector3_1 + vector3_2 / 2f) == ContainmentType.Disjoint) { return; } if (this.InputManager.Jump == FezButtonState.Pressed) { this.OnInput(CodeInput.Jump); } else if (this.InputManager.RotateRight == FezButtonState.Pressed) { this.OnInput(CodeInput.SpinRight); } else if (this.InputManager.RotateLeft == FezButtonState.Pressed) { this.OnInput(CodeInput.SpinLeft); } else if (this.InputManager.Left == FezButtonState.Pressed) { this.OnInput(CodeInput.Left); } else if (this.InputManager.Right == FezButtonState.Pressed) { this.OnInput(CodeInput.Right); } else if (this.InputManager.Up == FezButtonState.Pressed) { this.OnInput(CodeInput.Up); } else { if (this.InputManager.Down != FezButtonState.Pressed) { return; } this.OnInput(CodeInput.Down); } }
protected override bool Act(TimeSpan elapsed) { if (this.PlayerManager.PushedInstance == null || this.PlayerManager.PushedInstance.Hidden || this.PlayerManager.PushedInstance.PhysicsState == null) { this.PlayerManager.Action = ActionType.Idle; this.PlayerManager.PushedInstance = (TrileInstance)null; return(false); } else { int frame = this.PlayerManager.Animation.Timing.Frame; if (this.lastFrame != frame && this.PlayerManager.LastAction != ActionType.Pushing && this.PlayerManager.Action == ActionType.Grabbing) { if (frame == 3) { SoundEffectExtensions.EmitAt(this.grabSound, this.PlayerManager.Position); } this.lastFrame = frame; } Vector3 vector3_1 = FezMath.SideMask(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.DepthMask(this.CameraManager.Viewpoint); Vector3 vector3_3 = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)this.pushingDirectionSign; this.PlayerManager.Center = Vector3.Up * this.PlayerManager.Center + (vector3_2 + vector3_1) * this.PlayerManager.PushedInstance.Center + -vector3_3 * (this.PlayerManager.PushedInstance.TransformedSize / 2f + this.PlayerManager.Size / 2f); if ((this.PlayerManager.Action == ActionType.Pushing || this.PlayerManager.Action == ActionType.Grabbing) && (this.pushingDirectionSign == -Math.Sign(this.InputManager.Movement.X) || !this.PlayerManager.Grounded)) { this.PlayerManager.PushedInstance = (TrileInstance)null; this.PlayerManager.Action = ActionType.Idle; return(false); } else { if (this.PlayerManager.Action != ActionType.Grabbing || !this.PlayerManager.Animation.Timing.Ended || (double)this.InputManager.Movement.X == 0.0) { return(this.PlayerManager.Action == ActionType.Grabbing); } this.PlayerManager.Action = ActionType.Pushing; return(false); } } }
protected override bool Act(TimeSpan elapsed) { if (this.PlayerManager.HeldInstance.PhysicsState != null) { this.PlayerManager.Position += this.PlayerManager.HeldInstance.PhysicsState.Velocity; } if (!this.PlayerManager.Animation.Timing.Ended) { return(true); } this.PlayerManager.Action = ActionType.GrabLedgeBack; Vector3 vector3_1 = FezMath.SideMask(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.DepthMask(this.CameraManager.Viewpoint); Vector3 vector3_3 = FezMath.ForwardVector(this.CameraManager.Viewpoint); TrileInstance heldInstance = this.PlayerManager.HeldInstance; this.PlayerManager.Position = this.PlayerManager.Position * vector3_1 + heldInstance.Center * (Vector3.UnitY + vector3_2) + vector3_3 * (float)-(0.5 + (double)this.PlayerManager.Size.X / 4.0) + Vector3.UnitY * 8f / 16f * (float)Math.Sign(this.CollisionManager.GravityFactor); this.PlayerManager.ForceOverlapsDetermination(); this.PhysicsManager.HugWalls((IPhysicsEntity)this.PlayerManager, false, false, true); this.PlayerManager.HeldInstance = this.PlayerManager.AxisCollision[VerticalDirection.Down].Deep; return(false); }
protected override void TestConditions() { switch (this.PlayerManager.Action) { case ActionType.Jumping: case ActionType.Falling: if (!FezButtonStateExtensions.IsDown(this.InputManager.Up)) { break; } FaceOrientation face = FezMath.VisibleOrientation(this.CameraManager.Viewpoint); TrileInstance trileInstance1 = this.PlayerManager.AxisCollision[VerticalDirection.Up].Deep; TrileInstance trileInstance2 = this.PlayerManager.AxisCollision[VerticalDirection.Down].Deep; if (trileInstance1 != null && trileInstance1.GetRotatedFace(face) == CollisionType.AllSides || (trileInstance2 == null || trileInstance2.GetRotatedFace(face) != CollisionType.TopOnly) || BoxCollisionResultExtensions.AnyHit(this.CollisionManager.CollideEdge(trileInstance2.Center, Vector3.Down * (float)Math.Sign(this.CollisionManager.GravityFactor), this.PlayerManager.Size * FezMath.XZMask / 2f, Direction2D.Vertical))) { break; } TrileInstance trileInstance3 = this.PlayerManager.AxisCollision[VerticalDirection.Down].Surface; if (trileInstance3 != null && ActorTypeExtensions.IsClimbable(trileInstance3.Trile.ActorSettings.Type) || !trileInstance2.Enabled || this.PlayerManager.Action == ActionType.Jumping && (double)((trileInstance2.Center - this.PlayerManager.LeaveGroundPosition) * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint)).Length() < 1.25) { break; } this.PlayerManager.Action = ActionType.GrabLedgeBack; Vector3 vector3_1 = FezMath.DepthMask(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.SideMask(this.CameraManager.Viewpoint); Vector3 vector3_3 = FezMath.ForwardVector(this.CameraManager.Viewpoint); this.PlayerManager.HeldInstance = trileInstance2; IPlayerManager playerManager = this.PlayerManager; Vector3 vector3_4 = playerManager.Velocity * vector3_2 * 0.5f; playerManager.Velocity = vector3_4; this.PlayerManager.Position = this.PlayerManager.Position * vector3_2 + trileInstance2.Center * (Vector3.UnitY + vector3_1) + vector3_3 * -(this.PlayerManager.HeldInstance.TransformedSize / 2f + this.PlayerManager.Size.X * vector3_1 / 4f) + this.PlayerManager.HeldInstance.Trile.Size.Y / 2f * Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor); Waiters.Wait(0.1, (Action)(() => { SoundEffectExtensions.EmitAt(this.sound, this.PlayerManager.Position); this.PlayerManager.Velocity = Vector3.Zero; })); break; } }
public override void Update(GameTime gameTime) { if (this.GameState.Paused || this.GameState.InMap || (!this.CameraManager.ActionRunning || !FezMath.IsOrthographic(this.CameraManager.Viewpoint)) || (this.GameState.Loading || this.TrackedSuckBlocks.Count == 0)) { return; } FaceOrientation visibleOrientation = this.CameraManager.VisibleOrientation; Vector3 vector3_1 = FezMath.ForwardVector(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.DepthMask(this.CameraManager.Viewpoint); Vector3 vector3_3 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); Vector3 vector3_4 = vector3_3 / 2f; bool flag1 = false; foreach (SuckBlocksHost.SuckBlockState suckBlockState in this.TrackedSuckBlocks) { TrileInstance instance = suckBlockState.Instance; if (this.PlayerManager.HeldInstance != instance) { int num1 = instance.ActorSettings.HostVolume.Value; Vector3 vector3_5 = instance.Center * (Vector3.One - vector3_2) + this.CameraManager.Position * vector3_2; this.cornerRays[0] = new Ray() { Position = vector3_5 + vector3_4 * new Vector3(1f, 0.499f, 1f), Direction = vector3_1 }; this.cornerRays[1] = new Ray() { Position = vector3_5 + vector3_4 * new Vector3(1f, -1f, 1f), Direction = vector3_1 }; this.cornerRays[2] = new Ray() { Position = vector3_5 + vector3_4 * new Vector3(-1f, 0.499f, -1f), Direction = vector3_1 }; this.cornerRays[3] = new Ray() { Position = vector3_5 + vector3_4 * new Vector3(-1f, -1f, -1f), Direction = vector3_1 }; suckBlockState.Update(gameTime.ElapsedGameTime); this.eCratePush.Position = instance.Center; bool flag2 = false; foreach (Volume volume in this.HostingVolumes) { if (volume.Orientations.Contains(visibleOrientation)) { bool flag3 = false; foreach (Ray ray in this.cornerRays) { flag3 = flag3 | volume.BoundingBox.Intersects(ray).HasValue; } if (flag3) { flag2 = true; if (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Sucking && (this.eSuck == null || this.eSuck.Dead)) { this.eSuck = SoundEffectExtensions.EmitAt(this.sSuck, instance.Center, true); } flag1 = ((flag1 ? 1 : 0) | (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Sucking ? 1 : (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Processing ? 1 : 0))) != 0; Vector3 vector3_6 = (volume.BoundingBox.Min + volume.BoundingBox.Max) / 2f; Vector3 vector3_7 = (vector3_6 - instance.Center) * vector3_3; float num2 = vector3_7.Length(); if ((double)num2 < 0.00999999977648258) { if (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Sucking) { suckBlockState.Action = SuckBlocksHost.SuckBlockAction.Processing; this.PlayerManager.CanRotate = false; this.eCratePush.VolumeFactor = 0.5f; this.eCratePush.Cue.Pitch = -0.4f; } if (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Processing) { Vector3 vector3_8 = (volume.BoundingBox.Max - volume.BoundingBox.Min) / 2f; Vector3 vector3_9 = volume.BoundingBox.Min * vector3_3 + vector3_6 * vector3_2 + vector3_8 * vector3_1 - vector3_1 * 0.5f - vector3_2 * 0.5f; Vector3 vector3_10 = vector3_9 - vector3_1; instance.Position = Vector3.Lerp(vector3_10, vector3_9, (float)suckBlockState.SinceActionChanged.Ticks / (float)SuckBlocksHost.SuckBlockState.ProcessingTime.Ticks); this.LevelManager.UpdateInstance(instance); if (suckBlockState.SinceActionChanged > SuckBlocksHost.SuckBlockState.ProcessingTime) { this.PlayerManager.CanRotate = true; if (volume.Id == num1) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type SuckBlocksHost.\u003C\u003Ec__DisplayClassb cDisplayClassb = new SuckBlocksHost.\u003C\u003Ec__DisplayClassb(); SuckBlocksHost.DisableTrile(instance); suckBlockState.Action = SuckBlocksHost.SuckBlockAction.Accepted; if (this.eCratePush.Cue.State != SoundState.Paused) { this.eCratePush.Cue.Pause(); } this.SuckBlockService.OnSuck(suckBlockState.Group.Id); SoundEffectExtensions.Emit(this.sAccept[4 - this.TrackedSuckBlocks.Count]); Texture2D texture2D = this.CMProvider.CurrentLevel.Load <Texture2D>("Other Textures/suck_blocks/four_highlight_" + instance.Trile.CubemapPath.Substring(instance.Trile.CubemapPath.Length - 1).ToLower(CultureInfo.InvariantCulture)); // ISSUE: reference to a compiler-generated field cDisplayClassb.plane = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, (Texture)texture2D) { Position = instance.Center + FezMath.AsVector(visibleOrientation) * (17.0 / 32.0), Rotation = this.CameraManager.Rotation, Doublesided = true, Fullbright = true, Opacity = 0.0f }; // ISSUE: reference to a compiler-generated field this.highlightPlanes.Add(cDisplayClassb.plane); // ISSUE: reference to a compiler-generated field this.LevelManager.AddPlane(cDisplayClassb.plane); // ISSUE: reference to a compiler-generated method Waiters.Interpolate(1.0, new Action <float>(cDisplayClassb.\u003CUpdate\u003Eb__6)); if (this.TrackedSuckBlocks.Count == 1) { Waiters.Wait(2.0, (Action)(() => Waiters.Interpolate(1.0, (Action <float>)(s => { foreach (BackgroundPlane item_3 in this.highlightPlanes) { item_3.Opacity = 1f - s; } }), (Action)(() => this.eSuck = (SoundEmitter)null)))); this.eSuck.FadeOutAndDie(1f); } } else { suckBlockState.Action = SuckBlocksHost.SuckBlockAction.Rejected; } } } if (suckBlockState.Action == SuckBlocksHost.SuckBlockAction.Rejected && FezMath.XZ(instance.PhysicsState.Velocity) == Vector2.Zero) { int num3 = RandomHelper.Probability(0.5) ? -1 : 1; Vector3 vector3_8 = new Vector3((float)num3, 0.75f, (float)num3) * vector3_3; ServiceHelper.AddComponent((IGameComponent) new CamShake(this.Game) { Distance = 0.1f, Duration = TimeSpan.FromSeconds(0.25) }); SoundEffectExtensions.Emit(this.sDenied); if (this.eCratePush.Cue.State != SoundState.Paused) { this.eCratePush.Cue.Pause(); } instance.PhysicsState.Velocity += 6f * vector3_8 * (float)gameTime.ElapsedGameTime.TotalSeconds; } } else if (suckBlockState.Action != SuckBlocksHost.SuckBlockAction.Rejected) { if (instance.PhysicsState.Grounded && this.eCratePush.Cue.State != SoundState.Playing) { this.eCratePush.Cue.Pitch = 0.0f; this.eCratePush.Cue.Resume(); } else if (!instance.PhysicsState.Grounded && this.eCratePush.Cue.State != SoundState.Paused) { this.eCratePush.Cue.Pause(); } if (this.eCratePush.Cue.State == SoundState.Playing) { this.eCratePush.VolumeFactor = FezMath.Saturate(Math.Abs(FezMath.Dot(instance.PhysicsState.Velocity, FezMath.XZMask) / 0.1f)); } suckBlockState.Action = SuckBlocksHost.SuckBlockAction.Sucking; instance.PhysicsState.Velocity += 0.25f * vector3_7 / num2 * (float)gameTime.ElapsedGameTime.TotalSeconds; } } } } if (!flag2) { suckBlockState.Action = SuckBlocksHost.SuckBlockAction.Idle; } } } if (!flag1 && this.eSuck != null && !this.eSuck.Dead) { this.eSuck.FadeOutAndDie(0.1f); this.eSuck = (SoundEmitter)null; } for (int index = 0; index < this.TrackedSuckBlocks.Count; ++index) { if (this.TrackedSuckBlocks[index].Action == SuckBlocksHost.SuckBlockAction.Accepted) { this.TrackedSuckBlocks.RemoveAt(index); --index; } } }
private void FollowGomez() { float num1 = this.CameraManager.PixelsPerTrixel; if (this.GameState.FarawaySettings.InTransition && FezMath.AlmostEqual(this.GameState.FarawaySettings.DestinationCrossfadeStep, 1f)) { num1 = MathHelper.Lerp(this.CameraManager.PixelsPerTrixel, this.GameState.FarawaySettings.DestinationPixelsPerTrixel, (float)(((double)this.GameState.FarawaySettings.TransitionStep - 0.875) / 0.125)); } float num2 = (float)(4.0 * (this.LevelManager.Descending ? -1.0 : 1.0)) / num1; Vector3 vector3_1 = new Vector3(this.CameraManager.Center.X, this.PlayerManager.Position.Y + num2, this.CameraManager.Center.Z); Vector3 center = this.CameraManager.Center; if (this.CameraManager.StickyCam) { Vector3 vector3_2 = this.PlayerManager.Position + Vector3.UnitY * num2; Vector3 vector3_3 = this.StickyCenter * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) - vector3_2 * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); float val1 = vector3_3.Length() + 1f; if (this.InputManager.FreeLook == Vector2.Zero) { this.MinimumStickDistance = Math.Min(val1, this.MinimumStickDistance); float viewScale = SettingsManager.GetViewScale(this.GraphicsDevice); if ((double)Math.Abs(vector3_3.X + vector3_3.Z) > (double)this.CameraManager.Radius * 0.400000005960464 / (double)viewScale || (double)Math.Abs(vector3_3.Y) > (double)this.CameraManager.Radius * 0.400000005960464 / (double)this.CameraManager.AspectRatio / (double)viewScale) { this.MinimumStickDistance = 2.5f; } if ((double)this.MinimumStickDistance < 4.0) { this.StickyCenter = Vector3.Lerp(this.StickyCenter, vector3_2, (float)Math.Pow(1.0 / (double)this.MinimumStickDistance, 4.0)); } } vector3_1 = this.StickyCenter; if ((double)val1 <= 1.1) { this.CameraManager.StickyCam = false; } } else { if ((double)MathHelper.Clamp(this.PlayerManager.Position.X, center.X - 1.5f, center.X + 1.5f) != (double)this.PlayerManager.Position.X) { float num3 = this.PlayerManager.Position.X - center.X; vector3_1.X += num3 - 1.5f * (float)Math.Sign(num3); } if ((double)MathHelper.Clamp(this.PlayerManager.Position.Z, center.Z - 1.5f, center.Z + 1.5f) != (double)this.PlayerManager.Position.Z) { float num3 = this.PlayerManager.Position.Z - this.CameraManager.Center.Z; vector3_1.Z += num3 - 1.5f * (float)Math.Sign(num3); } } if (this.CameraManager.PanningConstraints.HasValue && !this.GameState.InMap) { Vector3 vector3_2 = FezMath.DepthMask(this.CameraManager.Viewpoint); Vector3 vector3_3 = FezMath.SideMask(this.CameraManager.Viewpoint); Vector3 vector3_4 = new Vector3(MathHelper.Lerp(this.CameraManager.ConstrainedCenter.X, vector3_1.X, this.CameraManager.PanningConstraints.Value.X), MathHelper.Lerp(this.CameraManager.ConstrainedCenter.Y, vector3_1.Y, this.CameraManager.PanningConstraints.Value.Y), MathHelper.Lerp(this.CameraManager.ConstrainedCenter.Z, vector3_1.Z, this.CameraManager.PanningConstraints.Value.X)); this.CameraManager.Center = this.CameraManager.Center * vector3_2 + vector3_3 * vector3_4 + Vector3.UnitY * vector3_4; } else { if (this.GameState.InMenuCube || this.GameState.InMap || FezMath.In <ActionType>(this.PlayerManager.Action, ActionType.PullUpCornerLedge, ActionType.LowerToCornerLedge, ActionType.Victory, (IEqualityComparer <ActionType>)ActionTypeComparer.Default)) { return; } this.CameraManager.Center = vector3_1; } }
protected override void TestConditions() { switch (this.PlayerManager.Action) { case ActionType.Teetering: case ActionType.IdlePlay: case ActionType.IdleSleep: case ActionType.IdleLookAround: case ActionType.IdleYawn: case ActionType.Idle: case ActionType.LookingLeft: case ActionType.LookingRight: case ActionType.LookingUp: case ActionType.LookingDown: case ActionType.Walking: case ActionType.Running: case ActionType.Jumping: case ActionType.Lifting: case ActionType.Falling: case ActionType.Bouncing: case ActionType.Flying: case ActionType.Dropping: case ActionType.Sliding: case ActionType.Landing: string key = this.PlayerManager.NextLevel; if (this.PlayerManager.NextLevel == "CABIN_INTERIOR_A") { key = "CABIN_INTERIOR_B"; } if (this.PlayerManager.DoorVolume.HasValue && this.PlayerManager.Grounded && (!this.PlayerManager.HideFez && this.PlayerManager.CanControl) && (!this.PlayerManager.Background && !this.DotManager.PreventPoI && (this.GameState.SaveData.World.ContainsKey(key) && !this.skipPreview)) && (key != this.LevelManager.Name && this.LevelManager.Name != "CRYPT" && this.LevelManager.Name != "PYRAMID")) { if (MemoryContentManager.AssetExists("Other Textures\\map_screens\\" + key.Replace('/', '\\'))) { Texture2D texture2D = this.CMProvider.CurrentLevel.Load <Texture2D>("Other Textures/map_screens/" + key); this.DotManager.Behaviour = DotHost.BehaviourType.ThoughtBubble; this.DotManager.DestinationVignette = texture2D; this.DotManager.ComeOut(); if (this.DotManager.Owner != this) { this.DotManager.Hey(); } this.DotManager.Owner = (object)this; } else { this.UnDotize(); } } else { this.UnDotize(); } if ((double)this.step != -1.0 || this.InputManager.ExactUp != FezButtonState.Pressed && this.PlayerManager.LastAction != ActionType.OpeningDoor || !this.PlayerManager.Grounded || (!this.PlayerManager.DoorVolume.HasValue || this.PlayerManager.Background)) { break; } this.UnDotize(); this.GameState.SkipLoadScreen = this.skipFade = this.LevelManager.DestinationVolumeId.HasValue && this.PlayerManager.NextLevel == this.LevelManager.Name; bool spinThroughDoor = this.PlayerManager.SpinThroughDoor; if (spinThroughDoor) { Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint); Vector3 vector3 = FezMath.DepthMask(this.CameraManager.Viewpoint); Volume volume = this.LevelManager.Volumes[this.PlayerManager.DoorVolume.Value]; Vector3 a = (volume.From + volume.To) / 2f - (volume.To - volume.From) / 2f * b - b; if ((double)FezMath.Dot(this.PlayerManager.Position, b) < (double)FezMath.Dot(a, b)) { this.PlayerManager.Position = this.PlayerManager.Position * (Vector3.One - vector3) + a * vector3; } this.spinOrigin = this.GetDestination(); this.spinDestination = this.GetDestination() + b * 1.5f; } if (this.PlayerManager.CarriedInstance != null) { bool flag = ActorTypeExtensions.IsLight(this.PlayerManager.CarriedInstance.Trile.ActorSettings.Type); this.PlayerManager.Position = this.GetDestination(); this.PlayerManager.Action = flag ? (spinThroughDoor ? ActionType.EnterDoorSpinCarry : ActionType.CarryEnter) : (spinThroughDoor ? ActionType.EnterDoorSpinCarryHeavy : ActionType.CarryHeavyEnter); break; } else { this.WalkTo.Destination = new Func <Vector3>(this.GetDestination); this.PlayerManager.Action = ActionType.WalkingTo; this.WalkTo.NextAction = spinThroughDoor ? ActionType.EnterDoorSpin : ActionType.EnteringDoor; break; } } }
protected override void TestConditions() { if (this.PlayerManager.Action == ActionType.SuckedIn || ActionTypeExtensions.IsEnteringDoor(this.PlayerManager.Action) || (this.PlayerManager.Action == ActionType.OpeningTreasure || this.PlayerManager.Action == ActionType.FindingTreasure)) { return; } foreach (Volume volume in this.PlayerManager.CurrentVolumes) { if (volume.ActorSettings != null && volume.ActorSettings.IsBlackHole) { Vector3 vector3_1 = volume.To - volume.From; Vector3 vector3_2 = (volume.From + volume.To) / 2f - vector3_1 / 2f * FezMath.ForwardVector(this.CameraManager.Viewpoint); this.PlayerManager.Action = ActionType.SuckedIn; this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + vector3_2 * FezMath.DepthMask(this.CameraManager.Viewpoint) + -0.25f * FezMath.ForwardVector(this.CameraManager.Viewpoint); volume.ActorSettings.Sucking = true; break; } } }
private void Fly(TimeSpan elapsed) { if (!this.flyRight.HasValue) { this.flyRight = new Vector3?(Vector3.Transform(Vector3.Right, this.Group.Rotation)); } if ((!this.FlyingBack || this.Npc.ActorType != ActorType.Owl) && FezMath.AlmostEqual(FezMath.Dot(FezMath.Abs(Vector3.Transform(Vector3.Right, this.Group.Rotation)), FezMath.Abs(this.flyRight.Value)), 0.0f, 0.1f)) { NpcState npcState = this; Vector3? nullable1 = npcState.flyRight; Vector3 vector3 = Vector3.Transform(Vector3.Right, this.Group.Rotation); Vector3? nullable2 = nullable1.HasValue ? new Vector3?(nullable1.GetValueOrDefault() + vector3) : new Vector3?(); npcState.flyRight = nullable2; } this.flySpeed = Vector2.Lerp(this.flySpeed, new Vector2(4f, 3f), 0.03333334f); Vector2 vector2 = this.flySpeed * ((1f - FezMath.Frac(this.CurrentTiming.Step + 0.75f)) * new Vector2(0.4f, 0.6f) + new Vector2(0.6f, 0.4f)); this.Position += (float)elapsed.TotalSeconds * (vector2.X * this.flyRight.Value + Vector3.Up * vector2.Y * (this.FlyingBack ? -1f : 1f)); if (FezMath.IsOrthographic(this.CameraManager.Viewpoint) && this.CameraManager.ViewTransitionReached) { Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint); if (this.InBackground) { b *= -1f; } NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.Position, QueryOptions.Simple); TrileInstance trileInstance = nearestTriles.Surface ?? nearestTriles.Deep; if (trileInstance != null) { Vector3 a = trileInstance.Center + trileInstance.TransformedSize / 2f * -b; Vector3 vector3 = FezMath.DepthMask(this.CameraManager.Viewpoint); if ((double)FezMath.Dot(this.Position, b) > (double)FezMath.Dot(a, b)) { this.Position = this.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + a * vector3 - b; } } } if (this.CurrentTiming.Frame == 0 && this.lastFrame != 0) { SoundEffectExtensions.EmitAt(this.flySound, this.Position); } this.lastFrame = this.CurrentTiming.Frame; if (this.FlyingBack) { if ((double)this.Position.Y > (double)this.Npc.Position.Y) { return; } this.Position = this.Npc.Position; this.CurrentAction = NpcAction.Land; this.flySpeed = Vector2.Zero; this.UpdateAction(); this.FlyingBack = false; this.flyRight = new Vector3?(); } else { if (this.CameraManager.Frustum.Contains(new BoundingBox(this.Position - Vector3.One, this.Position + Vector3.One)) != ContainmentType.Disjoint) { return; } if (this.MayComeBack) { this.OwlInvisible = true; this.MayComeBack = false; this.CurrentAction = NpcAction.Idle; this.flySpeed = Vector2.Zero; this.flyRight = new Vector3?(); this.UpdateAction(); } else { ServiceHelper.RemoveComponent <NpcState>(this); } } }
public void ChangeLevel(string levelName) { this.GameState.SaveToCloud(false); this.GameState.DotLoading = this.DotLoadLevels.Contains(this.Name + "+" + levelName) || this.PlayerManager.Action == ActionType.LesserWarp || this.PlayerManager.Action == ActionType.GateWarp; if (this.GameState.DotLoading) { this.SoundManager.PlayNewSong((string)null, 1f); List <AmbienceTrack> ambienceTracks = this.levelData.AmbienceTracks; this.levelData.AmbienceTracks = new List <AmbienceTrack>(); this.SoundManager.PlayNewAmbience(); this.levelData.AmbienceTracks = ambienceTracks; } this.GameService.CloseScroll((string)null); if (levelName == this.Name && this.DestinationVolumeId.HasValue && this.Volumes.ContainsKey(this.DestinationVolumeId.Value)) { this.LastLevelName = this.Name; Volume volume = this.Volumes[this.DestinationVolumeId.Value]; Viewpoint view = FezMath.AsViewpoint(Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume.Orientations)); this.CameraManager.ChangeViewpoint(view, 1.5f); Vector3 position = (volume.BoundingBox.Min + volume.BoundingBox.Max) / 2f + new Vector3(1.0 / 1000.0); position.Y = volume.BoundingBox.Min.Y - 0.25f; TrileInstance trileInstance = this.NearestTrile(position, QueryOptions.None, new Viewpoint?(view)).Deep; this.GameState.SaveData.Ground = trileInstance.Center; this.GameState.SaveData.View = view; float num = this.PlayerManager.Position.Y; this.PlayerManager.Position = trileInstance.Center + (trileInstance.TransformedSize / 2f + this.PlayerManager.Size / 2f) * Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor); this.PlayerManager.WallCollision = new MultipleHits <CollisionResult>(); this.PlayerManager.Ground = new MultipleHits <TrileInstance>(); this.PlayerManager.Velocity = (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464 * 0.0166666675359011) * -Vector3.UnitY; this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager); this.PlayerManager.Velocity = (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464 * 0.0166666675359011) * -Vector3.UnitY; Vector3 originalCenter = this.CameraManager.Center; float diff = this.PlayerManager.Position.Y - num; Waiters.Interpolate(1.5, (Action <float>)(s => this.CameraManager.Center = new Vector3(originalCenter.X, originalCenter.Y + diff / 2f * Easing.EaseInOut((double)s, EasingType.Sine), originalCenter.Z))); this.OnLevelChanging(); this.OnLevelChanged(); } else { bool flag1 = this.GameState.SaveData.World.Count > 0; string str1 = this.GameState.SaveData.Level; this.LastLevelName = !flag1 ? (string)null : this.Name; this.Load(levelName); this.Rebuild(); if (!this.GameState.SaveData.World.ContainsKey(this.Name)) { this.GameState.SaveData.World.Add(this.Name, new LevelSaveData() { FirstVisit = true }); } this.GameState.SaveData.Level = this.Name; this.OnLevelChanging(); LevelSaveData thisLevel = this.GameState.SaveData.ThisLevel; foreach (TrileEmplacement emplacement in thisLevel.DestroyedTriles) { this.ClearTrile(emplacement); } foreach (int num in thisLevel.InactiveArtObjects) { if (num < 0) { this.RemoveArtObject(this.ArtObjects[-(num + 1)]); } } TrileInstance trileInstance = !flag1 || !(str1 == levelName) ? (TrileInstance)null : this.ActualInstanceAt(this.GameState.SaveData.Ground); float? nullable = new float?(); Viewpoint spawnView = !flag1 || !(str1 == levelName) ? Viewpoint.Left : this.GameState.SaveData.View; bool flag2 = false; if (this.LastLevelName != null) { Volume volume = (Volume)null; if (this.DestinationVolumeId.HasValue && this.DestinationVolumeId.Value != -1 && this.Volumes.ContainsKey(this.DestinationVolumeId.Value)) { volume = this.Volumes[this.DestinationVolumeId.Value]; flag2 = true; this.DestinationVolumeId = new int?(); } else { string str2 = this.LastLevelName.Replace('\\', '/'); string trimmedLln = str2.Substring(str2.LastIndexOf('/') + 1); foreach (Script script in Enumerable.Where <Script>(Enumerable.Where <Script>((IEnumerable <Script>) this.Scripts.Values, (Func <Script, bool>)(s => Enumerable.Any <ScriptTrigger>((IEnumerable <ScriptTrigger>)s.Triggers, (Func <ScriptTrigger, bool>)(t => t.Object.Type == "Volume")))), (Func <Script, bool>)(s => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a => { if (!(a.Object.Type == "Level") || !a.Operation.Contains("ChangeLevel")) { return(false); } if (!(a.Arguments[0] == this.LastLevelName)) { return(a.Arguments[0] == trimmedLln); } else { return(true); } }))))) { int key = Enumerable.First <ScriptTrigger>(Enumerable.Where <ScriptTrigger>((IEnumerable <ScriptTrigger>)script.Triggers, (Func <ScriptTrigger, bool>)(x => x.Object.Type == "Volume"))).Object.Identifier.Value; if (this.Volumes.ContainsKey(key)) { volume = this.Volumes[key]; flag2 = true; } } } if (flag2 && volume != null) { Vector3 vector3 = (volume.BoundingBox.Min + volume.BoundingBox.Max) / 2f + new Vector3(1.0 / 1000.0); vector3.Y = volume.BoundingBox.Min.Y - 0.25f; spawnView = FezMath.AsViewpoint(Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume.Orientations)); nullable = new float?(FezMath.Dot(vector3, FezMath.SideMask(spawnView))); float num = (float)((double)FezMath.Dot(volume.BoundingBox.Max - volume.BoundingBox.Min, FezMath.DepthMask(spawnView)) / 2.0 + 0.5); Vector3 position = vector3 + num * -FezMath.ForwardVector(spawnView); foreach (TrileEmplacement trileEmplacement in Enumerable.Union <TrileEmplacement>((IEnumerable <TrileEmplacement>)thisLevel.InactiveTriles, (IEnumerable <TrileEmplacement>)thisLevel.DestroyedTriles)) { if ((double)Vector3.DistanceSquared(trileEmplacement.AsVector, position) < 2.0) { position -= FezMath.ForwardVector(spawnView); break; } } trileInstance = this.ActualInstanceAt(position) ?? this.NearestTrile(vector3, QueryOptions.None, new Viewpoint?(spawnView)).Deep; } } InstanceFace instanceFace = new InstanceFace(); if (!flag1 || trileInstance == null) { if (this.StartingPosition != (TrileFace)null) { instanceFace.Instance = this.TrileInstanceAt(ref this.StartingPosition.Id); instanceFace.Face = this.StartingPosition.Face; } else { instanceFace.Face = FezMath.VisibleOrientation(spawnView); } if (instanceFace.Instance == null) { instanceFace.Instance = Enumerable.FirstOrDefault <TrileInstance>((IEnumerable <TrileInstance>)Enumerable.OrderBy <TrileInstance, float>(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>) this.Triles.Values, (Func <TrileInstance, bool>)(x => !FezMath.In <CollisionType>(x.GetRotatedFace(FezMath.VisibleOrientation(spawnView)), CollisionType.None, CollisionType.Immaterial, (IEqualityComparer <CollisionType>)CollisionTypeComparer.Default))), (Func <TrileInstance, float>)(x => Math.Abs(FezMath.Dot(x.Center - this.Size / 2f, FezMath.ScreenSpaceMask(spawnView)))))); } trileInstance = instanceFace.Instance; spawnView = FezMath.AsViewpoint(instanceFace.Face); } this.CameraManager.Constrained = false; this.CameraManager.PanningConstraints = new Vector2?(); if (trileInstance != null) { this.GameState.SaveData.Ground = trileInstance.Center; } this.GameState.SaveData.View = spawnView; this.GameState.SaveData.TimeOfDay = this.TimeManager.CurrentTime.TimeOfDay; if (flag2) { this.PlayerManager.CheckpointGround = (TrileInstance)null; } this.PlayerManager.RespawnAtCheckpoint(); if (nullable.HasValue) { this.PlayerManager.Position = this.PlayerManager.Position * (Vector3.One - FezMath.SideMask(spawnView)) + nullable.Value * FezMath.SideMask(spawnView); } this.PlayerManager.Action = ActionType.Idle; this.PlayerManager.WallCollision = new MultipleHits <CollisionResult>(); this.PlayerManager.Ground = new MultipleHits <TrileInstance>(); this.PlayerManager.Velocity = (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464 * 0.0166666675359011) * -Vector3.UnitY; this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager); this.PlayerManager.Velocity = (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464 * 0.0166666675359011) * -Vector3.UnitY; this.CameraManager.InterpolatedCenter = this.CameraManager.Center = this.PlayerManager.Position; this.OnLevelChanged(); this.LevelService.OnStart(); ScriptingHost.Instance.ForceUpdate(new GameTime()); if (!this.PlayerManager.SpinThroughDoor) { if (!this.CameraManager.Constrained) { this.CameraManager.Center = this.PlayerManager.Position + (float)(4.0 * (this.Descending ? -1.0 : 1.0)) / this.CameraManager.PixelsPerTrixel * Vector3.UnitY; this.CameraManager.SnapInterpolation(); } if (!this.GameState.FarawaySettings.InTransition) { this.LevelMaterializer.ForceCull(); } } if (this.Name != "HEX_REBUILD" && this.Name != "DRUM" && (this.Name != "VILLAGEVILLE_3D_END_64" && this.Name != "VILLAGEVILLE_3D_END_32")) { this.GameState.Save(); } GC.Collect(3); } }
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; } }
private Vector3 GetDestination() { Viewpoint viewpoint = this.CameraManager.Viewpoint; return(this.PlayerManager.Position * (Vector3.UnitY + FezMath.DepthMask(viewpoint)) + this.doorBottom.Center * FezMath.SideMask(viewpoint)); }
protected override bool Act(TimeSpan elapsed) { this.PlayerManager.Position = this.PlayerManager.HeldInstance.Center + (-(FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection)) + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)) * this.PlayerManager.HeldInstance.TransformedSize / 2f + FezMath.ForwardVector(this.CameraManager.Viewpoint) * -(this.PlayerManager.HeldInstance.TransformedSize / 2f + this.PlayerManager.Size.X * FezMath.DepthMask(this.CameraManager.Viewpoint) / 4f) * (this.PlayerManager.Background ? -1f : 1f); if (!this.PlayerManager.Animation.Timing.Ended) { return(true); } this.PlayerManager.Action = ActionType.GrabCornerLedge; this.PlayerManager.Background = false; return(false); }
public override void Update(GameTime gameTime) { if (this.CameraManager.Viewpoint == Viewpoint.Perspective || this.GameState.InMap || (this.GameState.Paused || this.GameState.Loading) || this.watchers.Count == 0) { return; } Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.Abs(vector3_1); Vector3 vector3_3 = FezMath.ForwardVector(this.CameraManager.Viewpoint); foreach (TrileInstance index in this.watchers.Keys) { WatchersHost.WatcherState watcherState = this.watchers[index]; Vector3 vector3_4 = index.PhysicsState.Center + vector3_2 * -5f / 16f + Vector3.UnitY * -2f / 16f - 0.5f * vector3_3; watcherState.Eyes.Groups[0].Position = vector3_4 + watcherState.EyeOffset; watcherState.Eyes.Groups[1].Position = vector3_4 + vector3_2 * 9f / 16f + watcherState.EyeOffset; watcherState.Eyes.Groups[0].Enabled = true; watcherState.Eyes.Groups[1].Enabled = true; } if (!this.CameraManager.ActionRunning || !this.CameraManager.ViewTransitionReached) { return; } Vector3 center1 = this.PlayerManager.Center; BoundingBox box = FezMath.Enclose(center1 - this.PlayerManager.Size / 2f, center1 + this.PlayerManager.Size / 2f); Vector3 vector3_5 = vector3_1 * 8f; Vector3 vector3_6 = vector3_3 * this.LevelManager.Size; Vector3 vector3_7 = Vector3.Up * 8f; this.lastCrushDirections.Clear(); bool flag1 = false; foreach (TrileInstance index in this.watchers.Keys) { WatchersHost.WatcherState watcherState1 = this.watchers[index]; Vector3 vector1 = FezMath.Sign(center1 - index.Position) * vector3_2; Vector3 vector3_4 = FezMath.Sign(center1 - index.Position) * Vector3.UnitY; BoundingBox boundingBox1 = (double)Vector3.Dot(vector1, vector3_1) > 0.0 ? FezMath.Enclose(index.Position + Vector3.UnitY * 0.05f - vector3_6, index.Position + vector3_5 + vector3_6 + new Vector3(0.9f)) : FezMath.Enclose(index.Position + Vector3.UnitY * 0.05f - vector3_6 - vector3_5, index.Position + vector3_6 + new Vector3(0.9f)); BoundingBox boundingBox2 = FezMath.Enclose(index.Position + Vector3.UnitY * 0.05f - vector3_7 - vector3_6, index.Position + vector3_7 + new Vector3(0.9f) + vector3_6); switch (watcherState1.Action) { case WatchersHost.WatcherAction.Idle: bool flag2 = boundingBox1.Intersects(box); bool flag3 = boundingBox2.Intersects(box); watcherState1.EyeOffset = !flag2 ? (!flag3 ? Vector3.Lerp(watcherState1.EyeOffset, Vector3.Zero, 0.1f) : Vector3.Lerp(watcherState1.EyeOffset, vector3_4 * 1f / 16f, 0.25f)) : Vector3.Lerp(watcherState1.EyeOffset, vector1 * 1f / 16f, 0.25f); watcherState1.CrushDirection = flag2 ? vector1 : (flag3 ? vector3_4 : Vector3.Zero); watcherState1.Eyes.Material.Opacity = 1f; WatchersHost.WatcherState watcherState2; if (this.LevelManager.NearestTrile(index.Position + new Vector3(0.5f)).Deep == index && (flag2 || flag3) && (!FezMath.In <ActionType>(this.PlayerManager.Action, ActionType.GrabCornerLedge, ActionType.Suffering, ActionType.Dying, (IEqualityComparer <ActionType>)ActionTypeComparer.Default) && (watcherState2 = this.HasPair(index)) != null)) { watcherState1.Action = WatchersHost.WatcherAction.Spotted; watcherState2.StartTime = watcherState1.StartTime = gameTime.TotalGameTime; if (!watcherState1.SkipNextSound) { SoundEffectExtensions.EmitAt(this.seeSound, index.Center); watcherState2.SkipNextSound = true; break; } else { break; } } else { break; } case WatchersHost.WatcherAction.Spotted: watcherState1.EyeOffset = Vector3.Lerp(watcherState1.EyeOffset, watcherState1.CrushDirection * 1f / 16f, 0.25f); if ((gameTime.TotalGameTime - watcherState1.StartTime).TotalSeconds > 1.0) { watcherState1.Action = WatchersHost.WatcherAction.Crushing; watcherState1.StartTime = gameTime.TotalGameTime; index.PhysicsState.Velocity = watcherState1.OriginalCenter - index.Center; this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, true, false); index.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(index); watcherState1.MoveEmitter = watcherState1.SkipNextSound ? (SoundEmitter)null : SoundEffectExtensions.EmitAt(this.moveSound, index.Center); break; } else { Vector3 vector3_8 = watcherState1.CrushDirection * RandomHelper.Unit() * 0.5f / 16f; index.PhysicsState.Sticky = true; index.PhysicsState.Velocity = watcherState1.OriginalCenter + vector3_8 - index.Center; this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, true, false); index.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(index); break; } case WatchersHost.WatcherAction.Crushing: if (index.PhysicsState.Sticky) { index.PhysicsState.Sticky = false; index.PhysicsState.Velocity = Vector3.Zero; } watcherState1.EyeOffset = watcherState1.CrushDirection * 1f / 16f; Vector3 vector3_9 = watcherState1.CrushDirection * (float)gameTime.ElapsedGameTime.TotalSeconds * 15f; Vector3 vector3_10 = Vector3.Lerp(index.PhysicsState.Velocity, vector3_9, 0.025f); index.PhysicsState.Velocity = vector3_10 * watcherState1.CrashAttenuation; if (FezMath.VisibleAxis(this.CameraManager.Viewpoint) != FezMath.AsAxis(FezMath.OrientationFromDirection(watcherState1.CrushDirection))) { this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, false, false); } Vector3 vector3_11 = vector3_10 * watcherState1.CrashAttenuation - index.PhysicsState.Velocity; if (watcherState1.MoveEmitter != null) { watcherState1.MoveEmitter.Position = index.Center; } index.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(index); this.PlayerManager.ForceOverlapsDetermination(); bool flag4 = this.PlayerManager.HeldInstance == index || this.PlayerManager.WallCollision.FarHigh.Destination == index || (this.PlayerManager.WallCollision.NearLow.Destination == index || this.PlayerManager.Ground.NearLow == index) || this.PlayerManager.Ground.FarHigh == index; if (!flag4) { foreach (PointCollision pointCollision in this.PlayerManager.CornerCollision) { if (pointCollision.Instances.Deep == index) { flag4 = true; break; } } } if (flag1 && flag4 && this.lastCrushDirections.Contains(-watcherState1.CrushDirection)) { this.PlayerManager.Position = index.Center + Vector3.One / 2f * watcherState1.CrushDirection + -FezMath.SideMask(this.CameraManager.Viewpoint) * FezMath.Abs(watcherState1.CrushDirection) * 1.5f / 16f; this.PlayerManager.Velocity = Vector3.Zero; this.PlayerManager.Action = (double)watcherState1.CrushDirection.Y == 0.0 ? ActionType.CrushHorizontal : ActionType.CrushVertical; watcherState1.CrashAttenuation = this.PlayerManager.Action == ActionType.CrushVertical ? 0.5f : 0.75f; } flag1 = flag1 | flag4; if (flag4 && this.PlayerManager.Action != ActionType.CrushHorizontal && this.PlayerManager.Action != ActionType.CrushVertical) { this.lastCrushDirections.Add(watcherState1.CrushDirection); if ((double)watcherState1.CrushDirection.Y == 0.0) { this.PlayerManager.Position += index.PhysicsState.Velocity; } } if ((double)vector3_11.LengthSquared() > 4.99999987368938E-05 || (double)Math.Abs(Vector3.Dot(index.Center - watcherState1.OriginalCenter, FezMath.Abs(watcherState1.CrushDirection))) >= 8.0) { if (watcherState1.MoveEmitter != null && !watcherState1.MoveEmitter.Dead) { watcherState1.MoveEmitter.Cue.Stop(false); } watcherState1.MoveEmitter = (SoundEmitter)null; if (!watcherState1.SkipNextSound) { SoundEffectExtensions.EmitAt(this.collideSound, index.Center); } watcherState1.Action = WatchersHost.WatcherAction.Wait; index.PhysicsState.Velocity = Vector3.Zero; watcherState1.StartTime = TimeSpan.Zero; watcherState1.CrashAttenuation = 1f; break; } else { break; } case WatchersHost.WatcherAction.Wait: watcherState1.StartTime += gameTime.ElapsedGameTime; if (watcherState1.StartTime.TotalSeconds > 1.5) { watcherState1.Action = WatchersHost.WatcherAction.Withdrawing; watcherState1.StartTime = gameTime.TotalGameTime; watcherState1.WithdrawEmitter = watcherState1.SkipNextSound ? (SoundEmitter)null : SoundEffectExtensions.EmitAt(this.withdrawSound, index.Center, true); break; } else { break; } case WatchersHost.WatcherAction.Withdrawing: watcherState1.EyeOffset = Vector3.Lerp(watcherState1.EyeOffset, -watcherState1.CrushDirection * 0.5f / 16f, 0.05f); Vector3 vector3_12 = -watcherState1.CrushDirection * (float)gameTime.ElapsedGameTime.TotalSeconds * 2f; index.PhysicsState.Velocity = Vector3.Lerp(index.PhysicsState.Velocity, vector3_12, 0.025f); if (watcherState1.WithdrawEmitter != null) { watcherState1.WithdrawEmitter.VolumeFactor = 0.0f; } bool flag5 = false; if (FezMath.DepthMask(this.CameraManager.Viewpoint) == FezMath.GetMask(FezMath.AsAxis(FezMath.OrientationFromDirection(watcherState1.CrushDirection)))) { flag5 = true; } if (watcherState1.WithdrawEmitter != null) { watcherState1.WithdrawEmitter.VolumeFactor = 1f; } Vector3 center2 = index.PhysicsState.Center; Vector3 velocity = index.PhysicsState.Velocity; this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, true, false); index.PhysicsState.Center = center2 + velocity; if (watcherState1.WithdrawEmitter != null) { watcherState1.WithdrawEmitter.Position = index.Center; } if (flag5 ? (double)Math.Abs(Vector3.Dot(index.Center - watcherState1.OriginalCenter, vector3_1 + Vector3.Up)) <= 1.0 / 32.0 : (double)Vector3.Dot(index.Center - watcherState1.OriginalCenter, watcherState1.CrushDirection) <= 1.0 / 1000.0) { if (watcherState1.WithdrawEmitter != null) { watcherState1.WithdrawEmitter.FadeOutAndDie(0.1f); watcherState1.WithdrawEmitter = (SoundEmitter)null; } watcherState1.SkipNextSound = false; watcherState1.Action = WatchersHost.WatcherAction.Cooldown; watcherState1.CrushDirection = Vector3.Zero; watcherState1.StartTime = TimeSpan.Zero; } index.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(index); break; case WatchersHost.WatcherAction.Cooldown: index.PhysicsState.Velocity = watcherState1.OriginalCenter - index.Center; this.PhysicsManager.Update((ISimplePhysicsEntity)index.PhysicsState, true, false); index.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(index); watcherState1.EyeOffset = Vector3.Lerp(watcherState1.EyeOffset, Vector3.Zero, 0.05f); watcherState1.Eyes.Material.Opacity = 0.5f; watcherState1.StartTime += gameTime.ElapsedGameTime; if (watcherState1.StartTime.TotalSeconds > 0.5) { index.PhysicsState.Velocity = Vector3.Zero; watcherState1.Action = WatchersHost.WatcherAction.Idle; break; } else { break; } } Vector3 vector3_13 = index.PhysicsState.Center + vector3_2 * -5f / 16f + Vector3.UnitY * -2f / 16f - 0.5f * vector3_3; watcherState1.Eyes.Groups[0].Position = vector3_13 + watcherState1.EyeOffset; watcherState1.Eyes.Groups[1].Position = vector3_13 + vector3_2 * 9f / 16f + watcherState1.EyeOffset; watcherState1.Eyes.Groups[2].Position = watcherState1.Eyes.Groups[0].Position; watcherState1.Eyes.Groups[3].Position = watcherState1.Eyes.Groups[1].Position; watcherState1.Eyes.Groups[0].Enabled = false; watcherState1.Eyes.Groups[1].Enabled = false; } }
protected override void TryTalk() { switch (this.PlayerManager.Action) { case ActionType.Idle: case ActionType.Walking: case ActionType.Running: case ActionType.Sliding: if (this.PlayerManager.Background || !this.SpeechManager.Hidden || this.Npc.ActorType == ActorType.Owl && (this.OwlInvisible || this.CurrentAction == NpcAction.TakeOff || this.CurrentAction == NpcAction.Fly)) { break; } if (this.Npc.CustomSpeechLine == null) { if (this.InputManager.CancelTalk != FezButtonState.Pressed) { break; } Vector3 vector3_1 = Vector3.UnitY + (FezMath.SideMask(this.CameraManager.Viewpoint) + FezMath.DepthMask(this.CameraManager.Viewpoint)) * 1.5f; BoundingBox boundingBox = new BoundingBox(this.Position - vector3_1, this.Position + vector3_1); Vector3 mask = FezMath.GetMask(FezMath.VisibleAxis(this.CameraManager.Viewpoint)); Vector3 vector3_2 = FezMath.ForwardVector(this.CameraManager.Viewpoint); Ray ray = new Ray() { Position = this.PlayerManager.Center * (Vector3.One - mask) - vector3_2 * this.LevelManager.Size, Direction = vector3_2 }; float?nullable = boundingBox.Intersects(ray); if (!nullable.HasValue || this.TestObstruction(ray.Position, nullable.Value)) { break; } } this.Talk(); break; } }
public override void Update(GameTime gameTime) { if (this.GameState.Paused || this.GameState.InMap || (!this.CameraManager.ActionRunning || !FezMath.IsOrthographic(this.CameraManager.Viewpoint)) || this.GameState.Loading) { return; } Vector3 depthMask = FezMath.DepthMask(this.CameraManager.Viewpoint); Vector3 vector3_1 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); if (this.RightPositions == 4) { this.SinceSolved += (float)gameTime.ElapsedGameTime.TotalSeconds; float num = FezMath.Saturate(this.SinceSolved); float amount = Easing.EaseIn((double)num, EasingType.Cubic); foreach (TrileInstance instance in this.Blocks) { Vector3 v = instance.Center - TetrisPuzzleHost.PuzzleCenter; if ((double)v.Length() > 0.5) { Vector3 vector3_2 = FezMath.Sign(FezMath.AlmostClamp(v, 0.1f)); Vector3 vector3_3 = (TetrisPuzzleHost.PuzzleCenter + vector3_2 * 1.75f) * FezMath.XZMask + Vector3.UnitY * instance.Center; Vector3 vector3_4 = (TetrisPuzzleHost.PuzzleCenter + vector3_2) * FezMath.XZMask + Vector3.UnitY * instance.Center; instance.PhysicsState.Center = Vector3.Lerp(vector3_3, vector3_4, amount); instance.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(instance); } } if ((double)num != 1.0) { return; } bool flag = false; foreach (TrileInstance instance in this.Blocks) { if (!flag) { ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, instance, TetrisPuzzleHost.PuzzleCenter + Vector3.UnitY)); flag = true; } else { ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, instance)); } } this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(0); foreach (Volume volume in Enumerable.Where <Volume>((IEnumerable <Volume>) this.LevelManager.Volumes.Values, (Func <Volume, bool>)(x => { if (x.ActorSettings != null && x.ActorSettings.IsPointOfInterest) { return(x.Enabled); } else { return(false); } }))) { volume.Enabled = false; this.GameState.SaveData.ThisLevel.InactiveVolumes.Add(volume.Id); } this.LevelService.ResolvePuzzle(); this.Enabled = false; } else { this.RightPositions = 0; int num1 = 0; int num2 = 0; this.Blocks.Sort((Comparison <TrileInstance>)((a, b) => b.LastTreasureSin.CompareTo(a.LastTreasureSin))); using (List <TrileInstance> .Enumerator enumerator = this.Blocks.GetEnumerator()) { while (enumerator.MoveNext()) { TrileInstance instance = enumerator.Current; if (!instance.PhysicsState.Grounded) { instance.LastTreasureSin = this.SinceStarted; } if ((double)instance.Position.Y >= 19.0 && (double)instance.Position.Y <= 20.5 && (this.PlayerManager.HeldInstance != instance && this.PlayerManager.PushedInstance != instance) && instance.PhysicsState.Grounded && instance.PhysicsState.Ground.First != this.PlayerManager.PushedInstance) { Vector3 vector3_2 = Vector3.Min(Vector3.Max(FezMath.Round((instance.Center - TetrisPuzzleHost.PuzzleCenter) / 1.75f), new Vector3(-3f, 0.0f, -3f)), new Vector3(3f, 1f, 3f)); Vector3 vector3_3 = (TetrisPuzzleHost.PuzzleCenter + vector3_2 * 1.75f - instance.Center) * FezMath.XZMask; float num3 = Math.Max(vector3_3.Length(), 0.1f); instance.PhysicsState.Velocity += 0.25f * vector3_3 / num3 * (float)gameTime.ElapsedGameTime.TotalSeconds; if ((double)num3 <= 0.100000001490116 && (double)vector3_2.Y == 0.0 && instance != this.PlayerManager.Ground.First && !Enumerable.Any <TrileInstance>((IEnumerable <TrileInstance>) this.Blocks, (Func <TrileInstance, bool>)(x => x.PhysicsState.Ground.First == instance)) && Enumerable.Any <TrileInstance>((IEnumerable <TrileInstance>) this.Blocks, (Func <TrileInstance, bool>)(b => { if (b != instance && FezMath.AlmostEqual(b.Position.Y, instance.Position.Y)) { return((double)Math.Abs(FezMath.Dot(b.Center - instance.Center, depthMask)) < 1.75); } else { return(false); } }))) { int num4 = Math.Sign(FezMath.Dot(instance.Center - TetrisPuzzleHost.PuzzleCenter, depthMask)); if (num4 == 0) { num4 = 1; } for (int index = -2; index <= 2; ++index) { int num5 = TetrisPuzzleHost.SpiralTraversal[index + 2] * num4; Vector3 tetativePosition = vector3_1 * instance.PhysicsState.Center + TetrisPuzzleHost.PuzzleCenter * depthMask + depthMask * (float)num5 * 1.75f; if (Enumerable.All <TrileInstance>((IEnumerable <TrileInstance>) this.Blocks, (Func <TrileInstance, bool>)(b => { if (b != instance && FezMath.AlmostEqual(b.Position.Y, instance.Position.Y)) { return((double)Math.Abs(FezMath.Dot(b.Center - tetativePosition, depthMask)) >= 1.57499992847443); } else { return(true); } }))) { instance.PhysicsState.Center = tetativePosition; break; } } } if (this.RightPositions < 4 && (double)num3 <= 0.100000001490116 && instance.PhysicsState.Grounded) { if ((double)instance.Position.Y == 20.0) { if ((double)vector3_2.X == (double)TetrisPuzzleHost.TwoHigh.X && (double)vector3_2.Z == (double)TetrisPuzzleHost.TwoHigh.Z) { this.RightPositions += 2; } } else { if ((double)vector3_2.X == (double)TetrisPuzzleHost.Interchangeable1_1.X && (double)vector3_2.Z == (double)TetrisPuzzleHost.Interchangeable1_1.Z || (double)vector3_2.X == (double)TetrisPuzzleHost.Interchangeable1_2.X && (double)vector3_2.Z == (double)TetrisPuzzleHost.Interchangeable1_2.Z) { ++num1; } if ((double)vector3_2.X == (double)TetrisPuzzleHost.Interchangeable2_1.X && (double)vector3_2.Z == (double)TetrisPuzzleHost.Interchangeable2_1.Z || (double)vector3_2.X == (double)TetrisPuzzleHost.Interchangeable2_2.X && (double)vector3_2.Z == (double)TetrisPuzzleHost.Interchangeable2_2.Z) { ++num2; } } } } } } if (this.RightPositions >= 4 || num1 != 2 && num2 != 2) { return; } this.RightPositions += 2; } }
protected override bool Act(TimeSpan elapsed) { float timeFactor = this.movementHelper.Running ? 1.25f : 1f; this.PlayerManager.Animation.Timing.Update(elapsed, timeFactor); this.PlayerManager.LookingDirection = this.originalLookingDirection; float num1 = FezMath.Dot(this.Destination() - this.PlayerManager.Position, FezMath.RightVector(this.CameraManager.Viewpoint)); int num2 = (double)num1 < 0.0 ? -1 : 1; this.PlayerManager.LookingDirection = (double)num1 < 0.0 ? HorizontalDirection.Left : HorizontalDirection.Right; if (FezMath.AlmostEqual((double)num1, 0.0, 0.01)) { this.ChangeAction(); } else { this.movementHelper.Update((float)elapsed.TotalSeconds, (float)num2 * 0.75f); this.PlayerManager.Velocity = this.PlayerManager.Velocity * (Vector3.UnitY + FezMath.DepthMask(this.CameraManager.Viewpoint)) + FezMath.RightVector(this.CameraManager.Viewpoint) * Math.Min(Math.Abs(FezMath.Dot(this.PlayerManager.Velocity, FezMath.SideMask(this.CameraManager.Viewpoint))), Math.Abs(num1)) * (float)num2; } return(false); }
private void TestInput() { CodeInput codeInput = CodeInput.None; if (this.InputManager.Jump == FezButtonState.Pressed) { codeInput = CodeInput.Jump; } else if (this.InputManager.RotateRight == FezButtonState.Pressed) { codeInput = CodeInput.SpinRight; } else if (this.InputManager.RotateLeft == FezButtonState.Pressed) { codeInput = CodeInput.SpinLeft; } else if (this.InputManager.Left == FezButtonState.Pressed) { codeInput = CodeInput.Left; } else if (this.InputManager.Right == FezButtonState.Pressed) { codeInput = CodeInput.Right; } else if (this.InputManager.Up == FezButtonState.Pressed) { codeInput = CodeInput.Up; } else if (this.InputManager.Down == FezButtonState.Pressed) { codeInput = CodeInput.Down; } if (codeInput == CodeInput.None) { return; } this.Input.Add(codeInput); if (this.Input.Count > 16) { this.Input.RemoveAt(0); } if (!this.isAchievementCode && !this.GameState.SaveData.AchievementCheatCodeDone && (!this.GameState.SaveData.FezHidden && PatternTester.Test((IList <CodeInput>) this.Input, GameWideCodes.AchievementCode)) && this.LevelManager.Name != "ELDERS") { this.Input.Clear(); this.isAchievementCode = true; this.LevelService.ResolvePuzzleSoundOnly(); Waiters.Wait((Func <bool>)(() => { if (this.CameraManager.ViewTransitionReached && this.PlayerManager.Grounded) { return(!this.PlayerManager.Background); } else { return(false); } }), (Action)(() => { Vector3 local_0 = this.PlayerManager.Center + new Vector3(0.0f, 2f, 0.0f); Trile local_1 = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube)); if (local_1 == null) { return; } Vector3 local_2 = local_0 - Vector3.One / 2f; NearestTriles local_3 = this.LevelManager.NearestTrile(local_0); TrileInstance local_4 = local_3.Surface ?? local_3.Deep; if (local_4 != null) { local_2 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) * local_2 + local_4.Center * FezMath.DepthMask(this.CameraManager.Viewpoint) - FezMath.ForwardVector(this.CameraManager.Viewpoint) * 2f; } ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(this.Game, this.waitingForTrile = new TrileInstance(Vector3.Clamp(local_2, Vector3.Zero, this.LevelManager.Size - Vector3.One), local_1.Id))); this.GomezService.CollectedAnti += new Action(this.GotTrile); })); } if (!this.isMapQr && !this.GameState.SaveData.MapCheatCodeDone && (this.GameState.SaveData.Maps.Contains("MAP_MYSTERY") && this.LevelManager.Name != "WATERTOWER_SECRET") && PatternTester.Test((IList <CodeInput>) this.Input, GameWideCodes.MapCode)) { this.Input.Clear(); this.GameState.SaveData.AnyCodeDeciphered = true; this.isMapQr = true; if (this.GameState.SaveData.World.ContainsKey("WATERTOWER_SECRET")) { this.GameState.SaveData.World["WATERTOWER_SECRET"].FilledConditions.SecretCount = 1; } this.LevelService.ResolvePuzzleSoundOnly(); Waiters.Wait((Func <bool>)(() => { if (this.CameraManager.ViewTransitionReached && this.PlayerManager.Grounded) { return(!this.PlayerManager.Background); } else { return(false); } }), (Action)(() => { Vector3 local_0 = this.PlayerManager.Center + new Vector3(0.0f, 2f, 0.0f); Trile local_1 = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube)); if (local_1 == null) { return; } Vector3 local_2 = local_0 - Vector3.One / 2f; NearestTriles local_3 = this.LevelManager.NearestTrile(local_0); TrileInstance local_4 = local_3.Surface ?? local_3.Deep; if (local_4 != null) { local_2 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) * local_2 + local_4.Center * FezMath.DepthMask(this.CameraManager.Viewpoint) - FezMath.ForwardVector(this.CameraManager.Viewpoint) * 2f; } ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(this.Game, this.waitingForTrile = new TrileInstance(Vector3.Clamp(local_2, Vector3.Zero, this.LevelManager.Size - Vector3.One), local_1.Id))); this.GomezService.CollectedAnti += new Action(this.GotTrile); })); } if (this.GameState.SaveData.HasNewGamePlus && PatternTester.Test((IList <CodeInput>) this.Input, GameWideCodes.JetpackCode)) { this.Input.Clear(); this.GameState.JetpackMode = true; } this.SinceInput = TimeSpan.Zero; }
protected override void TryFlee() { if (this.PlayerManager.Action == ActionType.IdleSleep) { return; } float num1 = FezMath.Dot(FezMath.Abs(this.Position - this.PlayerManager.Position), FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint)); this.Npc.WalkSpeed = this.originalSpeed * (float)(1.0 + (1.0 - (double)FezMath.Saturate(num1 / 3f))); switch (this.CurrentAction) { case NpcAction.Turn: break; case NpcAction.Burrow: break; case NpcAction.ComeOut: break; case NpcAction.TakeOff: break; case NpcAction.Fly: break; default: Vector3 vector3 = Vector3.UnitY + FezMath.SideMask(this.CameraManager.Viewpoint) * 3f + FezMath.DepthMask(this.CameraManager.Viewpoint) * float.MaxValue; if (new BoundingBox(this.Position - vector3, this.Position + vector3).Contains(this.PlayerManager.Position) == ContainmentType.Disjoint) { if (this.CurrentAction != NpcAction.Hide) { break; } this.CurrentAction = NpcAction.ComeOut; this.UpdateAction(); break; } else { float num2 = FezMath.Dot(this.PlayerManager.Position - this.Position, FezMath.RightVector(this.CameraManager.Viewpoint)) * (float)Math.Sign(FezMath.Dot(this.Npc.DestinationOffset, FezMath.RightVector(this.CameraManager.Viewpoint))); NpcAction npcAction = this.CurrentAction; if ((double)num1 < 1.0) { this.Hide(); } else if (this.CurrentAction == NpcAction.Hide) { this.CurrentAction = NpcAction.ComeOut; SoundEffectExtensions.EmitAt(this.comeOutSound, this.Position); this.UpdateAction(); break; } else { HorizontalDirection horizontalDirection = FezMath.DirectionFromMovement(-num2); if (this.LookingDirection != horizontalDirection) { if (this.CanTurn) { this.CurrentAction = NpcAction.Turn; } else { this.LookingDirection = horizontalDirection; this.CurrentAction = this.CanWalk ? NpcAction.Walk : NpcAction.Idle; } } else { this.CurrentAction = this.CanWalk ? NpcAction.Walk : NpcAction.Idle; } } if (npcAction == this.CurrentAction) { break; } this.UpdateAction(); break; } } }
protected override void Begin() { this.PlayerManager.Velocity = Vector3.Zero; this.PlayerManager.Position = this.PlayerManager.HeldInstance.Center + (-(FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection)) + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)) * this.PlayerManager.HeldInstance.TransformedSize / 2f + FezMath.ForwardVector(this.CameraManager.Viewpoint) * -(this.PlayerManager.HeldInstance.TransformedSize / 2f + this.PlayerManager.Size.X * FezMath.DepthMask(this.CameraManager.Viewpoint) / 4f); this.PlayerManager.ForceOverlapsDetermination(); this.PhysicsManager.HugWalls((IPhysicsEntity)this.PlayerManager, false, false, true); SoundEffectExtensions.EmitAt(this.transitionSound, this.PlayerManager.Position); }
private void SetupInstances() { float num1 = this.settings.ExplodingInstance.Trile.ActorSettings.Type == ActorType.Vase ? 0.05f : 0.15f; int maxValue = 16 - this.settings.MinimumSize; Vector3 b1 = FezMath.SideMask(this.CameraManager.Viewpoint); Vector3 b2 = FezMath.DepthMask(this.CameraManager.Viewpoint); bool flag1 = (double)b1.X != 0.0; bool flag2 = this.CameraManager.Viewpoint == Viewpoint.Front || this.CameraManager.Viewpoint == Viewpoint.Left; Random random = RandomHelper.Random; Vector3 a1 = this.settings.EnergySource.Value; Vector3 vector3_1 = new Vector3(FezMath.Dot(a1, b1), a1.Y, 0.0f); Vector3 vector3_2 = FezMath.Dot(this.settings.ExplodingInstance.Center, b2) * b2; Vector3 vector3_3 = a1 - FezMath.Dot(a1, b2) * b2; Vector2 vector2_1 = new Vector2((float)this.settings.ExplodingInstance.Trile.TrileSet.TextureAtlas.Width, (float)this.settings.ExplodingInstance.Trile.TrileSet.TextureAtlas.Height); Vector2 vector2_2 = new Vector2(128f / vector2_1.X, 16f / vector2_1.Y); Vector2 atlasOffset = this.settings.ExplodingInstance.Trile.AtlasOffset; List <SpaceDivider.DividedCell> list = (List <SpaceDivider.DividedCell>)null; if (this.settings.Crumble) { list = SpaceDivider.Split(this.settings.ParticleCount); } for (int instanceIndex = 0; instanceIndex < this.settings.ParticleCount; ++instanceIndex) { TrixelParticleSystem.Particle particle = new TrixelParticleSystem.Particle(this, instanceIndex) { Elasticity = num1 }; Vector3 vector3_4; Vector3 vector1; if (this.settings.Crumble) { SpaceDivider.DividedCell dividedCell = list[instanceIndex]; vector3_4 = ((float)(dividedCell.Left - 8) * b1 + (float)(dividedCell.Bottom - 8) * Vector3.UnitY + (float)(dividedCell.Left - 8) * b2) / 16f; vector1 = ((float)dividedCell.Width * (b1 + b2) + (float)dividedCell.Height * Vector3.UnitY) / 16f; } else { vector3_4 = new Vector3((float)random.Next(0, maxValue), (float)random.Next(0, maxValue), (float)random.Next(0, maxValue)); do { vector1 = new Vector3((float)random.Next(this.settings.MinimumSize, Math.Min(17 - (int)vector3_4.X, this.settings.MaximumSize)), (float)random.Next(this.settings.MinimumSize, Math.Min(17 - (int)vector3_4.Y, this.settings.MaximumSize)), (float)random.Next(this.settings.MinimumSize, Math.Min(17 - (int)vector3_4.Z, this.settings.MaximumSize))); }while ((double)Math.Abs(vector1.X - vector1.Y) > ((double)vector1.X + (double)vector1.Y) / 2.0 || (double)Math.Abs(vector1.Z - vector1.Y) > ((double)vector1.Z + (double)vector1.Y) / 2.0); vector3_4 = (vector3_4 - new Vector3(8f)) / 16f; vector1 /= 16f; } particle.Size = vector1; float num2 = flag1 ? vector1.X : vector1.Z; particle.TextureMatrix = new Vector4(num2 * vector2_2.X, vector1.Y * vector2_2.Y, (float)(((flag2 ? 1.0 : -1.0) * (flag1 ? (double)vector3_4.X : (double)vector3_4.Z) + (flag2 ? 0.0 : -(double)num2) + 0.5 + 1.0 / 16.0) / 8.0) * vector2_2.X + atlasOffset.X, (float)(-((double)vector3_4.Y + (double)vector1.Y) + 0.5 + 1.0 / 16.0) * vector2_2.Y + atlasOffset.Y); float num3 = this.settings.Darken ? RandomHelper.Between(0.3, 1.0) : 1f; particle.Color = new Vector3(num3, num3, num3); Vector3 a2 = this.settings.ExplodingInstance.Center + vector3_4 + vector1 / 2f; Vector3 vector3_5 = new Vector3(FezMath.Dot(a2, b1), a2.Y, 0.0f); Vector3 vector3_6 = a2 - vector3_2 - vector3_3; if (vector3_6 != Vector3.Zero) { vector3_6.Normalize(); } if (this.settings.Crumble) { vector3_6 = Vector3.Normalize(new Vector3(RandomHelper.Centered(1.0), RandomHelper.Centered(1.0), RandomHelper.Centered(1.0))); } float num4 = Math.Min(1f, 1.5f - Vector3.Dot(vector1, Vector3.One)); float num5 = (float)Math.Pow(1.0 / (1.0 + (double)(vector3_5 - vector3_1).Length()), 1.5); particle.Center = a2; particle.Velocity = vector3_6 * this.settings.Energy * num4 * 0.2f * num5 + this.settings.BaseVelocity; if (this.settings.Incandesce) { particle.Incandescence = 2f; } particle.Update(); this.particles.Add(particle); if (this.settings.Crumble) { particle.Delay = FezMath.Saturate(Easing.EaseOut((double)vector3_4.Y + 0.5, EasingType.Cubic) + RandomHelper.Centered(0.100000001490116)); } } }
protected override bool Act(TimeSpan elapsed) { float num1 = FezMath.Saturate(Math.Abs(3f / (float)this.PlayerManager.Animation.Timing.EndFrame - this.PlayerManager.Animation.Timing.Step)) * 2f; int frame = this.PlayerManager.Animation.Timing.Frame; if (this.lastFrame != frame) { if (frame == 2) { SoundEffectExtensions.EmitAt(this.shimmySound, this.PlayerManager.Position); } this.lastFrame = frame; } TrileInstance heldInstance = this.PlayerManager.HeldInstance; this.PlayerManager.HeldInstance = this.PlayerManager.AxisCollision[VerticalDirection.Down].Deep; bool flag1 = this.PlayerManager.HeldInstance == null; Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint) * (this.PlayerManager.Background ? -1f : 1f); bool flag2 = this.PlayerManager.HeldInstance != null && this.PlayerManager.HeldInstance.GetRotatedFace(FezMath.VisibleOrientation(this.CameraManager.Viewpoint)) == CollisionType.None; if (flag1 || flag2 && (double)FezMath.Dot(this.PlayerManager.HeldInstance.Position, b) > (double)FezMath.Dot(heldInstance.Position, b)) { this.PlayerManager.Action = ActionTypeExtensions.FacesBack(this.PlayerManager.Action) ? ActionType.ToCornerBack : ActionType.ToCornerFront; this.PlayerManager.HeldInstance = heldInstance; this.PlayerManager.LookingDirection = FezMath.GetOpposite(this.PlayerManager.LookingDirection); return(false); } else if (flag2) { this.PlayerManager.Action = ActionType.Dropping; this.PlayerManager.HeldInstance = (TrileInstance)null; return(false); } else { float num2 = (float)((double)this.InputManager.Movement.X * 4.69999980926514 * 0.150000005960464) * (float)elapsed.TotalSeconds; if (this.PlayerManager.Action != ActionType.ShimmyBack && this.PlayerManager.Action != ActionType.ShimmyFront) { num2 *= 0.6f; } this.PlayerManager.Velocity = num2 * FezMath.RightVector(this.CameraManager.Viewpoint) * (1f + num1); if ((double)this.InputManager.Movement.X == 0.0) { this.PlayerManager.Action = ActionTypeExtensions.FacesBack(this.PlayerManager.Action) ? ActionType.GrabLedgeBack : ActionType.GrabLedgeFront; } else { this.PlayerManager.GroundedVelocity = new Vector3?(this.PlayerManager.Velocity); } if (this.InputManager.RotateLeft == FezButtonState.Pressed || this.InputManager.RotateRight == FezButtonState.Pressed) { this.PlayerManager.Action = ActionTypeExtensions.FacesBack(this.PlayerManager.Action) ? ActionType.GrabLedgeBack : ActionType.GrabLedgeFront; } if (this.PlayerManager.Action == ActionType.ShimmyBack || this.PlayerManager.Action == ActionType.ShimmyFront) { this.PlayerManager.Animation.Timing.Update(elapsed, Math.Abs(this.InputManager.Movement.X)); if (this.PlayerManager.HeldInstance.PhysicsState != null) { this.PlayerManager.Position += this.PlayerManager.HeldInstance.PhysicsState.Velocity; } } Vector3 vector3 = FezMath.DepthMask(this.CameraManager.Viewpoint); this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + this.PlayerManager.HeldInstance.Center * vector3 + b * -(this.PlayerManager.HeldInstance.TransformedSize / 2f + this.PlayerManager.Size.X * vector3 / 4f); this.PhysicsManager.HugWalls((IPhysicsEntity)this.PlayerManager, false, false, true); return(false); } }
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); }
protected override bool Act(TimeSpan elapsed) { this.sinceOpened += elapsed; float num1 = FezMath.Saturate((float)this.sinceOpened.Ticks / (float)OpenDoor.OpeningDuration.Ticks); if (this.doorBottom.InstanceId != -1) { float num2 = Easing.EaseInOut((double)num1, EasingType.Sine); float angle = num2 * 1.570796f; this.doorBottom.Phi = this.doorTop.Phi = this.initialPhi + angle; if (this.aoInstance != null) { this.aoInstance.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, angle) * this.aoInitialRotation; } Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.ForwardVector(this.CameraManager.Viewpoint); Vector3 vector3_3 = FezMath.DepthMask(this.CameraManager.Viewpoint); Vector3 vector3_4 = vector3_2 * 1.125f * num2 + vector3_1 * (float)(Math.Sin((double)angle * 2.0) * ((Math.Sqrt(2.0) - 1.0) / 2.0) - 3.0 / 16.0 * (double)num2); this.doorBottom.Position = new Vector3(this.initialPosition.X, this.doorBottom.Position.Y, this.initialPosition.Z) + vector3_4; this.LevelManager.UpdateInstance(this.doorBottom); this.doorTop.Position = new Vector3(this.initialPosition.X, this.doorTop.Position.Y, this.initialPosition.Z) + vector3_4; this.LevelManager.UpdateInstance(this.doorTop); if (this.holeBottom != null) { this.holeBottom.Position = new Vector3(this.initialPosition.X, this.doorBottom.Position.Y, this.initialPosition.Z) + vector3_4 * vector3_3 + vector3_2; this.LevelManager.UpdateInstance(this.holeBottom); } if (this.holeTop != null) { this.holeTop.Position = new Vector3(this.initialPosition.X, this.doorTop.Position.Y, this.initialPosition.Z) + vector3_4 * vector3_3 + vector3_2; this.LevelManager.UpdateInstance(this.holeTop); } if (this.aoInstance != null) { this.aoInstance.Position = this.initialAoPosition + vector3_2 * 1.125f * num2 + vector3_1 * (float)(Math.Sin((double)angle * 2.0) * ((Math.Sqrt(2.0) - 1.0) / 2.0) + 3.0 / 16.0 * (double)num2); } if ((double)num1 == 1.0) { this.LevelManager.ClearTrile(this.doorBottom); this.LevelManager.ClearTrile(this.doorTop); if (this.holeBottom != null) { this.holeBottom.Position = new Vector3(this.initialPosition.X, this.doorBottom.Position.Y, this.initialPosition.Z) + vector3_2; this.LevelManager.UpdateInstance(this.holeBottom); } if (this.holeTop != null) { this.holeTop.Position = new Vector3(this.initialPosition.X, this.doorTop.Position.Y, this.initialPosition.Z) + vector3_2; this.LevelManager.UpdateInstance(this.holeTop); } if (this.tempBottom != null) { this.LevelManager.RestoreTrile(this.tempBottom); } if (this.tempTop != null) { this.LevelManager.RestoreTrile(this.tempTop); } this.LevelMaterializer.CullInstances(); } } if (this.PlayerManager.Animation.Timing.Ended) { if (!this.isUnlocked) { this.PlayerManager.Action = ActionType.Walking; } this.PlayerManager.Action = ActionType.Idle; } int frame = this.PlayerManager.Animation.Timing.Frame; if (this.lastFrame != frame) { if (frame == 7) { if (this.doorBottom.Trile.ActorSettings.Type == ActorType.Door) { SoundEffectExtensions.EmitAt(this.unlockSound, this.PlayerManager.Position); } else { SoundEffectExtensions.EmitAt(this.openSound, this.PlayerManager.Position); } } this.lastFrame = frame; } return(true); }
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); } } } }