Exemplo n.º 1
0
 public void DetermineInBackground(IPhysicsEntity entity, bool allowEnterInBackground, bool postRotation, bool keepInFront)
 {
     if (allowEnterInBackground)
     {
         if (entity is IComplexPhysicsEntity)
         {
             IComplexPhysicsEntity complexPhysicsEntity = entity as IComplexPhysicsEntity;
             Vector3      impulse = 1.0 / 32.0 * Vector3.Down;
             QueryOptions options = QueryOptions.None;
             if (complexPhysicsEntity.Background)
             {
                 options |= QueryOptions.Background;
             }
             bool flag = BoxCollisionResultExtensions.AnyHit(this.CollisionManager.CollideEdge(entity.Center, impulse, entity.Size / 2f, Direction2D.Vertical, options));
             if (!flag)
             {
                 flag = flag | BoxCollisionResultExtensions.AnyHit(this.CollisionManager.CollideEdge(entity.Center, impulse, entity.Size / 2f, Direction2D.Vertical, options, 0.0f, FezMath.GetOpposite(this.CameraManager.Viewpoint)));
             }
             if (complexPhysicsEntity.Grounded && !flag)
             {
                 this.DebuggingBag.Add("zz. had to re-clamp to ground", (object)"POSITIF");
                 MultipleHits <CollisionResult> result = this.CollisionManager.CollideEdge(entity.Center, impulse, entity.Size / 2f, Direction2D.Vertical, options, 0.0f, this.CameraManager.LastViewpoint);
                 if (BoxCollisionResultExtensions.AnyCollided(result))
                 {
                     this.ClampToGround(entity, new Vector3?(BoxCollisionResultExtensions.First(result).NearestDistance), this.CameraManager.LastViewpoint);
                 }
             }
         }
         entity.Background = false;
         PhysicsManager.WallHuggingResult wallHuggingResult;
         do
         {
             this.DetermineOverlapsInternal(entity, this.CameraManager.Viewpoint);
             wallHuggingResult = this.HugWalls(entity, true, postRotation, keepInFront);
         }while (wallHuggingResult.Hugged);
         entity.Background = wallHuggingResult.Behind;
         this.DetermineOverlapsInternal(entity, this.CameraManager.Viewpoint);
         this.HugWalls(entity, false, false, keepInFront);
     }
     else
     {
         if (!entity.Background)
         {
             return;
         }
         bool flag = true;
         foreach (PointCollision pointCollision in entity.CornerCollision)
         {
             flag = flag & !this.IsHuggable(pointCollision.Instances.Deep, entity);
         }
         if (!flag)
         {
             return;
         }
         entity.Background = false;
     }
 }
Exemplo n.º 2
0
 public void DetermineOverlaps(IComplexPhysicsEntity entity)
 {
   this.DetermineOverlapsInternal((IPhysicsEntity) entity, this.CameraManager.Viewpoint);
   Vector3 center = entity.Center;
   Vector3 vector3 = entity.Size / 2f - new Vector3(1.0 / 1000.0);
   if ((double) this.CollisionManager.GravityFactor < 0.0)
     vector3 *= new Vector3(1f, -1f, 1f);
   QueryOptions options = entity.Background ? QueryOptions.Background : QueryOptions.None;
   entity.AxisCollision[VerticalDirection.Up] = this.LevelManager.NearestTrile(center + vector3 * Vector3.Up, options);
   entity.AxisCollision[VerticalDirection.Down] = this.LevelManager.NearestTrile(center + vector3 * Vector3.Down, options);
 }
Exemplo n.º 3
0
        public void DetermineOverlaps(IComplexPhysicsEntity entity)
        {
            this.DetermineOverlapsInternal((IPhysicsEntity)entity, this.CameraManager.Viewpoint);
            Vector3 center  = entity.Center;
            Vector3 vector3 = entity.Size / 2f - new Vector3(1.0 / 1000.0);

            if ((double)this.CollisionManager.GravityFactor < 0.0)
            {
                vector3 *= new Vector3(1f, -1f, 1f);
            }
            QueryOptions options = entity.Background ? QueryOptions.Background : QueryOptions.None;

            entity.AxisCollision[VerticalDirection.Up]   = this.LevelManager.NearestTrile(center + vector3 * Vector3.Up, options);
            entity.AxisCollision[VerticalDirection.Down] = this.LevelManager.NearestTrile(center + vector3 * Vector3.Down, options);
        }
