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.Walking: case ActionType.Running: case ActionType.Sliding: if (!this.PlayerManager.Grounded || (double)this.InputManager.Movement.X == 0.0 || this.PlayerManager.LookingDirection == HorizontalDirection.None) { break; } TrileInstance trileInstance = this.PlayerManager.WallCollision.NearLow.Destination; if (trileInstance == null || !ActorTypeExtensions.IsPickable(trileInstance.Trile.ActorSettings.Type) || (trileInstance.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.AllSides || trileInstance.Hidden) || (trileInstance.PhysicsState == null || !trileInstance.PhysicsState.Grounded)) { break; } NearestTriles nearestTriles = this.LevelManager.NearestTrile(trileInstance.Position); if (nearestTriles.Surface != null && nearestTriles.Surface.Trile.ForceHugging || (double)Math.Abs(trileInstance.Center.Y - this.PlayerManager.Position.Y) > 0.5 || trileInstance.Trile.ActorSettings.Type == ActorType.Couch && FezMath.OrientationFromPhi(FezMath.ToPhi(trileInstance.Trile.ActorSettings.Face) + trileInstance.Phi) != FezMath.VisibleOrientation(FezMath.GetRotatedView(this.CameraManager.Viewpoint, this.PlayerManager.LookingDirection == HorizontalDirection.Right ? -1 : 1))) { break; } this.PlayerManager.Action = ActionType.Grabbing; this.PlayerManager.PushedInstance = trileInstance; break; } }
public void SpawnTrileAt(int id, string actorTypeName) { BoundingBox boundingBox = this.LevelManager.Volumes[id].BoundingBox; Vector3 position1 = (boundingBox.Min + boundingBox.Max) / 2f; Trile trile = Enumerable.FirstOrDefault <Trile>(this.LevelManager.ActorTriles((ActorType)Enum.Parse(typeof(ActorType), actorTypeName, true))); if (trile == null) { return; } Vector3 vector3 = position1 - Vector3.One / 2f; NearestTriles nearestTriles = this.LevelManager.NearestTrile(position1); TrileInstance trileInstance = nearestTriles.Surface ?? nearestTriles.Deep; if (trileInstance != null) { vector3 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) * vector3 + trileInstance.Center * FezMath.DepthMask(this.CameraManager.Viewpoint) - FezMath.ForwardVector(this.CameraManager.Viewpoint) * 2f; } Vector3 position2 = Vector3.Clamp(vector3, Vector3.Zero, this.LevelManager.Size - Vector3.One); ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(ServiceHelper.Game, new TrileInstance(position2, trile.Id) { OriginalEmplacement = new TrileEmplacement(position2) })); }
private TrileInstance IsOnLadder(out ClimbingApproach approach) { Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint); Vector3 vector3 = FezMath.RightVector(this.CameraManager.Viewpoint); float num1 = float.MaxValue; bool flag1 = false; TrileInstance trileInstance1 = (TrileInstance)null; bool flag2 = true; if (this.currentApproach == ClimbingApproach.None) { NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.PlayerManager.Center, this.PlayerManager.Background ? QueryOptions.Background : QueryOptions.None); flag2 = nearestTriles.Surface != null && nearestTriles.Surface.Trile.ActorSettings.Type == ActorType.Ladder; } foreach (NearestTriles nearestTriles in this.PlayerManager.AxisCollision.Values) { if (nearestTriles.Surface != null && this.TestLadderCollision(nearestTriles.Surface, true)) { TrileInstance trileInstance2 = nearestTriles.Surface; float num2 = FezMath.Dot(trileInstance2.Position, b); if (flag2 && (double)num2 < (double)num1) { num1 = num2; trileInstance1 = trileInstance2; } } } if (trileInstance1 == null) { foreach (NearestTriles nearestTriles in this.PlayerManager.AxisCollision.Values) { if (nearestTriles.Surface != null && this.TestLadderCollision(nearestTriles.Surface, false)) { TrileInstance trileInstance2 = nearestTriles.Surface; float num2 = FezMath.Dot(trileInstance2.Position, b); if (flag2 && (double)num2 < (double)num1) { flag1 = true; num1 = num2; trileInstance1 = trileInstance2; } } } } if (trileInstance1 != null) { float num2 = FezMath.Dot(FezMath.AsVector(FezMath.OrientationFromPhi(FezMath.WrapAngle(FezMath.ToPhi(trileInstance1.Trile.ActorSettings.Face) + trileInstance1.Phi))), flag1 ? vector3 : b); approach = !flag1 ? ((double)num2 > 0.0 ? ClimbingApproach.Front : ClimbingApproach.Back) : ((double)num2 > 0.0 ? ClimbingApproach.Left : ClimbingApproach.Right); } else { approach = ClimbingApproach.None; } return(trileInstance1); }
protected override void Begin() { base.Begin(); if (ActionTypeExtensions.IsClimbingLadder(this.PlayerManager.LastAction)) { SoundEffectExtensions.EmitAt(this.dropLadderSound, this.PlayerManager.Position); } else if (ActionTypeExtensions.IsClimbingVine(this.PlayerManager.LastAction)) { SoundEffectExtensions.EmitAt(this.dropVineSound, this.PlayerManager.Position); } else if (ActionTypeExtensions.IsOnLedge(this.PlayerManager.LastAction)) { SoundEffectExtensions.EmitAt(this.dropLedgeSound, this.PlayerManager.Position); this.GomezService.OnDropLedge(); Vector3 position = this.PlayerManager.Position; if (this.PlayerManager.LastAction == ActionType.GrabCornerLedge || this.PlayerManager.LastAction == ActionType.LowerToCornerLedge) { this.PlayerManager.Position += FezMath.RightVector(this.CameraManager.Viewpoint) * (float)-FezMath.Sign(this.PlayerManager.LookingDirection) * 0.5f; } this.PhysicsManager.DetermineInBackground((IPhysicsEntity)this.PlayerManager, true, false, false); this.PlayerManager.Position = position; } if (this.PlayerManager.Grounded) { this.PlayerManager.Position -= Vector3.UnitY * 0.01f; IPlayerManager playerManager = this.PlayerManager; Vector3 vector3 = playerManager.Velocity - 0.0075f * Vector3.UnitY; playerManager.Velocity = vector3; } else { this.PlayerManager.Velocity = Vector3.Zero; } if (this.PlayerManager.LastAction != ActionType.GrabCornerLedge) { return; } this.PlayerManager.Position += FezMath.RightVector(this.CameraManager.Viewpoint) * (float)-FezMath.Sign(this.PlayerManager.LookingDirection) * (15.0 / 32.0); this.PlayerManager.ForceOverlapsDetermination(); NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.PlayerManager.Position - 1.0 / 500.0 * Vector3.UnitY); if (nearestTriles.Surface == null || nearestTriles.Surface.Trile.ActorSettings.Type != ActorType.Vine) { return; } this.PlayerManager.Action = ActionType.SideClimbingVine; }
protected override bool Act(TimeSpan elapsed) { NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.PlayerManager.HeldInstance.Center); CollisionType collisionType = CollisionType.None; bool flag = false; if (nearestTriles.Deep != null) { collisionType = nearestTriles.Deep.GetRotatedFace(FezMath.VisibleOrientation(this.CameraManager.Viewpoint)); flag = flag | collisionType == CollisionType.AllSides; } if (flag && (this.InputManager.RotateLeft == FezButtonState.Pressed || this.InputManager.RotateRight == FezButtonState.Pressed)) { this.InputManager.PressedToDown(); } if (nearestTriles.Deep == null) { flag = true; } if (nearestTriles.Deep != null) { flag = flag | collisionType == CollisionType.TopNoStraightLedge; } FezButtonState fezButtonState = this.PlayerManager.Animation.Timing.Ended ? FezButtonState.Down : FezButtonState.Pressed; if (this.CameraManager.ActionRunning && !flag && (this.PlayerManager.LookingDirection == HorizontalDirection.Right && this.InputManager.Right == fezButtonState || this.PlayerManager.LookingDirection == HorizontalDirection.Left && this.InputManager.Left == fezButtonState)) { bool background1 = this.PlayerManager.Background; Vector3 position = this.PlayerManager.Position; this.PlayerManager.Position += FezMath.RightVector(this.CameraManager.Viewpoint) * (float)-FezMath.Sign(this.PlayerManager.LookingDirection) * 0.5f; this.PhysicsManager.DetermineInBackground((IPhysicsEntity)this.PlayerManager, true, false, false); bool background2 = this.PlayerManager.Background; this.PlayerManager.Background = background1; this.PlayerManager.Position = position; if (!background2) { this.PlayerManager.Action = ActionType.FromCornerBack; return(false); } } this.huggedCorner = (-(!this.rotatedFrom.HasValue ? FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection) : FezMath.RightVector(this.rotatedFrom.Value) * (float)FezMath.Sign(this.PlayerManager.LookingDirection)) + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)) * this.PlayerManager.HeldInstance.TransformedSize / 2f; this.PlayerManager.Position = this.PlayerManager.HeldInstance.Center + this.huggedCorner; return(true); }
protected void UpdateRotation() { Quaternion rotation = this.CameraManager.Rotation; if (this.oldRotation == rotation && this.oldDirection == this.LookingDirection) { return; } this.oldRotation = rotation; this.oldDirection = this.LookingDirection; int num = -Math.Sign(FezMath.Dot(this.CameraManager.InverseView.Right, FezMath.Sign(this.Npc.DestinationOffset))); if (this.LookingDirection == HorizontalDirection.Left) { num *= -1; } if (num != 0) { rotation *= FezMath.QuaternionFromPhi((float)(3.14159274101257 * ((double)num / 2.0 + 0.5))); } this.Group.Rotation = rotation; if (!FezMath.IsOrthographic(this.CameraManager.Viewpoint)) { return; } this.InBackground = false; Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint); NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.Position, QueryOptions.Simple); TrileInstance trileInstance = nearestTriles.Surface ?? nearestTriles.Deep; if (trileInstance == null) { return; } Vector3 a = trileInstance.Center + trileInstance.TransformedSize / 2f * -b; this.InBackground = (double)FezMath.Dot(this.Position, b) > (double)FezMath.Dot(a, b); }
public CollisionResult CollidePoint(Vector3 position, Vector3 impulse, QueryOptions options, float elasticity, Viewpoint viewpoint) { CollisionResult collisionResult = new CollisionResult(); Vector3 vector3 = position + impulse; TrileInstance instance = (TrileInstance)null; if ((options & QueryOptions.Background) != QueryOptions.None) { instance = this.LevelManager.ActualInstanceAt(vector3); } if (instance == null) { NearestTriles nearestTriles = this.LevelManager.NearestTrile(vector3, options, new Viewpoint?(viewpoint)); instance = nearestTriles.Deep ?? nearestTriles.Surface; } bool invertedGravity = (double)this.GravityFactor < 0.0; if (instance != null) { collisionResult = CollisionManager.CollideWithInstance(position, vector3, impulse, instance, options, elasticity, viewpoint, invertedGravity); } if (collisionResult.Collided && (invertedGravity ? ((double)impulse.Y > 0.0 ? 1 : 0) : ((double)impulse.Y < 0.0 ? 1 : 0)) != 0) { if ((double)vector3.X % 0.25 == 0.0) { vector3.X += 1.0 / 1000.0; } if ((double)vector3.Z % 0.25 == 0.0) { vector3.Z += 1.0 / 1000.0; } TrileInstance trileInstance = this.LevelManager.ActualInstanceAt(vector3); CollisionType rotatedFace; collisionResult.ShouldBeClamped = trileInstance == null || !trileInstance.Enabled || (rotatedFace = trileInstance.GetRotatedFace(this.CameraManager.VisibleOrientation)) == CollisionType.None || rotatedFace == CollisionType.Immaterial; } return(collisionResult); }
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; }
private void TestVolumes(bool force) { if (!force && this.GameState.Loading) { return; } if (!force && this.deferredScripts) { foreach (Volume volume in this.PlayerManager.CurrentVolumes) { this.VolumeService.OnEnter(volume.Id); } this.HeightCheck(); this.deferredScripts = false; } else { SoundService.ImmediateEffect = false; } if (force) { this.deferredScripts = true; } Vector3 mask = FezMath.GetMask(FezMath.VisibleAxis(this.CameraManager.Viewpoint)); Vector3 vector3 = FezMath.ForwardVector(this.CameraManager.Viewpoint); if (this.PlayerManager.Background) { vector3 *= -1f; } Ray ray = new Ray() { Position = this.PlayerManager.Center * (Vector3.One - mask) - vector3 * this.LevelManager.Size, Direction = vector3 }; if (this.PlayerManager.Action == ActionType.PullUpBack || this.PlayerManager.Action == ActionType.PullUpFront || this.PlayerManager.Action == ActionType.PullUpCornerLedge) { ray.Position += new Vector3(0.0f, 0.5f, 0.0f); } foreach (Volume volume in this.levelVolumes) { if (volume.Enabled) { if (!this.GameState.FarawaySettings.InTransition) { bool flag = (double)this.CameraManager.Center.Y > ((double)volume.From.Y + (double)volume.To.Y) / 2.0; if (!volume.PlayerIsHigher.HasValue || flag != volume.PlayerIsHigher.Value) { if (flag) { this.VolumeService.OnGoHigher(volume.Id); } else { this.VolumeService.OnGoLower(volume.Id); } volume.PlayerIsHigher = new bool?(flag); } } if (this.checkForContainment && (volume.Id == 1 || volume.Id == 2)) { if (volume.BoundingBox.Contains(this.PlayerManager.Position) != ContainmentType.Disjoint) { this.PlayerIsInside(volume, force); } } else { float?nullable = volume.BoundingBox.Intersects(ray); if (volume.ActorSettings != null && volume.ActorSettings.IsBlackHole) { if (!nullable.HasValue) { nullable = volume.BoundingBox.Intersects(new Ray(ray.Position + new Vector3(0.0f, 0.3f, 0.0f), ray.Direction)); } if (!nullable.HasValue) { nullable = volume.BoundingBox.Intersects(new Ray(ray.Position - new Vector3(0.0f, 0.3f, 0.0f), ray.Direction)); } } if (nullable.HasValue) { bool flag = false; bool isBlackHole = volume.ActorSettings != null && volume.ActorSettings.IsBlackHole; if (this.PlayerManager.CarriedInstance != null) { this.PlayerManager.CarriedInstance.PhysicsState.UpdatingPhysics = true; } NearestTriles nearestTriles = this.LevelManager.NearestTrile(ray.Position, this.PlayerManager.Background ? QueryOptions.Background : QueryOptions.None); if (this.LevelManager.Name != "PIVOT_TWO" && nearestTriles.Surface != null) { flag = flag | this.TestObstruction(nearestTriles.Surface, nullable.Value, ray.Position, isBlackHole); } if (nearestTriles.Deep != null) { flag = flag | this.TestObstruction(nearestTriles.Deep, nullable.Value, ray.Position, isBlackHole); } if (this.PlayerManager.CarriedInstance != null) { this.PlayerManager.CarriedInstance.PhysicsState.UpdatingPhysics = false; } if (!flag && (volume.ActorSettings != null && volume.ActorSettings.IsBlackHole || volume.Orientations.Contains(this.CameraManager.VisibleOrientation))) { this.PlayerIsInside(volume, force); } } } } } for (int index = this.PlayerManager.CurrentVolumes.Count - 1; index >= 0; --index) { Volume volume = this.PlayerManager.CurrentVolumes[index]; if (!volume.PlayerInside) { if (!force) { this.VolumeService.OnExit(volume.Id); } this.PlayerManager.CurrentVolumes.RemoveAt(index); } volume.PlayerInside = false; } if (this.PlayerManager.CurrentVolumes.Count <= 0) { return; } if (this.PlayerManager.Action == ActionType.LesserWarp || this.PlayerManager.Action == ActionType.GateWarp) { this.Input.Clear(); } if (!this.GrabInput()) { return; } foreach (Volume volume in this.PlayerManager.CurrentVolumes) { if (volume.ActorSettings != null && volume.ActorSettings.CodePattern != null && volume.ActorSettings.CodePattern.Length > 0) { this.TestCodePattern(volume); } } }
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 PointCollision(Vector3 point, NearestTriles instances) { this.Point = point; this.Instances = instances; }
protected override bool Act(TimeSpan elapsed) { ClimbingApproach approach; TrileInstance trileInstance1 = this.IsOnVine(out approach); this.PlayerManager.HeldInstance = trileInstance1; if (trileInstance1 == null || this.currentApproach == ClimbingApproach.None) { this.PlayerManager.Action = ActionType.Idle; return(false); } else { this.lastGrabbed = trileInstance1; this.sinceGrabbed = TimeSpan.Zero; if ((this.currentApproach == ClimbingApproach.Back || this.currentApproach == ClimbingApproach.Front) && (approach == ClimbingApproach.Right || approach == ClimbingApproach.Left)) { this.currentApproach = approach; } if (this.PlayerManager.Action == ActionType.SideClimbingVine && (double)Math.Abs(this.InputManager.Movement.X) > 0.5) { Vector3 vector3 = (float)Math.Sign(this.InputManager.Movement.X) * FezMath.RightVector(this.CameraManager.Viewpoint); NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.PlayerManager.Position + vector3); if (nearestTriles.Surface != null && nearestTriles.Surface.Trile.ActorSettings.Type == ActorType.Vine) { this.PlayerManager.Position += vector3 * 0.1f; this.PlayerManager.ForceOverlapsDetermination(); trileInstance1 = this.IsOnVine(out this.currentApproach); this.PlayerManager.HeldInstance = trileInstance1; } } if (trileInstance1 == null || this.currentApproach == ClimbingApproach.None) { this.PlayerManager.Action = ActionType.Idle; return(false); } else { this.RefreshPlayerAction(false); this.RefreshPlayerDirection(false); Vector3 vector3_1 = trileInstance1.Position + FezMath.HalfVector; Vector3 vector3_2 = Vector3.Zero; switch (this.currentApproach) { case ClimbingApproach.Right: case ClimbingApproach.Left: TrileInstance trileInstance2 = this.LevelManager.ActualInstanceAt(this.PlayerManager.Position); vector3_2 = trileInstance2 == null || trileInstance2.Trile.ActorSettings.Type != ActorType.Vine ? FezMath.XZMask : FezMath.SideMask(this.CameraManager.Viewpoint); break; case ClimbingApproach.Back: case ClimbingApproach.Front: vector3_2 = FezMath.DepthMask(this.CameraManager.Viewpoint); break; } this.PlayerManager.Position = this.PlayerManager.Position * (Vector3.One - vector3_2) + vector3_1 * vector3_2; Vector2 vector2 = this.InputManager.Movement * 4.7f * 0.475f * (float)elapsed.TotalSeconds; Vector3 vector = Vector3.Zero; if (this.PlayerManager.Action != ActionType.SideClimbingVine) { vector = Vector3.Transform(Vector3.UnitX * vector2.X * 0.75f, this.CameraManager.Rotation); } Vector3 impulse = vector2.Y * Vector3.UnitY; QueryOptions options = this.PlayerManager.Background ? QueryOptions.Background : QueryOptions.None; FaceOrientation face = this.PlayerManager.Background ? this.CameraManager.VisibleOrientation : FezMath.GetOpposite(this.CameraManager.VisibleOrientation); NearestTriles nearestTriles1 = this.LevelManager.NearestTrile(this.PlayerManager.Center + Vector3.Down * 1.5f + this.PlayerManager.Size / 2f * FezMath.Sign(vector), options); NearestTriles nearestTriles2 = this.LevelManager.NearestTrile(this.PlayerManager.Center + vector * 2f, options); if ((nearestTriles2.Surface == null || nearestTriles2.Surface.Trile.ActorSettings.Type != ActorType.Vine) && (nearestTriles1.Deep == null || nearestTriles1.Deep.GetRotatedFace(face) == CollisionType.None)) { vector = Vector3.Zero; } nearestTriles1 = this.LevelManager.NearestTrile(this.PlayerManager.Center + this.PlayerManager.Size / 2f * Vector3.Down, options); NearestTriles nearestTriles3 = this.LevelManager.NearestTrile(this.PlayerManager.Center + impulse * 2f, options); if ((nearestTriles3.Surface == null || nearestTriles3.Surface.Trile.ActorSettings.Type != ActorType.Vine) && (nearestTriles1.Deep == null || nearestTriles1.Deep.GetRotatedFace(face) == CollisionType.None)) { impulse = Vector3.Zero; if (FezButtonStateExtensions.IsDown(this.InputManager.Up)) { Vector3 vector3_3 = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection); TrileInstance trileInstance3 = this.LevelManager.NearestTrile(trileInstance1.Center + vector3_3 * 0.5f + vector3_3 * trileInstance1.TransformedSize / 2f).Deep; if (trileInstance3 != null && !trileInstance3.Trile.Immaterial && (trileInstance3.Enabled && trileInstance3.GetRotatedFace(face) != CollisionType.None)) { TrileInstance trileInstance4 = this.LevelManager.ActualInstanceAt(trileInstance3.Position - vector3_3 + new Vector3(0.5f)); TrileInstance trileInstance5 = this.LevelManager.NearestTrile(trileInstance3.Position - vector3_3 + new Vector3(0.5f)).Deep; if ((trileInstance5 == null || !trileInstance5.Enabled || trileInstance5.GetRotatedFace(this.CameraManager.VisibleOrientation) == CollisionType.None) && (trileInstance4 == null || !trileInstance4.Enabled || trileInstance4.Trile.Immaterial)) { this.PlayerManager.HeldInstance = trileInstance3; this.PlayerManager.Action = ActionType.GrabCornerLedge; Vector3 vector3_4 = (-vector3_3 + Vector3.UnitY) * trileInstance3.TransformedSize / 2f; this.PlayerManager.Position = trileInstance3.Center + vector3_4; this.PlayerManager.ForceOverlapsDetermination(); return(false); } } } } float num1 = (float)((double)FezMath.Saturate(Math.Abs((float)((double)this.PlayerManager.Animation.Timing.NormalizedStep * 2.0 % 1.0 - 0.5))) * 1.39999997615814 + 0.25); float num2 = FezMath.Saturate(Math.Abs((float)(((double)this.PlayerManager.Animation.Timing.NormalizedStep + 0.300000011920929) % 1.0))) + 0.2f; int frame = this.PlayerManager.Animation.Timing.Frame; if (this.lastFrame != frame) { bool flag = (double)Math.Abs(this.InputManager.Movement.Y) < 0.5; if (flag && frame == 0 || !flag && (frame == 1 || frame == 4)) { SoundEffectExtensions.EmitAt(this.climbSound, this.PlayerManager.Position, RandomHelper.Between(-0.100000001490116, 0.100000001490116), RandomHelper.Between(0.899999976158142, 1.0)); } this.lastFrame = frame; } this.PlayerManager.Velocity = vector * num2 + impulse * num1; if (trileInstance1.PhysicsState != null) { IPlayerManager playerManager = this.PlayerManager; Vector3 vector3_3 = playerManager.Velocity + trileInstance1.PhysicsState.Velocity; playerManager.Velocity = vector3_3; } float timeFactor = impulse == Vector3.Zero ? 0.0f : Math.Abs(this.InputManager.Movement.Y); if (this.PlayerManager.Action != ActionType.SideClimbingVine) { timeFactor = vector == Vector3.Zero ? timeFactor : FezMath.Saturate(timeFactor + Math.Abs(this.InputManager.Movement.X)); } this.PlayerManager.Animation.Timing.Update(elapsed, timeFactor); this.PlayerManager.GroundedVelocity = new Vector3?(this.PlayerManager.Velocity); MultipleHits <CollisionResult> multipleHits = this.CollisionManager.CollideEdge(this.PlayerManager.Center, impulse, this.PlayerManager.Size / 2f, Direction2D.Vertical); if ((double)impulse.Y < 0.0 && (multipleHits.NearLow.Collided || multipleHits.FarHigh.Collided) && multipleHits.First.Destination.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.None) { this.lastGrabbed = (TrileInstance)null; this.PlayerManager.HeldInstance = (TrileInstance)null; this.PlayerManager.Action = ActionType.Falling; } return(false); } } }
protected override bool Act(TimeSpan elapsed) { ClimbingApproach approach; TrileInstance trileInstance1 = this.IsOnLadder(out approach); this.PlayerManager.HeldInstance = trileInstance1; if (trileInstance1 == null || this.currentApproach == ClimbingApproach.None) { this.PlayerManager.Action = ActionType.Idle; return(false); } else { this.lastGrabbed = trileInstance1; this.sinceGrabbed = TimeSpan.Zero; this.currentApproach = approach; this.RefreshPlayerAction(); this.RefreshPlayerDirection(); this.PlayerManager.Position = this.PlayerManager.Position * Vector3.UnitY + (trileInstance1.Position + FezMath.HalfVector) * FezMath.XZMask; Vector3 vector3_1 = (float)((double)this.InputManager.Movement.Y * 4.69999980926514 * 0.425000011920929) * (float)elapsed.TotalSeconds * Vector3.UnitY; Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint) * (this.PlayerManager.Background ? -1f : 1f); if ((double)this.PlayerManager.Center.Y < (double)this.LevelManager.Size.Y - 1.0 && (double)this.PlayerManager.Center.Y > 1.0) { QueryOptions options = this.PlayerManager.Background ? QueryOptions.Background : QueryOptions.None; NearestTriles nearestTriles1 = this.LevelManager.NearestTrile(this.PlayerManager.Center + Vector3.Down, options); NearestTriles nearestTriles2 = this.LevelManager.NearestTrile(this.PlayerManager.Center + vector3_1, options); NearestTriles nearestTriles3 = this.LevelManager.NearestTrile(this.PlayerManager.Center + vector3_1 + FezMath.Sign(vector3_1) * new Vector3(0.0f, 0.5f, 0.0f), options); bool flag = false; if ((nearestTriles2.Surface == null || (flag = nearestTriles3.Deep != null && (double)FezMath.Dot(this.PlayerManager.Position, b) > (double)FezMath.Dot(nearestTriles3.Deep.Center, b))) && (nearestTriles1.Deep == null || nearestTriles1.Deep.GetRotatedFace(this.PlayerManager.Background ? this.CameraManager.VisibleOrientation : FezMath.GetOpposite(this.CameraManager.VisibleOrientation)) == CollisionType.None)) { vector3_1 = Vector3.Zero; if (!flag && (this.PlayerManager.LookingDirection == HorizontalDirection.Left && FezButtonStateExtensions.IsDown(this.InputManager.Left) || this.PlayerManager.LookingDirection == HorizontalDirection.Right && FezButtonStateExtensions.IsDown(this.InputManager.Right))) { if (nearestTriles2.Deep == null || nearestTriles1.Surface == null) { this.PlayerManager.Action = ActionType.ClimbOverLadder; return(false); } else if ((double)FezMath.Dot(nearestTriles2.Deep.Center, b) > (double)FezMath.Dot(nearestTriles1.Surface.Center, b)) { this.PlayerManager.Action = ActionType.ClimbOverLadder; return(false); } } } } float num1 = (float)((double)FezMath.Saturate(Math.Abs((float)((double)this.PlayerManager.Animation.Timing.NormalizedStep * 2.0 % 1.0 - 0.5))) * 1.39999997615814 + 0.25); int frame = this.PlayerManager.Animation.Timing.Frame; if (this.lastFrame != frame) { if (frame == 1 || frame == 4) { SoundEffectExtensions.EmitAt(this.climbSound, this.PlayerManager.Position); } this.lastFrame = frame; } this.PlayerManager.Velocity = vector3_1 * num1; if (trileInstance1.PhysicsState != null) { IPlayerManager playerManager = this.PlayerManager; Vector3 vector3_2 = playerManager.Velocity + trileInstance1.PhysicsState.Velocity; playerManager.Velocity = vector3_2; } int num2 = Math.Sign(vector3_1.Y); this.PlayerManager.Animation.Timing.Update(elapsed, (float)num2); this.PlayerManager.GroundedVelocity = new Vector3?(this.PlayerManager.Velocity); MultipleHits <CollisionResult> multipleHits = this.CollisionManager.CollideEdge(this.PlayerManager.Center, vector3_1, this.PlayerManager.Size / 2f, Direction2D.Vertical); if ((double)vector3_1.Y < 0.0 && (multipleHits.NearLow.Collided || multipleHits.FarHigh.Collided)) { TrileInstance trileInstance2 = this.LevelManager.NearestTrile(multipleHits.First.Destination.Center).Surface; if (trileInstance2 != null && trileInstance2.Trile.ActorSettings.Type == ActorType.Ladder && this.currentApproach == ClimbingApproach.Back) { IPlayerManager playerManager = this.PlayerManager; Vector3 vector3_2 = playerManager.Center + vector3_1; playerManager.Center = vector3_2; } else { this.lastGrabbed = (TrileInstance)null; this.PlayerManager.HeldInstance = (TrileInstance)null; this.PlayerManager.Action = ActionType.Falling; } } return(false); } }
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 b1 = FezMath.SideMask(this.CameraManager.Viewpoint); Vector3 depthMask = FezMath.DepthMask(this.CameraManager.Viewpoint); Vector3 vector3_1 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint); if (this.RightPositions == 8) { bool flag = false; foreach (TrileInstance instance in this.Blocks) { if (!flag) { ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, instance, NameOfGodPuzzleHost.PuzzleCenter + Vector3.UnitY * 2f + Vector3.UnitZ) { FlashOnSpawn = true, ActorToSpawn = ActorType.PieceOfHeart }); 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; Vector3 b2 = FezMath.RightVector(this.CameraManager.Viewpoint); foreach (TrileInstance trileInstance1 in this.Blocks) { float num = FezMath.Dot(trileInstance1.Center, b2); trileInstance1.LastTreasureSin = 0.0f; foreach (TrileInstance trileInstance2 in this.Blocks) { if (trileInstance2 != trileInstance1 && (double)num > (double)FezMath.Dot(trileInstance2.Center, b2)) { ++trileInstance1.LastTreasureSin; } } } using (List <TrileInstance> .Enumerator enumerator = this.Blocks.GetEnumerator()) { while (enumerator.MoveNext()) { TrileInstance instance = enumerator.Current; if (!instance.PhysicsState.Background && instance.Enabled && ((double)instance.Position.Y >= 57.0 && (double)instance.Position.Y < 57.75) && (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 - NameOfGodPuzzleHost.PuzzleCenter) / 1f), new Vector3(-8f, 0.0f, -8f)), new Vector3(8f, 1f, 8f)); Vector3 vector3_3 = NameOfGodPuzzleHost.PuzzleCenter + vector3_2 * 1f; Vector3 vector3_4 = (vector3_3 - instance.Center) * FezMath.XZMask; float num1 = Math.Max(vector3_4.Length(), 0.1f); instance.PhysicsState.Velocity += 0.25f * vector3_4 / num1 * (float)gameTime.ElapsedGameTime.TotalSeconds; if ((double)num1 <= 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.0); } else { return(false); } }))) { instance.Enabled = false; for (int index = 0; index < NameOfGodPuzzleHost.SpiralTraversal.Length; ++index) { int num2 = NameOfGodPuzzleHost.SpiralTraversal[index]; NearestTriles nearestTriles = this.LevelManager.NearestTrile(NameOfGodPuzzleHost.PuzzleCenter + (float)num2 * 1f * depthMask, QueryOptions.None, new Viewpoint?(FezMath.GetRotatedView(this.CameraManager.Viewpoint, 1))); if (nearestTriles.Deep == null) { nearestTriles.Deep = this.LevelManager.NearestTrile(NameOfGodPuzzleHost.PuzzleCenter + (float)num2 * 1f * depthMask - depthMask * 0.5f, QueryOptions.None, new Viewpoint?(FezMath.GetRotatedView(this.CameraManager.Viewpoint, 1))).Deep; } if (nearestTriles.Deep == null) { nearestTriles.Deep = this.LevelManager.NearestTrile(NameOfGodPuzzleHost.PuzzleCenter + (float)num2 * 1f * depthMask + depthMask * 0.5f, QueryOptions.None, new Viewpoint?(FezMath.GetRotatedView(this.CameraManager.Viewpoint, 1))).Deep; } if (nearestTriles.Deep == null) { vector3_3 = instance.PhysicsState.Center = vector3_1 * instance.PhysicsState.Center + NameOfGodPuzzleHost.PuzzleCenter * depthMask + depthMask * (float)num2 * 1f; break; } } instance.Enabled = true; } if ((double)Math.Abs(vector3_4.X) <= 1.0 / 64.0 && (double)Math.Abs(vector3_4.Y) <= 1.0 / 64.0) { instance.PhysicsState.Velocity = Vector3.Zero; instance.PhysicsState.Center = vector3_3; instance.PhysicsState.UpdateInstance(); this.LevelManager.UpdateInstance(instance); } if ((instance.PhysicsState.Ground.NearLow == null || instance.PhysicsState.Ground.NearLow.PhysicsState != null && (double)Math.Abs(FezMath.Dot(instance.PhysicsState.Ground.NearLow.Center - instance.Center, b1)) > 0.875) && (instance.PhysicsState.Ground.FarHigh == null || instance.PhysicsState.Ground.FarHigh.PhysicsState != null && (double)Math.Abs(FezMath.Dot(instance.PhysicsState.Ground.FarHigh.Center - instance.Center, b1)) > 0.875)) { instance.PhysicsState.Ground = new MultipleHits <TrileInstance>(); instance.PhysicsState.Center += Vector3.Down * 0.1f; } if (instance.PhysicsState.Grounded && instance.PhysicsState.Velocity == Vector3.Zero) { string cubemapPath = instance.Trile.CubemapPath; FaceOrientation o = FezMath.OrientationFromPhi(FezMath.ToPhi(this.CameraManager.Viewpoint) + instance.Phi); switch (o) { case FaceOrientation.Right: case FaceOrientation.Left: o = FezMath.GetOpposite(o); break; } int index = (int)MathHelper.Clamp(instance.LastTreasureSin, 0.0f, 7f); if (NameOfGodPuzzleHost.Slots[index].Face == o && NameOfGodPuzzleHost.Slots[index].TrileName == cubemapPath) { ++this.RightPositions; } } } } } } }