Exemple #1
0
        private bool InstanceMaterialForQuery(TrileInstance instance, QueryOptions options, out LevelManager.QueryResult queryResult)
        {
            Trile         trile       = instance.Trile;
            CollisionType rotatedFace = instance.GetRotatedFace((options & QueryOptions.Background) == QueryOptions.Background ? FezMath.GetOpposite(this.CameraManager.VisibleOrientation) : this.CameraManager.VisibleOrientation);

            queryResult = trile.Immaterial || instance.PhysicsState != null && instance.PhysicsState.UpdatingPhysics || rotatedFace == CollisionType.Immaterial ? LevelManager.QueryResult.Nothing : (trile.Thin ? LevelManager.QueryResult.Thin : LevelManager.QueryResult.Full);
            return(queryResult != LevelManager.QueryResult.Nothing);
        }
Exemple #2
0
 private bool IsHuggable(TrileInstance instance, IPhysicsEntity entity)
 {
     if (instance != null && instance.Enabled && !instance.Trile.Immaterial && ((!instance.Trile.Thin || instance.Trile.ForceHugging) && (instance != this.PlayerManager.CarriedInstance && instance != this.PlayerManager.PushedInstance)) && (!ActorTypeExtensions.IsBomb(instance.Trile.ActorSettings.Type) && (instance.PhysicsState == null || instance.PhysicsState != entity)))
     {
         return(!FezMath.In <CollisionType>(instance.GetRotatedFace(entity.Background ? FezMath.GetOpposite(this.CameraManager.VisibleOrientation) : this.CameraManager.VisibleOrientation), CollisionType.Immaterial, CollisionType.TopNoStraightLedge, CollisionType.AllSides, (IEqualityComparer <CollisionType>)CollisionTypeComparer.Default));
     }
     else
     {
         return(false);
     }
 }