Exemplo n.º 4
0
        public bool Update(IComplexPhysicsEntity entity)
        {
            QueryOptions queryOptions = QueryOptions.None;

            if (entity.Background)
            {
                queryOptions |= QueryOptions.Background;
            }
            this.MoveAlongWithGround((IPhysicsEntity)entity, queryOptions);
            MultipleHits <CollisionResult> horizontalResults;
            MultipleHits <CollisionResult> verticalResults;

            this.CollisionManager.CollideRectangle(entity.Center, entity.Velocity, entity.Size, queryOptions, entity.Elasticity, out horizontalResults, out verticalResults);
            bool grounded = entity.Grounded;
            MultipleHits <TrileInstance> ground1  = entity.Ground;
            Vector3?        clampToGroundDistance = new Vector3?();
            FaceOrientation visibleOrientation    = this.CameraManager.VisibleOrientation;
            bool            flag1 = (double)this.CollisionManager.GravityFactor < 0.0;

            if (BoxCollisionResultExtensions.AnyCollided(verticalResults) && (flag1 ? ((double)entity.Velocity.Y > 0.0 ? 1 : 0) : ((double)entity.Velocity.Y < 0.0 ? 1 : 0)) != 0)
            {
                MultipleHits <TrileInstance> ground2 = entity.Ground;
                CollisionResult collisionResult1     = verticalResults.NearLow;
                CollisionResult collisionResult2     = verticalResults.FarHigh;
                if (collisionResult2.Destination != null && collisionResult2.Destination.GetRotatedFace(visibleOrientation) != CollisionType.None)
                {
                    ground2.FarHigh = collisionResult2.Destination;
                    if (collisionResult2.Collided && (collisionResult2.ShouldBeClamped || entity.MustBeClampedToGround))
                    {
                        clampToGroundDistance = new Vector3?(collisionResult2.NearestDistance);
                    }
                }
                else
                {
                    ground2.FarHigh = (TrileInstance)null;
                }
                if (collisionResult1.Destination != null && collisionResult1.Destination.GetRotatedFace(visibleOrientation) != CollisionType.None)
                {
                    ground2.NearLow = collisionResult1.Destination;
                    if (collisionResult1.Collided && (collisionResult1.ShouldBeClamped || entity.MustBeClampedToGround))
                    {
                        clampToGroundDistance = new Vector3?(collisionResult1.NearestDistance);
                    }
                }
                else
                {
                    ground2.NearLow = (TrileInstance)null;
                }
                entity.Ground = ground2;
            }
            else
            {
                entity.Ground = new MultipleHits <TrileInstance>();
            }
            entity.Ceiling = (double)entity.Velocity.Y <= 0.0 || !BoxCollisionResultExtensions.AnyCollided(verticalResults) ? new MultipleHits <CollisionResult>() : verticalResults;
            bool flag2 = (this.PlayerManager.Action == ActionType.Grabbing || this.PlayerManager.Action == ActionType.Pushing || (this.PlayerManager.Action == ActionType.GrabCornerLedge || this.PlayerManager.Action == ActionType.LowerToCornerLedge) || this.PlayerManager.Action == ActionType.SuckedIn || this.PlayerManager.Action == ActionType.Landing) | entity.MustBeClampedToGround;

            entity.MustBeClampedToGround = false;
            bool velocityIrrelevant = ((flag2 ? 1 : 0) | (!entity.Grounded ? 0 : (entity.Ground.First.ForceClampToGround ? 1 : 0))) != 0;

            if (grounded && !entity.Grounded)
            {
                entity.GroundedVelocity = new Vector3?(entity.Velocity);
            }
            else if (!grounded && entity.Grounded)
            {
                entity.GroundedVelocity = new Vector3?();
            }
            Vector3 vector2 = FezMath.RightVector(this.CameraManager.Viewpoint);

            entity.MovingDirection = FezMath.DirectionFromMovement(Vector3.Dot(entity.Velocity, vector2));
            bool flag3 = this.PlayerManager.Action == ActionType.FrontClimbingLadder || this.PlayerManager.Action == ActionType.FrontClimbingVine;

            if (entity.GroundMovement != Vector3.Zero || flag3)
            {
                this.DetermineInBackground((IPhysicsEntity)entity, true, false, !this.PlayerManager.Climbing);
            }
            return(this.UpdateInternal((IPhysicsEntity)entity, horizontalResults, verticalResults, clampToGroundDistance, grounded, !entity.HandlesZClamping, velocityIrrelevant, false));
        }
