Ejemplo n.º 1
0
        protected override bool Act(TimeSpan elapsed)
        {
            if (this.PlayerManager.Action != ActionType.LowerToCornerLedge)
            {
                return(false);
            }
            Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(this.PlayerManager.LookingDirection);
            float   num       = (float)(4.0 * (this.LevelManager.Descending ? -1.0 : 1.0)) / this.CameraManager.PixelsPerTrixel;
            Vector3 vector3_2 = this.PlayerManager.HeldInstance.Center + (vector3_1 + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)) * this.PlayerManager.HeldInstance.TransformedSize / 2f + num * Vector3.UnitY;

            if (!this.CameraManager.StickyCam && !this.CameraManager.Constrained)
            {
                this.CameraManager.Center = Vector3.Lerp(this.camOrigin, vector3_2, this.PlayerManager.Animation.Timing.NormalizedStep);
            }
            this.PlayerManager.Position = this.PlayerManager.HeldInstance.Center + (vector3_1 + Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor)) * this.PlayerManager.HeldInstance.TransformedSize / 2f;
            this.PlayerManager.SplitUpCubeCollectorOffset = (this.playerOrigin - this.PlayerManager.Position) * (1f - this.PlayerManager.Animation.Timing.NormalizedStep);
            if (this.PlayerManager.Animation.Timing.Ended)
            {
                this.PlayerManager.LookingDirection           = FezMath.GetOpposite(this.PlayerManager.LookingDirection);
                this.PlayerManager.SplitUpCubeCollectorOffset = Vector3.Zero;
                this.PlayerManager.Action = ActionType.GrabCornerLedge;
            }
            this.PlayerManager.Animation.Timing.Update(elapsed, 1.25f);
            return(false);
        }
Ejemplo n.º 2
0
 protected override void Begin()
 {
     base.Begin();
     this.PlayerManager.LookingDirection = FezMath.GetOpposite(this.PlayerManager.LookingDirection);
     this.PlayerManager.CarriedInstance  = (TrileInstance)null;
     this.PlayerManager.Action           = ActionType.SuckedIn;
     this.PlayerManager.Ground           = new MultipleHits <TrileInstance>();
     SoundEffectExtensions.EmitAt(this.suckedSound, this.PlayerManager.Position);
 }
Ejemplo n.º 3
0
 public override void Update(GameTime gameTime)
 {
     if (this.rotatedFrom.HasValue && (double)this.CameraManager.ViewTransitionStep >= 0.6)
     {
         int distance = FezMath.GetDistance(this.CameraManager.Viewpoint, this.rotatedFrom.Value);
         if (Math.Abs(distance) % 2 == 0)
         {
             this.PlayerManager.LookingDirection = FezMath.GetOpposite(this.PlayerManager.LookingDirection);
         }
         else
         {
             if (this.PlayerManager.LookingDirection == HorizontalDirection.Right)
             {
                 this.PlayerManager.Action = Math.Sign(distance) > 0 ? ActionType.GrabLedgeBack : ActionType.GrabLedgeFront;
             }
             else
             {
                 this.PlayerManager.Action = Math.Sign(distance) > 0 ? ActionType.GrabLedgeFront : ActionType.GrabLedgeBack;
             }
             if (this.PlayerManager.Action == ActionType.GrabLedgeBack)
             {
                 this.PlayerManager.Position -= this.PlayerManager.Size.Z / 4f * FezMath.ForwardVector(this.CameraManager.Viewpoint);
                 this.CorrectWallOverlap(true);
                 this.PlayerManager.Background = false;
             }
             else
             {
                 this.PlayerManager.Position  += this.PlayerManager.Size.Z / 4f * FezMath.ForwardVector(this.CameraManager.Viewpoint);
                 this.PlayerManager.Background = true;
             }
         }
         this.SyncAnimation(this.IsActionAllowed(this.PlayerManager.Action));
         this.rotatedFrom = new Viewpoint?();
     }
     if (ActionTypeExtensions.IsOnLedge(this.PlayerManager.Action))
     {
         if (this.PlayerManager.HeldInstance == null)
         {
             this.PlayerManager.Action = ActionType.Idle;
         }
         else if (this.PlayerManager.HeldInstance.PhysicsState != null && (double)Math.Abs(FezMath.Dot(this.PlayerManager.HeldInstance.PhysicsState.Velocity, Vector3.One)) > 0.5)
         {
             this.PlayerManager.Velocity     = this.PlayerManager.HeldInstance.PhysicsState.Velocity;
             this.PlayerManager.HeldInstance = (TrileInstance)null;
             this.PlayerManager.Action       = ActionType.Jumping;
         }
     }
     base.Update(gameTime);
 }