Exemple #3
0
 protected override void TestConditions()
 {
     switch (this.PlayerManager.Action)
     {
     case ActionType.Jumping:
     case ActionType.Falling:
         HorizontalDirection lookingDirection = this.PlayerManager.LookingDirection;
         if (lookingDirection == HorizontalDirection.None)
         {
             break;
         }
         Vector3 vector3_1 = FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint);
         Vector3 b         = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(lookingDirection);
         if ((double)FezMath.Dot(this.PlayerManager.Velocity, b) <= 0.025000000372529 && (double)(this.InputManager.Movement.X * (float)FezMath.Sign(lookingDirection)) <= 0.100000001490116)
         {
             break;
         }
         MultipleHits <CollisionResult> wallCollision = this.PlayerManager.WallCollision;
         FaceOrientation visibleOrientation           = this.CameraManager.VisibleOrientation;
         TrileInstance   trileInstance1 = wallCollision.NearLow.Destination ?? this.PlayerManager.CornerCollision[1 + (lookingDirection == HorizontalDirection.Left ? 2 : 0)].Instances.Deep;
         TrileInstance   trileInstance2 = wallCollision.FarHigh.Destination ?? this.PlayerManager.CornerCollision[lookingDirection == HorizontalDirection.Left ? 2 : 0].Instances.Deep;
         Trile           trile          = trileInstance1 == null ? (Trile)null : trileInstance1.Trile;
         if (trileInstance1 == null || trileInstance1.GetRotatedFace(visibleOrientation) == CollisionType.None || (trile.ActorSettings.Type == ActorType.Ladder || trileInstance1 == trileInstance2) || (trileInstance2 != null && trileInstance2.GetRotatedFace(visibleOrientation) == CollisionType.AllSides || !trileInstance1.Enabled))
         {
             break;
         }
         TrileInstance trileInstance3 = this.LevelManager.ActualInstanceAt(trileInstance1.Center - b);
         TrileInstance trileInstance4 = this.LevelManager.NearestTrile(trileInstance1.Center - b).Deep;
         if (trileInstance4 != null && trileInstance4.Enabled && trileInstance4.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.None || trileInstance3 != null && trileInstance3.Enabled && !trileInstance3.Trile.Immaterial || this.PlayerManager.Action == ActionType.Jumping && (double)((trileInstance1.Center - this.PlayerManager.LeaveGroundPosition) * vector3_1).Length() < 1.25 || trileInstance1.GetRotatedFace(visibleOrientation) != CollisionType.AllSides && BoxCollisionResultExtensions.AnyHit(this.CollisionManager.CollideEdge(trileInstance1.Center, Vector3.Down * (float)Math.Sign(this.CollisionManager.GravityFactor), this.PlayerManager.Size * FezMath.XZMask / 2f, Direction2D.Vertical)))
         {
             break;
         }
         Vector3 vector3_2 = (-b + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)) * trileInstance1.TransformedSize / 2f;
         if ((double)(this.PlayerManager.Center * vector3_1 - trileInstance1.Center * vector3_1 + vector3_2).Length() >= 0.349999994039536)
         {
             break;
         }
         this.PlayerManager.HeldInstance = trileInstance1;
         this.PlayerManager.Action       = ActionType.GrabCornerLedge;
         Waiters.Wait(0.1, (Action)(() =>
         {
             if (this.PlayerManager.HeldInstance == null)
             {
                 return;
             }
             SoundEffectExtensions.EmitAt(this.sound, this.PlayerManager.Position);
             this.InputManager.ActiveGamepad.Vibrate(VibrationMotor.LeftLow, 0.100000001490116, TimeSpan.FromSeconds(0.200000002980232));
             this.InputManager.ActiveGamepad.Vibrate(VibrationMotor.RightHigh, 0.400000005960464, TimeSpan.FromSeconds(0.200000002980232));
         }));
         break;
     }
 }
 protected override void TestConditions()
 {
     if (this.PlayerManager.Background)
     {
         return;
     }
     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.Sliding:
     case ActionType.Landing:
         if (!this.PlayerManager.Grounded || this.InputManager.Down != FezButtonState.Pressed)
         {
             break;
         }
         TrileInstance trileInstance1 = this.PlayerManager.Ground.NearLow;
         TrileInstance trileInstance2 = this.PlayerManager.Ground.FarHigh;
         Trile         trile          = trileInstance1 == null ? (Trile)null : trileInstance1.Trile;
         Vector3       vector3        = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection);
         TrileInstance trileInstance3 = this.PlayerManager.Ground.NearLow ?? this.PlayerManager.Ground.FarHigh;
         if (BoxCollisionResultExtensions.AnyHit(this.CollisionManager.CollideEdge(trileInstance3.Center + trileInstance3.TransformedSize * (Vector3.UnitY * 0.498f + vector3 * 0.5f), Vector3.Down * (float)Math.Sign(this.CollisionManager.GravityFactor), this.PlayerManager.Size * FezMath.XZMask / 2f, Direction2D.Vertical)) || trileInstance1 == null || (trileInstance1.GetRotatedFace(this.CameraManager.VisibleOrientation) == CollisionType.None || trile.ActorSettings.Type == ActorType.Ladder) || (trileInstance1 == trileInstance2 || trileInstance2 != null && trileInstance2.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.None))
         {
             break;
         }
         TrileInstance trileInstance4 = this.LevelManager.ActualInstanceAt(trileInstance1.Position + vector3 + new Vector3(0.5f));
         TrileInstance trileInstance5 = this.LevelManager.NearestTrile(trileInstance1.Position + vector3 + new Vector3(0.5f)).Deep;
         if (trileInstance5 != null && trileInstance5.Enabled && trileInstance5.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.None || trileInstance4 != null && trileInstance4.Enabled && (!trileInstance4.Trile.Immaterial && trileInstance4.Trile.ActorSettings.Type != ActorType.Vine))
         {
             break;
         }
         this.WalkTo.Destination         = new Func <Vector3>(this.GetDestination);
         this.WalkTo.NextAction          = ActionType.LowerToCornerLedge;
         this.PlayerManager.Action       = ActionType.WalkingTo;
         this.PlayerManager.HeldInstance = trileInstance1;
         break;
     }
 }
Exemple #5
0
 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;
     }
 }
