protected override bool Act(TimeSpan elapsed) { if (this.PlayerManager.CarriedInstance == null) { this.PlayerManager.Action = ActionType.Idle; return(false); } else { Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection); TrileInstance carriedInstance = this.PlayerManager.CarriedInstance; Vector3 vector3_2 = this.PlayerManager.Center + this.PlayerManager.Size / 2f * (Vector3.Down + vector3_1) - carriedInstance.TransformedSize / 2f * vector3_1 + carriedInstance.Trile.Size / 2f * (Vector3.UnitY + vector3_1) + 0.125f * vector3_1; bool flag = ActorTypeExtensions.IsLight(carriedInstance.Trile.ActorSettings.Type); Vector2[] vector2Array = flag ? Lift.LightTrilePositioning : Lift.HeavyTrilePositioning; int index = (flag ? 4 : 7) - this.PlayerManager.Animation.Timing.Frame; Vector3 vector3_3 = vector3_2 + (vector2Array[index].X * -vector3_1 + vector2Array[index].Y * Vector3.Up) * 1f / 16f; carriedInstance.PhysicsState.Center = vector3_3; carriedInstance.PhysicsState.UpdateInstance(); this.PlayerManager.Position -= vector3_3 - carriedInstance.Center; this.PlayerManager.CarriedInstance.PhysicsState.UpdateInstance(); if (this.PlayerManager.Animation.Timing.Ended) { Vector3 impulse = (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464) * (float)elapsed.TotalSeconds * Vector3.Down; if ((double)this.PlayerManager.GroundMovement.Y < 0.0) { impulse += this.PlayerManager.GroundMovement; } MultipleHits <CollisionResult> result = this.CollisionManager.CollideEdge(carriedInstance.PhysicsState.Center, impulse, carriedInstance.TransformedSize / 2f, Direction2D.Vertical); if (BoxCollisionResultExtensions.AnyCollided(result)) { carriedInstance.PhysicsState.Ground = new MultipleHits <TrileInstance>() { NearLow = result.NearLow.Collided ? result.NearLow.Destination : (TrileInstance)null, FarHigh = result.FarHigh.Collided ? result.FarHigh.Destination : (TrileInstance)null }; if (carriedInstance.PhysicsState.Ground.First.PhysicsState != null) { carriedInstance.PhysicsState.GroundMovement = carriedInstance.PhysicsState.Ground.First.PhysicsState.Velocity; carriedInstance.PhysicsState.Center += carriedInstance.PhysicsState.GroundMovement; } } carriedInstance.PhysicsState.Velocity = impulse; carriedInstance.PhysicsState.UpdateInstance(); if (flag) { this.PlayerManager.Action = ActionType.Idle; } else { this.PlayerManager.PushedInstance = this.PlayerManager.CarriedInstance; this.PlayerManager.Action = ActionType.Grabbing; } this.PlayerManager.CarriedInstance = (TrileInstance)null; this.PhysicsManager.HugWalls((IPhysicsEntity)this.PlayerManager, false, false, true); } return(true); } }
protected override bool Act(TimeSpan elapsed) { Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection); this.PlayerManager.Animation.Timing.Update(elapsed); if (this.PlayerManager.CarriedInstance != null) { if (this.PlayerManager.CarriedInstance.PhysicsState == null) { this.PlayerManager.CarriedInstance = (TrileInstance)null; } bool flag = ActorTypeExtensions.IsLight(this.PlayerManager.CarriedInstance.Trile.ActorSettings.Type); Vector2[] vector2Array = flag ? Throw.LightOffsets : Throw.HeavyOffsets; if (!flag) { IPlayerManager playerManager = this.PlayerManager; Vector3 vector3_2 = playerManager.Velocity * Vector3.UnitY; playerManager.Velocity = vector3_2; } if (this.PlayerManager.Animation.Timing.Frame < vector2Array.Length) { int frame = this.PlayerManager.Animation.Timing.Frame; TrileInstance carriedInstance = this.PlayerManager.CarriedInstance; Vector2 vector2 = vector2Array[frame]; Vector3 vector3_2 = this.PlayerManager.Center + this.PlayerManager.Size / 2f * (Vector3.Down + vector3_1) - carriedInstance.TransformedSize / 2f * vector3_1 + carriedInstance.Trile.Size / 2f * (Vector3.UnitY + vector3_1) - vector3_1 * 8f / 16f + Vector3.UnitY * 9f / 16f; if (flag) { vector3_2 += vector3_1 * 1f / 16f + Vector3.UnitY * 2f / 16f; } Vector3 vector3_3 = vector3_2 + (vector2.X * vector3_1 + vector2.Y * Vector3.Up) * (1.0 / 16.0); Vector3 vector3_4 = vector3_3 - carriedInstance.Center; carriedInstance.PhysicsState.Velocity = vector3_4; carriedInstance.PhysicsState.UpdatingPhysics = true; this.PhysicsManager.Update((ISimplePhysicsEntity)carriedInstance.PhysicsState, false, false); carriedInstance.PhysicsState.UpdatingPhysics = false; carriedInstance.PhysicsState.UpdateInstance(); carriedInstance.PhysicsState.Velocity = Vector3.Zero; IPlayerManager playerManager = this.PlayerManager; Vector3 vector3_5 = playerManager.Velocity - vector3_3 - carriedInstance.Center; playerManager.Velocity = vector3_5; } else if (!this.thrown) { this.thrown = true; this.PlayerManager.CarriedInstance.Phi = FezMath.SnapPhi(this.PlayerManager.CarriedInstance.Phi); this.PlayerManager.CarriedInstance.PhysicsState.Background = false; this.PlayerManager.CarriedInstance.PhysicsState.Velocity = this.PlayerManager.Velocity * 0.5f + ((float)FezMath.Sign(this.PlayerManager.LookingDirection) * FezMath.RightVector(this.CameraManager.Viewpoint) + Vector3.Up) * 0.08f; this.PlayerManager.CarriedInstance = (TrileInstance)null; } } if (this.PlayerManager.Animation.Timing.Ended) { this.thrown = false; this.PlayerManager.SyncCollisionSize(); this.PlayerManager.Action = ActionType.Idle; } return(false); }
protected override void TestConditions() { if ((double)this.CollisionManager.GravityFactor < 0.0) { return; } switch (this.PlayerManager.Action) { case ActionType.IdlePlay: case ActionType.IdleSleep: case ActionType.IdleLookAround: case ActionType.IdleYawn: case ActionType.Grabbing: case ActionType.Pushing: case ActionType.Teetering: case ActionType.Idle: case ActionType.Walking: case ActionType.Running: case ActionType.Sliding: case ActionType.Landing: if (this.PlayerManager.Background || !this.PlayerManager.Grounded || this.InputManager.GrabThrow != FezButtonState.Pressed) { break; } TrileInstance key = this.PlayerManager.PushedInstance ?? this.PlayerManager.AxisCollision[VerticalDirection.Up].Deep ?? this.PlayerManager.AxisCollision[VerticalDirection.Down].Deep; if (key == null || !ActorTypeExtensions.IsPickable(key.Trile.ActorSettings.Type) || key.Trile.ActorSettings.Type == ActorType.Couch || !key.PhysicsState.Grounded) { break; } Vector3 halfSize = key.TransformedSize / 2f - new Vector3(0.004f); if (BoxCollisionResultExtensions.AnyCollided(this.CollisionManager.CollideEdge(key.Center, key.Trile.Size.Y * Vector3.Up * (float)Math.Sign(this.CollisionManager.GravityFactor), halfSize, Direction2D.Vertical))) { break; } TrileInstance trileInstance = this.LevelManager.ActualInstanceAt(key.Center + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)); TrileGroup trileGroup; if (trileInstance != null && trileInstance.PhysicsState != null && trileInstance.PhysicsState.Ground.First == key || this.LevelManager.PickupGroups.TryGetValue(key, out trileGroup) && trileGroup.Triles.Count > 1) { break; } ActionType actionType = ActorTypeExtensions.IsLight(key.Trile.ActorSettings.Type) ? ActionType.Lifting : ActionType.LiftingHeavy; if (this.PlayerManager.Action == ActionType.Grabbing) { this.PlayerManager.CarriedInstance = key; this.PlayerManager.Action = actionType; break; } else { this.PlayerManager.PushedInstance = key; this.WalkTo.Destination = new Func <Vector3>(this.GetDestination); this.WalkTo.NextAction = actionType; this.PlayerManager.Action = ActionType.WalkingTo; break; } } }
public void SyncCollisionSize() { if (this.carriedInstance != null && this.lastCarriedInstance == null) { this.variableSize = !ActorTypeExtensions.IsLight(this.carriedInstance.Trile.ActorSettings.Type) ? new Vector3(0.75f, 1.75f, 0.75f) : new Vector3(0.75f, 31.0 / 16.0, 0.75f); this.Position -= (this.variableSize - this.BaseSize) / 2f * Vector3.UnitY; } else if (this.carriedInstance == null && this.lastCarriedInstance != null) { this.Position += (this.variableSize - this.BaseSize) / 2f * Vector3.UnitY; this.variableSize = this.BaseSize; } this.lastCarriedInstance = this.carriedInstance; }
protected override void TestConditions() { switch (this.PlayerManager.Action) { case ActionType.CarryIdle: case ActionType.CarryWalk: case ActionType.CarryJump: case ActionType.CarrySlide: case ActionType.CarryHeavyIdle: case ActionType.CarryHeavyWalk: case ActionType.CarryHeavyJump: case ActionType.CarryHeavySlide: if (this.PlayerManager.Background || this.InputManager.GrabThrow != FezButtonState.Pressed || (double)this.InputManager.Movement.Y >= -0.5 && (double)Math.Abs(this.InputManager.Movement.X) >= 0.25) { break; } TrileInstance carriedInstance = this.PlayerManager.CarriedInstance; this.PlayerManager.Action = ActorTypeExtensions.IsLight(carriedInstance.Trile.ActorSettings.Type) ? ActionType.DropTrile : ActionType.DropHeavyTrile; Vector3 vector3_1 = FezMath.SideMask(this.CameraManager.Viewpoint); Vector3 vector3_2 = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection); Vector3 vector3_3 = this.PlayerManager.Center + this.PlayerManager.Size / 2f * (Vector3.Down + vector3_2) - carriedInstance.TransformedSize / 2f * vector3_2 + carriedInstance.Trile.Size / 2f * (Vector3.UnitY + vector3_2) + 0.125f * vector3_2; carriedInstance.Enabled = false; MultipleHits <CollisionResult> result = this.CollisionManager.CollideEdge(carriedInstance.Center, vector3_3 - carriedInstance.Center, carriedInstance.TransformedSize / 2f, Direction2D.Horizontal); if (BoxCollisionResultExtensions.AnyCollided(result)) { CollisionResult collisionResult = result.NearLow; if (!collisionResult.Collided || collisionResult.Destination.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.AllSides || (double)Math.Abs(collisionResult.Destination.Center.Y - vector3_3.Y) >= 1.0) { collisionResult = result.FarHigh; } if (collisionResult.Collided && collisionResult.Destination.GetRotatedFace(this.CameraManager.VisibleOrientation) == CollisionType.AllSides && (double)Math.Abs(collisionResult.Destination.Center.Y - vector3_3.Y) < 1.0) { TrileInstance trileInstance = collisionResult.Destination; Vector3 vector3_4 = trileInstance.Center - vector3_2 * trileInstance.TransformedSize / 2f; Vector3 vector3_5 = vector3_3 + vector3_2 * carriedInstance.TransformedSize / 2f; this.PlayerManager.Position -= vector3_1 * (vector3_5 - vector3_4); } } carriedInstance.Enabled = true; IPlayerManager playerManager = this.PlayerManager; Vector3 vector3_6 = playerManager.Velocity * Vector3.UnitY; playerManager.Velocity = vector3_6; break; } }
protected override bool Act(TimeSpan elapsed) { if (this.PlayerManager.CarriedInstance == null) { this.PlayerManager.Action = ActionType.Idle; return(false); } else { bool flag = ActorTypeExtensions.IsLight(this.PlayerManager.CarriedInstance.Trile.ActorSettings.Type); if (this.PlayerManager.Action == ActionType.CarryWalk || this.PlayerManager.Action == ActionType.CarryHeavyWalk || (this.PlayerManager.Action == ActionType.CarryHeavyJump || this.PlayerManager.Action == ActionType.CarryJump) && this.PlayerManager.Grounded) { this.movementHelper.WalkAcceleration = flag ? 4.086957f : 2.35f; this.movementHelper.Update((float)elapsed.TotalSeconds); } float timeFactor = 1.2f; if (this.PlayerManager.Action == ActionType.CarryJump || this.PlayerManager.Action == ActionType.CarryHeavyJump) { timeFactor = 1f; } this.PlayerManager.Animation.Timing.Update(elapsed, timeFactor); if (this.PlayerManager.Action == ActionType.CarryJump || this.PlayerManager.Action == ActionType.CarryHeavyJump) { if (this.PlayerManager.Animation.Timing.Frame == 1 && this.PlayerManager.Grounded && !this.jumpIsFall) { SoundEffectExtensions.EmitAt(this.jumpSound, this.PlayerManager.Position); IPlayerManager playerManager1 = this.PlayerManager; Vector3 vector3_1 = playerManager1.Velocity * FezMath.XZMask; playerManager1.Velocity = vector3_1; IPlayerManager playerManager2 = this.PlayerManager; Vector3 vector3_2 = playerManager2.Velocity + 0.13275f * Vector3.UnitY * (flag ? 1f : 0.75f); playerManager2.Velocity = vector3_2; } else { this.JumpAftertouch((float)elapsed.TotalSeconds); } } this.MoveCarriedInstance(); return(false); } }
protected override void TestConditions() { switch (this.PlayerManager.Action) { case ActionType.CarryIdle: case ActionType.CarryWalk: case ActionType.CarryJump: case ActionType.CarrySlide: case ActionType.CarryHeavyIdle: case ActionType.CarryHeavyWalk: case ActionType.CarryHeavyJump: case ActionType.CarryHeavySlide: if (this.PlayerManager.Background || this.InputManager.GrabThrow != FezButtonState.Pressed || this.InputManager.Down == FezButtonState.Down && !FezMath.AlmostEqual(this.InputManager.Movement, Vector2.Zero, 0.5f)) { break; } this.PlayerManager.Action = ActorTypeExtensions.IsLight(this.PlayerManager.CarriedInstance.Trile.ActorSettings.Type) ? ActionType.Throwing : ActionType.ThrowingHeavy; this.thrown = false; break; } }
protected override bool Act(TimeSpan elapsed) { if (this.PlayerManager.CarriedInstance == null) { return(false); } Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection); Vector3 vector3_2 = this.PlayerManager.Center + this.PlayerManager.Size / 2f * (Vector3.Down * (float)Math.Sign(this.CollisionManager.GravityFactor) + vector3_1) - this.PlayerManager.CarriedInstance.TransformedSize / 2f * vector3_1 + this.PlayerManager.CarriedInstance.Trile.Size / 2f * (Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor) + vector3_1); bool flag = ActorTypeExtensions.IsLight(this.PlayerManager.CarriedInstance.Trile.ActorSettings.Type); this.PlayerManager.Animation.Timing.Update(elapsed); int frame = this.PlayerManager.Animation.Timing.Frame; Vector2[] vector2Array = flag ? Lift.LightTrilePositioning : Lift.HeavyTrilePositioning; this.PlayerManager.CarriedInstance.PhysicsState.Center = vector3_2 + (vector2Array[frame].X * -vector3_1 + vector2Array[frame].Y * Vector3.Up * (float)Math.Sign(this.CollisionManager.GravityFactor)) * (1.0 / 16.0) + 3.0 / 16.0 * vector3_1; this.PlayerManager.CarriedInstance.PhysicsState.UpdateInstance(); if (this.PlayerManager.Animation.Timing.Ended) { this.PlayerManager.Action = flag ? ActionType.CarryIdle : ActionType.CarryHeavyIdle; } return(false); }
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() { switch (this.PlayerManager.Action) { case ActionType.CarryIdle: case ActionType.CarryWalk: case ActionType.CarryJump: case ActionType.CarrySlide: case ActionType.CarryHeavyIdle: case ActionType.CarryHeavyWalk: case ActionType.CarryHeavyJump: case ActionType.CarryHeavySlide: if (this.PlayerManager.CarriedInstance == null) { break; } bool isLight = ActorTypeExtensions.IsLight(this.PlayerManager.CarriedInstance.Trile.ActorSettings.Type); bool flag1 = this.PlayerManager.Action == ActionType.CarryHeavyJump || this.PlayerManager.Action == ActionType.CarryJump; bool flag2 = flag1 && !this.PlayerManager.Animation.Timing.Ended; if (this.PlayerManager.Grounded && this.InputManager.Jump == FezButtonState.Pressed && FezButtonStateExtensions.IsDown(this.InputManager.Down) && this.PlayerManager.Ground.First.GetRotatedFace(this.CameraManager.VisibleOrientation) == CollisionType.TopOnly) { this.PlayerManager.Position -= Vector3.UnitY * this.CollisionManager.DistanceEpsilon * 2f; IPlayerManager playerManager = this.PlayerManager; Vector3 vector3 = playerManager.Velocity - 0.0075f * Vector3.UnitY; playerManager.Velocity = vector3; this.PlayerManager.Action = isLight ? ActionType.CarryJump : ActionType.CarryHeavyJump; this.PlayerManager.CanDoubleJump = false; break; } else if ((this.PlayerManager.Grounded || this.PlayerManager.CanDoubleJump) && (!flag1 || this.PlayerManager.Animation.Timing.Frame != 0) && this.InputManager.Jump == FezButtonState.Pressed) { this.jumpIsFall = false; this.Jump(isLight); break; } else if (this.PlayerManager.Grounded && (double)this.InputManager.Movement.X != 0.0 && !flag2) { this.PlayerManager.Action = isLight ? ActionType.CarryWalk : ActionType.CarryHeavyWalk; break; } else { if (this.PlayerManager.Action != ActionType.CarryHeavyJump && this.PlayerManager.Action != ActionType.CarryJump && !this.PlayerManager.Grounded) { this.jumpIsFall = true; this.PlayerManager.Action = isLight ? ActionType.CarryJump : ActionType.CarryHeavyJump; } if (this.wasNotGrounded && this.PlayerManager.Grounded) { SoundEffectExtensions.EmitAt(this.landSound, this.PlayerManager.Position); } this.wasNotGrounded = !this.PlayerManager.Grounded; if (this.PlayerManager.Action != ActionType.CarryIdle && this.PlayerManager.Action != ActionType.CarryHeavyIdle && (this.PlayerManager.Grounded && FezMath.AlmostEqual(FezMath.XZ(this.PlayerManager.Velocity), Vector2.Zero)) && !flag2) { this.PlayerManager.Action = isLight ? ActionType.CarryIdle : ActionType.CarryHeavyIdle; break; } else { if (this.PlayerManager.Action == ActionType.CarrySlide || !this.PlayerManager.Grounded || (FezMath.AlmostEqual(FezMath.XZ(this.PlayerManager.Velocity), Vector2.Zero) || !FezMath.AlmostEqual(this.InputManager.Movement, Vector2.Zero)) || flag2) { break; } this.PlayerManager.Action = isLight ? ActionType.CarrySlide : ActionType.CarryHeavySlide; this.PlayerManager.Animation.Timing.Paused = false; break; } } } }