Ejemplo n.º 4
0
 private void Initialize()
 {
     this.Trixels       = new HashSet <TrixelEmplacement>();
     this.tangentFace   = FezMath.GetTangent(this.Orientation);
     this.bitangentFace = FezMath.GetBitangent(this.Orientation);
     this.tangentFaces  = new FaceOrientation[4]
     {
         this.tangentFace,
         this.bitangentFace,
         FezMath.GetOpposite(this.tangentFace),
         FezMath.GetOpposite(this.bitangentFace)
     };
     this.normal    = FezMath.AsVector(this.Orientation);
     this.Tangent   = FezMath.AsVector(this.tangentFace);
     this.Bitangent = FezMath.AsVector(this.bitangentFace);
 }
Ejemplo n.º 5
0
 protected override bool Act(TimeSpan elapsed)
 {
     if (this.PlayerManager.Action == ActionType.RunTurnAround)
     {
         if (Math.Sign(this.InputManager.Movement.X) != this.initialMovement)
         {
             this.PlayerManager.LookingDirection = FezMath.GetOpposite(this.PlayerManager.LookingDirection);
             this.PlayerManager.Action           = ActionType.Idle;
             return(false);
         }
         else if (this.PlayerManager.Animation.Timing.Ended)
         {
             this.PlayerManager.LookingDirection = FezMath.GetOpposite(this.PlayerManager.LookingDirection);
             this.PlayerManager.Action           = ActionType.Running;
             return(false);
         }
         else
         {
             this.PlayerManager.Animation.Timing.Update(elapsed, (float)((1.0 + (double)Math.Abs(this.CollisionManager.GravityFactor)) / 2.0));
         }
     }
     else if (this.PlayerManager.Action != ActionType.Landing)
     {
         float num;
         if (WalkRun.MovementHelper.Running)
         {
             bool flag = this.PlayerManager.Action == ActionType.Walking;
             this.PlayerManager.Action = ActionType.Running;
             this.SyncAnimation(true);
             if (flag)
             {
                 this.PlayerManager.Animation.Timing.Frame = 1;
             }
             num = 1.25f;
         }
         else
         {
             this.PlayerManager.Action = ActionType.Walking;
             num = Easing.EaseOut((double)Math.Min(1f, Math.Abs(this.InputManager.Movement.X) * 2f), EasingType.Cubic);
         }
         this.PlayerManager.Animation.Timing.Update(elapsed, (float)((double)num * (1.0 + (double)Math.Abs(this.CollisionManager.GravityFactor)) / 2.0));
     }
     WalkRun.MovementHelper.Update((float)elapsed.TotalSeconds);
     return(false);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 7
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);
     }
 }
Ejemplo n.º 8
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;
     }
 }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
 private void Turn()
 {
     this.LookingDirection = FezMath.GetOpposite(this.LookingDirection);
     this.UpdateRotation();
     this.CurrentAction = this.CanWalk ? NpcAction.Walk : NpcAction.Idle;
 }