Exemple #6
0
        private static CollisionResult CollideWithInstance(Vector3 origin, Vector3 destination, Vector3 impulse, TrileInstance instance, QueryOptions options, float elasticity, Viewpoint viewpoint, bool invertedGravity)
        {
            CollisionResult collisionResult = new CollisionResult();
            Vector3         normal          = -FezMath.Sign(impulse);
            FaceOrientation faceOrientation = FezMath.VisibleOrientation(viewpoint);

            if ((options & QueryOptions.Background) == QueryOptions.Background)
            {
                faceOrientation = FezMath.GetOpposite(faceOrientation);
            }
            CollisionType rotatedFace = instance.GetRotatedFace(faceOrientation);

            if (rotatedFace != CollisionType.None)
            {
                collisionResult.Destination     = instance;
                collisionResult.NearestDistance = instance.Center;
                collisionResult.Response        = CollisionManager.SolidCollision(normal, instance, origin, destination, impulse, elasticity);
                if (collisionResult.Response != Vector3.Zero)
                {
                    collisionResult.Collided = rotatedFace == CollisionType.AllSides || (rotatedFace == CollisionType.TopNoStraightLedge || rotatedFace == CollisionType.TopOnly) && (invertedGravity ? (double)normal.Y <0.0 : (double)normal.Y> 0.0);
                }
            }
            return(collisionResult);
        }
Exemple #7
0
        public PhysicsManager.WallHuggingResult HugWalls(IPhysicsEntity entity, bool determineBackground, bool postRotation, bool keepInFront)
        {
            Vector3 vector3_1 = FezMath.ForwardVector(this.CameraManager.Viewpoint);

            if (!entity.Background)
            {
                vector3_1 = -vector3_1;
            }
            float num1 = 1.0 / 500.0;

            if (entity is ISimplePhysicsEntity)
            {
                num1 = 1.0 / 16.0;
            }
            PhysicsManager.WallHuggingResult wallHuggingResult = new PhysicsManager.WallHuggingResult();
            Vector3 vector3_2 = new Vector3();

            if (entity.Background && entity.Grounded)
            {
                return(wallHuggingResult);
            }
            foreach (PointCollision pointCollision in entity.CornerCollision)
            {
                TrileInstance trileInstance1 = (TrileInstance)null;
                if (this.IsHuggable(pointCollision.Instances.Surface, entity))
                {
                    FaceOrientation  face           = FaceOrientation.Down;
                    TrileEmplacement traversal      = pointCollision.Instances.Surface.Emplacement.GetTraversal(ref face);
                    TrileInstance    trileInstance2 = this.LevelManager.TrileInstanceAt(ref traversal);
                    if (trileInstance2 != null && trileInstance2.Enabled && trileInstance2.GetRotatedFace(this.CameraManager.VisibleOrientation) != CollisionType.None)
                    {
                        trileInstance1 = pointCollision.Instances.Surface;
                    }
                }
                if (trileInstance1 == null && this.IsHuggable(pointCollision.Instances.Deep, entity))
                {
                    trileInstance1 = pointCollision.Instances.Deep;
                }
                if (trileInstance1 != null && (!(entity is ISimplePhysicsEntity) || trileInstance1.PhysicsState == null || !trileInstance1.PhysicsState.Puppet) && trileInstance1.PhysicsState != entity)
                {
                    Vector3 vector3_3 = trileInstance1.Center + vector3_1 * trileInstance1.TransformedSize / 2f;
                    Vector3 vector1   = entity.Center - vector3_1 * entity.Size / 2f - vector3_3 + num1 * -vector3_1;
                    float   x         = Vector3.Dot(vector1, vector3_1);
                    if ((double)FezMath.AlmostClamp(x) < 0.0)
                    {
                        if (determineBackground && (!trileInstance1.Trile.Thin || trileInstance1.Trile.ForceHugging))
                        {
                            float num2 = Math.Abs(FezMath.Dot(trileInstance1.TransformedSize / 2f + entity.Size / 2f, vector3_1));
                            // ISSUE: explicit reference operation
                            // ISSUE: variable of a reference type
                            PhysicsManager.WallHuggingResult& local = @wallHuggingResult;
                            // ISSUE: explicit reference operation
                            int num3 = (^ local).Behind | (double)Math.Abs(x) > (double)num2 ? 1 : 0;
                            // ISSUE: explicit reference operation
                            (^ local).Behind = num3 != 0;
                        }
                        else if (keepInFront)
                        {
                            Vector3 vector3_4 = vector1 * FezMath.Abs(vector3_1);
                            vector3_2               -= vector3_4;
                            entity.Center           -= vector3_4;
                            wallHuggingResult.Hugged = true;
                        }
                    }
                }
                if (postRotation)
                {
                    Vector3       vector3_3 = FezMath.AsVector(FezMath.VisibleOrientation(this.CameraManager.LastViewpoint));
                    TrileInstance instance  = this.LevelManager.ActualInstanceAt(pointCollision.Point + vector3_2);
                    if (this.IsHuggable(instance, entity))
                    {
                        Vector3 vector3_4 = instance.Center + vector3_3 * FezMath.ZYX(instance.TransformedSize) / 2f;
                        Vector3 vector1   = entity.Center - vector3_3 * entity.Size / 2f - vector3_4 + 1.0 / 500.0 * vector3_3;
                        float   x         = Vector3.Dot(vector1, vector3_3);
                        if ((double)FezMath.AlmostClamp(x) < 0.0 && (double)x > -1.0 && keepInFront)
                        {
                            Vector3 vector3_5 = vector1 * FezMath.Abs(vector3_3);
                            vector3_2               -= vector3_5;
                            entity.Center           -= vector3_5;
                            wallHuggingResult.Hugged = true;
                        }
                    }
                }
            }
            return(wallHuggingResult);
        }
