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); }
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; }