Ejemplo n.º 11
0
 protected override void Begin()
 {
     base.Begin();
     if (!this.PlayerManager.CanControl)
     {
         return;
     }
     if (this.PlayerManager.HeldInstance != null)
     {
         this.PlayerManager.HeldInstance = (TrileInstance)null;
         this.PlayerManager.Action       = ActionType.Idle;
         this.PlayerManager.Action       = ActionType.Suffering;
     }
     this.PlayerManager.CarriedInstance = (TrileInstance)null;
     if (!this.causedByHurtActor)
     {
         this.PlayerManager.Velocity = Vector3.Zero;
     }
     else
     {
         this.PlayerManager.Velocity = 1.0 / 16.0 * (FezMath.RightVector(this.CameraManager.Viewpoint) * (float)FezMath.Sign(FezMath.GetOpposite(this.PlayerManager.LookingDirection)) + Vector3.UnitY);
     }
 }
Ejemplo n.º 12
0
        public void Fill(MapTree.TreeFillContext context, MapNode parent, FaceOrientation origin)
        {
            if (this.Valid)
            {
                return;
            }
            TrileSet trileSet = (TrileSet)null;
            Level    level;

            try
            {
                level = SdlSerializer.Deserialize <Level>(context.ContentRoot + "\\Levels\\" + this.LevelName + ".lvl.sdl");
                if (level.TrileSetName != null)
                {
                    if (!context.TrileSetCache.TryGetValue(level.TrileSetName, out trileSet))
                    {
                        context.TrileSetCache.Add(level.TrileSetName, trileSet = SdlSerializer.Deserialize <TrileSet>(context.ContentRoot + "\\Trile Sets\\" + level.TrileSetName + ".ts.sdl"));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Warning : Level " + this.LevelName + " could not be loaded because it has invalid markup. Skipping...");
                this.Valid = false;
                return;
            }
            this.NodeType = level.NodeType;
            this.Conditions.ChestCount   = Enumerable.Count <ArtObjectInstance>((IEnumerable <ArtObjectInstance>)level.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x => x.ArtObjectName.IndexOf("treasure", StringComparison.InvariantCultureIgnoreCase) != -1)) / 2;
            this.Conditions.ScriptIds    = Enumerable.ToList <int>(Enumerable.Select <Script, int>(Enumerable.Where <Script>((IEnumerable <Script>)level.Scripts.Values, (Func <Script, bool>)(x => x.IsWinCondition)), (Func <Script, int>)(x => x.Id)));
            this.Conditions.SplitUpCount = Enumerable.Count <TrileInstance>(Enumerable.Union <TrileInstance>((IEnumerable <TrileInstance>)level.Triles.Values, Enumerable.SelectMany <TrileInstance, TrileInstance>(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>)level.Triles.Values, (Func <TrileInstance, bool>)(x => x.Overlaps)), (Func <TrileInstance, IEnumerable <TrileInstance> >)(x => (IEnumerable <TrileInstance>)x.OverlappedTriles))), (Func <TrileInstance, bool>)(x =>
            {
                if (x.TrileId >= 0)
                {
                    return(trileSet[x.TrileId].ActorSettings.Type == ActorType.GoldenCube);
                }
                else
                {
                    return(false);
                }
            }));
            this.Conditions.CubeShardCount = Enumerable.Count <TrileInstance>((IEnumerable <TrileInstance>)level.Triles.Values, (Func <TrileInstance, bool>)(x =>
            {
                if (x.TrileId >= 0)
                {
                    return(trileSet[x.TrileId].ActorSettings.Type == ActorType.CubeShard);
                }
                else
                {
                    return(false);
                }
            }));
            this.Conditions.OtherCollectibleCount = Enumerable.Count <TrileInstance>((IEnumerable <TrileInstance>)level.Triles.Values, (Func <TrileInstance, bool>)(x =>
            {
                if (x.TrileId >= 0 && ActorTypeExtensions.IsTreasure(trileSet[x.TrileId].ActorSettings.Type))
                {
                    return(trileSet[x.TrileId].ActorSettings.Type != ActorType.CubeShard);
                }
                else
                {
                    return(false);
                }
            })) + Enumerable.Count <ArtObjectInstance>((IEnumerable <ArtObjectInstance>)level.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x => x.ArtObjectName == "treasure_mapAO"));
            this.Conditions.LockedDoorCount = Enumerable.Count <TrileInstance>((IEnumerable <TrileInstance>)level.Triles.Values, (Func <TrileInstance, bool>)(x =>
            {
                if (x.TrileId >= 0)
                {
                    return(trileSet[x.TrileId].ActorSettings.Type == ActorType.Door);
                }
                else
                {
                    return(false);
                }
            }));
            this.Conditions.UnlockedDoorCount = Enumerable.Count <TrileInstance>((IEnumerable <TrileInstance>)level.Triles.Values, (Func <TrileInstance, bool>)(x =>
            {
                if (x.TrileId >= 0)
                {
                    return(trileSet[x.TrileId].ActorSettings.Type == ActorType.UnlockedDoor);
                }
                else
                {
                    return(false);
                }
            }));
            int num1 = Enumerable.Count <KeyValuePair <int, ArtObjectInstance> >((IEnumerable <KeyValuePair <int, ArtObjectInstance> >)level.ArtObjects, (Func <KeyValuePair <int, ArtObjectInstance>, bool>)(x => x.Value.ArtObjectName.IndexOf("fork", StringComparison.InvariantCultureIgnoreCase) != -1));
            int num2 = Enumerable.Count <KeyValuePair <int, ArtObjectInstance> >((IEnumerable <KeyValuePair <int, ArtObjectInstance> >)level.ArtObjects, (Func <KeyValuePair <int, ArtObjectInstance>, bool>)(x => x.Value.ArtObjectName.IndexOf("qr", StringComparison.InvariantCultureIgnoreCase) != -1));
            int num3 = Enumerable.Count <KeyValuePair <int, Volume> >((IEnumerable <KeyValuePair <int, Volume> >)level.Volumes, (Func <KeyValuePair <int, Volume>, bool>)(x =>
            {
                if (x.Value.ActorSettings != null && x.Value.ActorSettings.CodePattern != null)
                {
                    return(x.Value.ActorSettings.CodePattern.Length > 0);
                }
                else
                {
                    return(false);
                }
            }));
            int num4 = this.LevelName == "OWL" ? 0 : Enumerable.Count <KeyValuePair <int, NpcInstance> >((IEnumerable <KeyValuePair <int, NpcInstance> >)level.NonPlayerCharacters, (Func <KeyValuePair <int, NpcInstance>, bool>)(x => x.Value.Name == "Owl"));
            int num5 = Enumerable.Count <KeyValuePair <int, ArtObjectInstance> >((IEnumerable <KeyValuePair <int, ArtObjectInstance> >)level.ArtObjects, (Func <KeyValuePair <int, ArtObjectInstance>, bool>)(x =>
            {
                if (x.Value.ArtObjectName.Contains("BIT_DOOR"))
                {
                    return(!x.Value.ArtObjectName.Contains("BROKEN"));
                }
                else
                {
                    return(false);
                }
            }));
            int num6 = Enumerable.Count <Script>((IEnumerable <Script>)level.Scripts.Values, (Func <Script, bool>)(s => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a =>
            {
                if (a.Object.Type == "Level")
                {
                    return(a.Operation == "ResolvePuzzle");
                }
                else
                {
                    return(false);
                }
            }))));
            int num7 = Enumerable.Contains <string>((IEnumerable <string>)MapNode.PuzzleLevels, this.LevelName) ? (this.LevelName == "CLOCK" ? 4 : 1) : 0;

            this.Conditions.SecretCount = num1 + num2 + num3 + num4 + num6 + num7 + num5;
            this.HasLesserGate          = Enumerable.Any <ArtObjectInstance>((IEnumerable <ArtObjectInstance>)level.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x =>
            {
                if (x.ArtObjectName.IndexOf("lesser_gate", StringComparison.InvariantCultureIgnoreCase) != -1)
                {
                    return(x.ArtObjectName.IndexOf("base", StringComparison.InvariantCultureIgnoreCase) == -1);
                }
                else
                {
                    return(false);
                }
            }));
            this.HasWarpGate = Enumerable.Any <ArtObjectInstance>((IEnumerable <ArtObjectInstance>)level.ArtObjects.Values, (Func <ArtObjectInstance, bool>)(x =>
            {
                if (!(x.ArtObjectName == "GATE_GRAVEAO") && !(x.ArtObjectName == "GATEAO") && (!(x.ArtObjectName == "GATE_INDUSTRIALAO") && !(x.ArtObjectName == "GATE_SEWERAO")) && !(x.ArtObjectName == "ZU_GATEAO"))
                {
                    return(x.ArtObjectName == "GRAVE_GATEAO");
                }
                else
                {
                    return(true);
                }
            }));
            foreach (Script script in level.Scripts.Values)
            {
                foreach (ScriptAction scriptAction in script.Actions)
                {
                    if (scriptAction.Object.Type == "Level" && scriptAction.Operation.Contains("Level"))
                    {
                        MapNode.Connection connection = new MapNode.Connection();
                        bool flag = true;
                        foreach (ScriptTrigger scriptTrigger in script.Triggers)
                        {
                            if (scriptTrigger.Object.Type == "Volume" && scriptTrigger.Event == "Enter" && scriptTrigger.Object.Identifier.HasValue)
                            {
                                int    key = scriptTrigger.Object.Identifier.Value;
                                Volume volume;
                                if (!level.Volumes.TryGetValue(key, out volume))
                                {
                                    Console.WriteLine("Warning : A level-changing script links to a nonexistent volume in " + (object)this.LevelName + " (Volume Id #" + (string)(object)key + ")");
                                    flag = false;
                                    break;
                                }
                                else if (volume.ActorSettings != null && volume.ActorSettings.IsSecretPassage)
                                {
                                    flag = false;
                                    break;
                                }
                                else
                                {
                                    connection.Face = Enumerable.First <FaceOrientation>((IEnumerable <FaceOrientation>)volume.Orientations);
                                    break;
                                }
                            }
                        }
                        if (flag)
                        {
                            string key = scriptAction.Operation == "ReturnToLastLevel" ? parent.LevelName : scriptAction.Arguments[0];
                            if (!(key == "PYRAMID") && !(key == "CABIN_INTERIOR_A") && (!(key == "THRONE") || !(this.LevelName == "ZU_CITY_RUINS")) && (!(key == "ZU_CITY_RUINS") || !(this.LevelName == "THRONE")))
                            {
                                MapNode mapNode;
                                if (!context.LoadedNodes.TryGetValue(key, out mapNode))
                                {
                                    mapNode = new MapNode()
                                    {
                                        LevelName = key
                                    };
                                    context.LoadedNodes.Add(key, mapNode);
                                    connection.Node = mapNode;
                                    if (connection.Node != parent)
                                    {
                                        if (parent != null && origin == connection.Face)
                                        {
                                            connection.Face = FezMath.GetOpposite(origin);
                                        }
                                        if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.UpLevels, key))
                                        {
                                            connection.Face = FaceOrientation.Top;
                                        }
                                        else if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.DownLevels, key))
                                        {
                                            connection.Face = FaceOrientation.Down;
                                        }
                                        else if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.OppositeLevels, key))
                                        {
                                            connection.Face = FezMath.GetOpposite(connection.Face);
                                        }
                                        else if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.BackLevels, key))
                                        {
                                            connection.Face = FaceOrientation.Back;
                                        }
                                        else if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.LeftLevels, key))
                                        {
                                            connection.Face = FaceOrientation.Left;
                                        }
                                        else if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.RightLevels, key))
                                        {
                                            connection.Face = FaceOrientation.Right;
                                        }
                                        else if (Enumerable.Contains <string>((IEnumerable <string>)MapNode.FrontLevels, key))
                                        {
                                            connection.Face = FaceOrientation.Front;
                                        }
                                        float num8;
                                        if (MapNode.OversizeLinks.TryGetValue(key, out num8))
                                        {
                                            connection.BranchOversize = num8;
                                        }
                                        this.Connections.Add(connection);
                                        break;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            this.Valid = true;
            foreach (MapNode.Connection connection in this.Connections)
            {
                connection.Node.Fill(context, this, connection.Face);
            }
        }