Exemplo n.º 5
0
 public bool Update(IComplexPhysicsEntity entity)
 {
   QueryOptions queryOptions = QueryOptions.None;
   if (entity.Background)
     queryOptions |= QueryOptions.Background;
   this.MoveAlongWithGround((IPhysicsEntity) entity, queryOptions);
   MultipleHits<CollisionResult> horizontalResults;
   MultipleHits<CollisionResult> verticalResults;
   this.CollisionManager.CollideRectangle(entity.Center, entity.Velocity, entity.Size, queryOptions, entity.Elasticity, out horizontalResults, out verticalResults);
   bool grounded = entity.Grounded;
   MultipleHits<TrileInstance> ground1 = entity.Ground;
   Vector3? clampToGroundDistance = new Vector3?();
   FaceOrientation visibleOrientation = this.CameraManager.VisibleOrientation;
   bool flag1 = (double) this.CollisionManager.GravityFactor < 0.0;
   if (BoxCollisionResultExtensions.AnyCollided(verticalResults) && (flag1 ? ((double) entity.Velocity.Y > 0.0 ? 1 : 0) : ((double) entity.Velocity.Y < 0.0 ? 1 : 0)) != 0)
   {
     MultipleHits<TrileInstance> ground2 = entity.Ground;
     CollisionResult collisionResult1 = verticalResults.NearLow;
     CollisionResult collisionResult2 = verticalResults.FarHigh;
     if (collisionResult2.Destination != null && collisionResult2.Destination.GetRotatedFace(visibleOrientation) != CollisionType.None)
     {
       ground2.FarHigh = collisionResult2.Destination;
       if (collisionResult2.Collided && (collisionResult2.ShouldBeClamped || entity.MustBeClampedToGround))
         clampToGroundDistance = new Vector3?(collisionResult2.NearestDistance);
     }
     else
       ground2.FarHigh = (TrileInstance) null;
     if (collisionResult1.Destination != null && collisionResult1.Destination.GetRotatedFace(visibleOrientation) != CollisionType.None)
     {
       ground2.NearLow = collisionResult1.Destination;
       if (collisionResult1.Collided && (collisionResult1.ShouldBeClamped || entity.MustBeClampedToGround))
         clampToGroundDistance = new Vector3?(collisionResult1.NearestDistance);
     }
     else
       ground2.NearLow = (TrileInstance) null;
     entity.Ground = ground2;
   }
   else
     entity.Ground = new MultipleHits<TrileInstance>();
   entity.Ceiling = (double) entity.Velocity.Y <= 0.0 || !BoxCollisionResultExtensions.AnyCollided(verticalResults) ? new MultipleHits<CollisionResult>() : verticalResults;
   bool flag2 = (this.PlayerManager.Action == ActionType.Grabbing || this.PlayerManager.Action == ActionType.Pushing || (this.PlayerManager.Action == ActionType.GrabCornerLedge || this.PlayerManager.Action == ActionType.LowerToCornerLedge) || this.PlayerManager.Action == ActionType.SuckedIn || this.PlayerManager.Action == ActionType.Landing) | entity.MustBeClampedToGround;
   entity.MustBeClampedToGround = false;
   bool velocityIrrelevant = ((flag2 ? 1 : 0) | (!entity.Grounded ? 0 : (entity.Ground.First.ForceClampToGround ? 1 : 0))) != 0;
   if (grounded && !entity.Grounded)
     entity.GroundedVelocity = new Vector3?(entity.Velocity);
   else if (!grounded && entity.Grounded)
     entity.GroundedVelocity = new Vector3?();
   Vector3 vector2 = FezMath.RightVector(this.CameraManager.Viewpoint);
   entity.MovingDirection = FezMath.DirectionFromMovement(Vector3.Dot(entity.Velocity, vector2));
   bool flag3 = this.PlayerManager.Action == ActionType.FrontClimbingLadder || this.PlayerManager.Action == ActionType.FrontClimbingVine;
   if (entity.GroundMovement != Vector3.Zero || flag3)
     this.DetermineInBackground((IPhysicsEntity) entity, true, false, !this.PlayerManager.Climbing);
   return this.UpdateInternal((IPhysicsEntity) entity, horizontalResults, verticalResults, clampToGroundDistance, grounded, !entity.HandlesZClamping, velocityIrrelevant, false);
 }