Exemple #8
0
 private void CorrectWallOverlap(bool overcompensate)
 {
     foreach (PointCollision pointCollision in this.PlayerManager.CornerCollision)
     {
         TrileInstance trileInstance = pointCollision.Instances.Deep;
         if (trileInstance != null && trileInstance != this.PlayerManager.CarriedInstance && trileInstance.GetRotatedFace(this.CameraManager.VisibleOrientation) == CollisionType.AllSides)
         {
             Vector3 vector = (pointCollision.Point - trileInstance.Center + FezMath.Sign(this.PlayerManager.Position - pointCollision.Point) * trileInstance.TransformedSize / 2f) * FezMath.SideMask(this.CameraManager.Viewpoint);
             this.PlayerManager.Position -= vector;
             this.PlayerManager.Position -= FezMath.Sign(vector) * (1.0 / 1000.0) * 2f;
             if (!(FezMath.Sign(this.PlayerManager.Velocity) == FezMath.Sign(vector)))
             {
                 break;
             }
             Vector3 vector3_1 = FezMath.Abs(FezMath.Sign(vector));
             this.PlayerManager.Position -= this.PlayerManager.Velocity * vector3_1;
             IPlayerManager playerManager = this.PlayerManager;
             Vector3        vector3_2     = playerManager.Velocity * (Vector3.One - vector3_1);
             playerManager.Velocity = vector3_2;
             break;
         }
     }
 }