Ejemplo n.º 13
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);
                }
            }
        }
Ejemplo n.º 14
0
        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);
            }
        }
Ejemplo n.º 15
0
        public bool Update(ISimplePhysicsEntity entity, bool simple, bool keepInFront)
        {
            QueryOptions queryOptions = QueryOptions.None;

            if (entity.Background)
            {
                queryOptions |= QueryOptions.Background;
            }
            if (simple)
            {
                queryOptions |= QueryOptions.Simple;
            }
            if (entity is InstancePhysicsState)
            {
                (entity as InstancePhysicsState).UpdatingPhysics = true;
            }
            if (!simple)
            {
                this.MoveAlongWithGround((IPhysicsEntity)entity, queryOptions);
            }
            Vector3?clampToGroundDistance = new Vector3?();
            bool    grounded = entity.Grounded;
            MultipleHits <CollisionResult> horizontalResults;
            MultipleHits <CollisionResult> verticalResults;

            if (!entity.IgnoreCollision)
            {
                this.CollisionManager.CollideRectangle(entity.Center, entity.Velocity, entity.Size, queryOptions, entity.Elasticity, out horizontalResults, out verticalResults);
                bool            flag            = (double)this.CollisionManager.GravityFactor < 0.0;
                FaceOrientation faceOrientation = this.CameraManager.VisibleOrientation;
                if (entity.Background)
                {
                    faceOrientation = FezMath.GetOpposite(faceOrientation);
                }
                if ((flag ? ((double)entity.Velocity.Y > 0.0 ? 1 : 0) : ((double)entity.Velocity.Y < 0.0 ? 1 : 0)) != 0 && BoxCollisionResultExtensions.AnyCollided(verticalResults))
                {
                    MultipleHits <TrileInstance> ground = entity.Ground;
                    CollisionResult collisionResult1    = verticalResults.NearLow;
                    CollisionResult collisionResult2    = verticalResults.FarHigh;
                    if (collisionResult2.Destination != null && collisionResult2.Destination.GetRotatedFace(faceOrientation) != CollisionType.None)
                    {
                        ground.FarHigh = collisionResult2.Destination;
                        if (collisionResult2.Collided && collisionResult2.ShouldBeClamped)
                        {
                            clampToGroundDistance = new Vector3?(collisionResult2.NearestDistance);
                        }
                    }
                    else
                    {
                        ground.FarHigh = (TrileInstance)null;
                    }
                    if (collisionResult1.Destination != null && collisionResult1.Destination.GetRotatedFace(faceOrientation) != CollisionType.None)
                    {
                        ground.NearLow = collisionResult1.Destination;
                        if (collisionResult1.Collided && collisionResult1.ShouldBeClamped)
                        {
                            clampToGroundDistance = new Vector3?(collisionResult1.NearestDistance);
                        }
                    }
                    else
                    {
                        ground.NearLow = (TrileInstance)null;
                    }
                    entity.Ground = ground;
                }
                else
                {
                    entity.Ground = new MultipleHits <TrileInstance>();
                }
            }
            else
            {
                horizontalResults = new MultipleHits <CollisionResult>();
                verticalResults   = new MultipleHits <CollisionResult>();
            }
            bool flag1 = this.UpdateInternal((IPhysicsEntity)entity, horizontalResults, verticalResults, clampToGroundDistance, grounded, keepInFront, false, simple);

            if (entity is InstancePhysicsState)
            {
                (entity as InstancePhysicsState).UpdatingPhysics = false;
            }
            return(flag1);
        }