Exemple #9
0
        public override void Update(GameTime gameTime)
        {
            if (this.GameState.Loading || this.PlayerManager.Hidden || this.GameState.InCutscene)
            {
                return;
            }
            Vector3 position = this.PlayerManager.Position;

            if (!this.PlayerManager.CanControl)
            {
                this.InputManager.SaveState();
                this.InputManager.Reset();
            }
            if (this.CameraManager.Viewpoint != Viewpoint.Perspective && this.CameraManager.ActionRunning && (!this.GameState.InMenuCube && !this.GameState.Paused) && (this.CameraManager.RequestedViewpoint == Viewpoint.None && !this.GameState.InMap && !this.LevelManager.IsInvalidatingScreen))
            {
                if (ActionTypeExtensions.AllowsLookingDirectionChange(this.PlayerManager.Action) && !FezMath.AlmostEqual(this.InputManager.Movement.X, 0.0f))
                {
                    this.oldLookDir = this.PlayerManager.LookingDirection;
                    this.PlayerManager.LookingDirection = FezMath.DirectionFromMovement(this.InputManager.Movement.X);
                }
                Vector3 velocity = this.PlayerManager.Velocity;
                this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager);
                if (this.PlayerManager.Grounded && this.PlayerManager.Ground.NearLow == null)
                {
                    TrileInstance trileInstance = this.PlayerManager.Ground.FarHigh;
                    Vector3       b             = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection);
                    float         num           = FezMath.Dot(trileInstance.Center - trileInstance.TransformedSize / 2f * b - this.PlayerManager.Center + this.PlayerManager.Size / 2f * b, b);
                    if ((double)num > -0.25)
                    {
                        this.PlayerManager.Position -= Vector3.UnitY * 0.01f * (float)Math.Sign(this.CollisionManager.GravityFactor);
                        if (trileInstance.GetRotatedFace(FezMath.VisibleOrientation(this.CameraManager.Viewpoint)) == CollisionType.AllSides)
                        {
                            this.PlayerManager.Position += num * b;
                            this.PlayerManager.Velocity  = velocity * Vector3.UnitY;
                        }
                        else
                        {
                            this.PlayerManager.Velocity = velocity;
                        }
                        this.PlayerManager.Ground = new MultipleHits <TrileInstance>();
                    }
                }
                this.PlayerManager.RecordRespawnInformation();
                if (!ActionTypeExtensions.HandlesZClamping(this.PlayerManager.Action) && (this.oldLookDir != this.PlayerManager.LookingDirection || this.PlayerManager.LastAction == ActionType.RunTurnAround) && (this.PlayerManager.Action != ActionType.Dropping && this.PlayerManager.Action != ActionType.GrabCornerLedge && (this.PlayerManager.Action != ActionType.SuckedIn && this.PlayerManager.Action != ActionType.CrushVertical)) && this.PlayerManager.Action != ActionType.CrushHorizontal)
                {
                    this.CorrectWallOverlap(false);
                }
            }
            if (this.PlayerManager.CarriedInstance != null && this.PlayerManager.Action != ActionType.Suffering)
            {
                this.PlayerManager.CarriedInstance.Position += this.PlayerManager.Position - position;
                this.LevelManager.UpdateInstance(this.PlayerManager.CarriedInstance);
            }
            if (this.PlayerManager.Grounded)
            {
                this.PlayerManager.IgnoreFreefall = false;
            }
            if (this.PlayerManager.Animation != null && this.lastFrame != this.PlayerManager.Animation.Timing.Frame)
            {
                if (this.PlayerManager.Grounded)
                {
                    SurfaceType surfaceType = this.PlayerManager.Ground.First.Trile.SurfaceType;
                    if (this.PlayerManager.Action == ActionType.Landing && this.PlayerManager.Animation.Timing.Frame == 0)
                    {
                        this.PlaySurfaceHit(surfaceType, false);
                    }
                    else if ((this.PlayerManager.Action == ActionType.PullUpBack || this.PlayerManager.Action == ActionType.PullUpFront || this.PlayerManager.Action == ActionType.PullUpCornerLedge) && this.PlayerManager.Animation.Timing.Frame == 5)
                    {
                        this.PlaySurfaceHit(surfaceType, false);
                    }
                    else if (ActionTypeExtensions.GetAnimationPath(this.PlayerManager.Action) == "Walk")
                    {
                        if (this.PlayerManager.Animation.Timing.Frame == 1 || this.PlayerManager.Animation.Timing.Frame == 4)
                        {
                            if (this.PlayerManager.Action != ActionType.Sliding)
                            {
                                SoundEffectExtensions.EmitAt(this.isLeft ? this.LeftStep : this.RightStep, this.PlayerManager.Position, RandomHelper.Between(-0.100000001490116, 0.100000001490116), RandomHelper.Between(0.899999976158142, 1.0));
                                this.isLeft = !this.isLeft;
                            }
                            this.PlaySurfaceHit(surfaceType, false);
                        }
                    }
                    else if (this.PlayerManager.Action == ActionType.Running)
                    {
                        if (this.PlayerManager.Animation.Timing.Frame == 0 || this.PlayerManager.Animation.Timing.Frame == 3)
                        {
                            this.PlaySurfaceHit(surfaceType, true);
                        }
                    }
                    else if (this.PlayerManager.CarriedInstance != null)
                    {
                        if (ActionTypeExtensions.GetAnimationPath(this.PlayerManager.Action) == "CarryHeavyWalk")
                        {
                            if (this.PlayerManager.Animation.Timing.Frame == 0 || this.PlayerManager.Animation.Timing.Frame == 4)
                            {
                                this.PlaySurfaceHit(surfaceType, true);
                            }
                        }
                        else if (ActionTypeExtensions.GetAnimationPath(this.PlayerManager.Action) == "CarryWalk" && (this.PlayerManager.Animation.Timing.Frame == 3 || this.PlayerManager.Animation.Timing.Frame == 7))
                        {
                            this.PlaySurfaceHit(surfaceType, true);
                        }
                    }
                    else
                    {
                        this.isLeft = false;
                    }
                }
                else
                {
                    this.isLeft = false;
                }
                this.lastFrame = this.PlayerManager.Animation.Timing.Frame;
            }
            if (this.PlayerManager.CanControl)
            {
                return;
            }
            this.InputManager.RecoverState();
        }
Exemple #10
0
        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);
        }
Exemple #11
0
 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;
     }
 }
Exemple #12
0
        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);
                }
            }
        }