Ejemplo n.º 16
0
        protected override bool Act(TimeSpan elapsed)
        {
            float num1  = FezMath.Saturate(Math.Abs(3f / (float)this.PlayerManager.Animation.Timing.EndFrame - this.PlayerManager.Animation.Timing.Step)) * 2f;
            int   frame = this.PlayerManager.Animation.Timing.Frame;

            if (this.lastFrame != frame)
            {
                if (frame == 2)
                {
                    SoundEffectExtensions.EmitAt(this.shimmySound, this.PlayerManager.Position);
                }
                this.lastFrame = frame;
            }
            TrileInstance heldInstance = this.PlayerManager.HeldInstance;

            this.PlayerManager.HeldInstance = this.PlayerManager.AxisCollision[VerticalDirection.Down].Deep;
            bool    flag1 = this.PlayerManager.HeldInstance == null;
            Vector3 b     = FezMath.ForwardVector(this.CameraManager.Viewpoint) * (this.PlayerManager.Background ? -1f : 1f);
            bool    flag2 = this.PlayerManager.HeldInstance != null && this.PlayerManager.HeldInstance.GetRotatedFace(FezMath.VisibleOrientation(this.CameraManager.Viewpoint)) == CollisionType.None;

            if (flag1 || flag2 && (double)FezMath.Dot(this.PlayerManager.HeldInstance.Position, b) > (double)FezMath.Dot(heldInstance.Position, b))
            {
                this.PlayerManager.Action           = ActionTypeExtensions.FacesBack(this.PlayerManager.Action) ? ActionType.ToCornerBack : ActionType.ToCornerFront;
                this.PlayerManager.HeldInstance     = heldInstance;
                this.PlayerManager.LookingDirection = FezMath.GetOpposite(this.PlayerManager.LookingDirection);
                return(false);
            }
            else if (flag2)
            {
                this.PlayerManager.Action       = ActionType.Dropping;
                this.PlayerManager.HeldInstance = (TrileInstance)null;
                return(false);
            }
            else
            {
                float num2 = (float)((double)this.InputManager.Movement.X * 4.69999980926514 * 0.150000005960464) * (float)elapsed.TotalSeconds;
                if (this.PlayerManager.Action != ActionType.ShimmyBack && this.PlayerManager.Action != ActionType.ShimmyFront)
                {
                    num2 *= 0.6f;
                }
                this.PlayerManager.Velocity = num2 * FezMath.RightVector(this.CameraManager.Viewpoint) * (1f + num1);
                if ((double)this.InputManager.Movement.X == 0.0)
                {
                    this.PlayerManager.Action = ActionTypeExtensions.FacesBack(this.PlayerManager.Action) ? ActionType.GrabLedgeBack : ActionType.GrabLedgeFront;
                }
                else
                {
                    this.PlayerManager.GroundedVelocity = new Vector3?(this.PlayerManager.Velocity);
                }
                if (this.InputManager.RotateLeft == FezButtonState.Pressed || this.InputManager.RotateRight == FezButtonState.Pressed)
                {
                    this.PlayerManager.Action = ActionTypeExtensions.FacesBack(this.PlayerManager.Action) ? ActionType.GrabLedgeBack : ActionType.GrabLedgeFront;
                }
                if (this.PlayerManager.Action == ActionType.ShimmyBack || this.PlayerManager.Action == ActionType.ShimmyFront)
                {
                    this.PlayerManager.Animation.Timing.Update(elapsed, Math.Abs(this.InputManager.Movement.X));
                    if (this.PlayerManager.HeldInstance.PhysicsState != null)
                    {
                        this.PlayerManager.Position += this.PlayerManager.HeldInstance.PhysicsState.Velocity;
                    }
                }
                Vector3 vector3 = FezMath.DepthMask(this.CameraManager.Viewpoint);
                this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + this.PlayerManager.HeldInstance.Center * vector3 + b * -(this.PlayerManager.HeldInstance.TransformedSize / 2f + this.PlayerManager.Size.X * vector3 / 4f);
                this.PhysicsManager.HugWalls((IPhysicsEntity)this.PlayerManager, false, false, true);
                return(false);
            }
        }
Ejemplo n.º 17
0
        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;
                                }
                            }
                        }
                    }
                }
            }
        }