示例#1
0
        public void AlterTransition(Viewpoint newTo)
        {
            Viewpoint rotatedView = FezMath.GetRotatedView(FezMath.AsViewpoint(FezMath.OrientationFromDirection(this.directionTransition.Points[0])), FezMath.GetDistance(FezMath.AsViewpoint(FezMath.OrientationFromDirection(this.directionTransition.Points[2])), newTo));
            Vector3   from        = this.predefinedViews[rotatedView].Direction;
            Vector3   to          = this.predefinedViews[newTo].Direction;

            this.directionTransition.Points[0] = from;
            this.directionTransition.Points[1] = DefaultCameraManager.GetIntemediateVector(from, to);
            this.directionTransition.Points[2] = to;
            this.current       = this.predefinedViews[newTo];
            this.lastViewpoint = rotatedView;
            this.viewpoint     = newTo;
        }
示例#2
0
        public override void Update(GameTime gameTime)
        {
            if (this.LevelMaterializer.LevelPlanes.Count == 0 || this.EngineState.Paused || (this.EngineState.InMap || this.EngineState.Loading))
            {
                return;
            }
            bool flag     = FezMath.IsOrthographic(this.CameraManager.Viewpoint) && this.CameraManager.ActionRunning;
            bool inEditor = this.EngineState.InEditor;

            foreach (BackgroundPlane backgroundPlane in this.LevelMaterializer.LevelPlanes)
            {
                if (backgroundPlane.Visible || backgroundPlane.ActorType == ActorType.Bomb)
                {
                    if (flag && backgroundPlane.Animated)
                    {
                        int frame = backgroundPlane.Timing.Frame;
                        backgroundPlane.Timing.Update(gameTime.ElapsedGameTime);
                        if (!backgroundPlane.Loop && frame > backgroundPlane.Timing.Frame)
                        {
                            this.LevelManager.BackgroundPlanes.Remove(backgroundPlane.Id);
                            backgroundPlane.Dispose();
                        }
                        else
                        {
                            backgroundPlane.MarkDirty();
                        }
                    }
                    if (backgroundPlane.Billboard)
                    {
                        backgroundPlane.Rotation = this.CameraManager.Rotation * backgroundPlane.OriginalRotation;
                    }
                    if (!inEditor && (double)backgroundPlane.ParallaxFactor != 0.0 && flag)
                    {
                        Viewpoint view = FezMath.AsViewpoint(backgroundPlane.Orientation);
                        if (!backgroundPlane.OriginalPosition.HasValue)
                        {
                            backgroundPlane.OriginalPosition = new Vector3?(backgroundPlane.Position);
                        }
                        float   num     = (float)((double)(-4 * (this.LevelManager.Descending ? -1 : 1)) / (double)this.CameraManager.PixelsPerTrixel - 15.0 / 32.0 + 1.0);
                        Vector3 vector3 = this.CameraManager.InterpolatedCenter - backgroundPlane.OriginalPosition.Value + num * Vector3.UnitY;
                        backgroundPlane.Position = backgroundPlane.OriginalPosition.Value + vector3 * FezMath.ScreenSpaceMask(view) * backgroundPlane.ParallaxFactor;
                    }
                    else if (!inEditor && (double)backgroundPlane.ParallaxFactor != 0.0 && backgroundPlane.OriginalPosition.HasValue && backgroundPlane.Position != backgroundPlane.OriginalPosition.Value)
                    {
                        backgroundPlane.Position = backgroundPlane.OriginalPosition.Value;
                    }
                }
            }
        }
示例#3
0
            public TombstoneState(TombstonesHost host, ArtObjectInstance ao)
            {
                ServiceHelper.InjectServices((object)this);
                this.Host      = host;
                this.ArtObject = ao;
                int num1;

                if (this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num1) && num1 != 0)
                {
                    int num2 = Math.Abs(num1);
                    for (int index = 0; index < num2; ++index)
                    {
                        this.OriginalAoRotation  = this.ArtObject.Rotation;
                        this.ArtObject.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f * (float)Math.Sign(num1));
                    }
                }
                this.LastViewpoint = FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.MaxClampXZ(Vector3.Transform(Vector3.Forward, this.ArtObject.Rotation))));
            }
示例#4
0
        public LongRunningAction FocusCamera(int id, int pixelsPerTrixel, bool immediate)
        {
            string      levelName        = this.LevelManager.Name;
            Volume      volume           = this.LevelManager.Volumes[id];
            BoundingBox boundingBox      = volume.BoundingBox;
            bool        changedViewpoint = volume.Orientations.Count == 1;
            Viewpoint   oldViewpoint     = this.CameraManager.Viewpoint;
            float       oldRadius        = this.CameraManager.Radius;

            this.CameraManager.Constrained = true;
            this.CameraManager.Center      = (boundingBox.Min + boundingBox.Max) / 2f;
            if (pixelsPerTrixel > 0)
            {
                this.CameraManager.PixelsPerTrixel = (float)pixelsPerTrixel;
            }
            if (changedViewpoint)
            {
                this.CameraManager.ChangeViewpoint(FezMath.AsViewpoint(Enumerable.First <FaceOrientation>((IEnumerable <FaceOrientation>)volume.Orientations)));
            }
            this.CameraManager.ConstrainedCenter = this.CameraManager.Center;
            if (!immediate)
            {
                return(new LongRunningAction((Action)(() =>
                {
                    if (this.LevelManager.Name != levelName)
                    {
                        return;
                    }
                    this.CameraManager.Constrained = false;
                    if (pixelsPerTrixel > 0)
                    {
                        this.CameraManager.Radius = oldRadius;
                    }
                    if (!changedViewpoint)
                    {
                        return;
                    }
                    this.CameraManager.ChangeViewpoint(oldViewpoint);
                })));
            }
            this.CameraManager.SnapInterpolation();
            return((LongRunningAction)null);
        }
示例#5
0
        public LongRunningAction FocusWithPan(int id, int pixelsPerTrixel, float verticalPan, float horizontalPan)
        {
            string      levelName        = this.LevelManager.Name;
            Volume      volume           = this.LevelManager.Volumes[id];
            BoundingBox boundingBox      = volume.BoundingBox;
            bool        changedViewpoint = volume.Orientations.Count == 1;
            Viewpoint   oldViewpoint     = this.CameraManager.Viewpoint;
            float       oldRadius        = this.CameraManager.Radius;

            this.CameraManager.Constrained        = true;
            this.CameraManager.Center             = (boundingBox.Min + boundingBox.Max) / 2f;
            this.CameraManager.PanningConstraints = new Vector2?(new Vector2(horizontalPan, verticalPan));
            if (pixelsPerTrixel > 0)
            {
                this.CameraManager.PixelsPerTrixel = (float)pixelsPerTrixel;
            }
            if (changedViewpoint)
            {
                this.CameraManager.ChangeViewpoint(FezMath.AsViewpoint(Enumerable.First <FaceOrientation>((IEnumerable <FaceOrientation>)volume.Orientations)));
            }
            this.CameraManager.ConstrainedCenter = this.CameraManager.Center;
            return(new LongRunningAction((Action)(() =>
            {
                if (this.LevelManager.Name != levelName || levelName == "CRYPT" && this.LevelManager.Name == "CRYPT")
                {
                    return;
                }
                this.CameraManager.Constrained = false;
                this.CameraManager.PanningConstraints = new Vector2?();
                if (pixelsPerTrixel > 0)
                {
                    this.CameraManager.Radius = oldRadius;
                }
                if (!changedViewpoint)
                {
                    return;
                }
                this.CameraManager.ChangeViewpoint(oldViewpoint);
            })));
        }
示例#6
0
        public BitDoorState(ArtObjectInstance artObject)
        {
            ServiceHelper.InjectServices((object)this);
            this.AoInstance = artObject;
            switch (artObject.ArtObject.ActorType)
            {
            case ActorType.FourBitDoor:
            case ActorType.TwoBitDoor:
            case ActorType.SixteenBitDoor:
            case ActorType.EightBitDoor:
            case ActorType.OneBitDoor:
                this.BitTexture     = this.CMProvider.Global.Load <Texture2D>("Other Textures/glow/GLOWBIT");
                this.AntiBitTexture = this.CMProvider.Global.Load <Texture2D>("Other Textures/glow/GLOWBIT_anti");
                break;

            case ActorType.ThirtyTwoBitDoor:
                this.BitTexture     = this.CMProvider.Global.Load <Texture2D>("Other Textures/glow/small_glowbit");
                this.AntiBitTexture = this.CMProvider.Global.Load <Texture2D>("Other Textures/glow/small_glowbit_anti");
                break;

            default:
                this.BitTexture     = this.CMProvider.Global.Load <Texture2D>("Other Textures/glow/code_machine_glowbit");
                this.AntiBitTexture = this.CMProvider.Global.Load <Texture2D>("Other Textures/glow/code_machine_glowbit_anti");
                for (int index = 0; index < 64; ++index)
                {
                    this.SixtyFourOffsets[index] /= 16f;
                }
                break;
            }
            this.RumbleSound       = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/Rumble");
            this.sLightUp          = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Zu/DoorBitLightUp");
            this.sFadeOut          = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Zu/DoorBitFadeOut");
            this.ExpectedViewpoint = FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.MaxClamp(Vector3.Transform(Vector3.UnitZ, this.AoInstance.Rotation))));
            this.lastBits          = 0;
            this.InitBitPlanes();
        }
示例#7
0
        private void CheckForUp()
        {
            if (this.GameState.Loading || this.GameState.InMap || (this.GameState.Paused || !this.CameraManager.ActionRunning) || (!this.PlayerManager.Grounded || this.InputManager.GrabThrow != FezButtonState.Pressed || this.CameraManager.Viewpoint != FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.AlmostClamp(Vector3.Transform(Vector3.Left, this.TelescopeAo.Rotation))))))
            {
                return;
            }
            Vector3 vector3 = Vector3.Transform(this.PlayerManager.Position - this.TelescopeAo.Position, this.TelescopeAo.Rotation);

            if ((double)Math.Abs(vector3.Z) >= 0.5 || (double)Math.Abs(vector3.Y) >= 0.5)
            {
                return;
            }
            this.Visible                  = true;
            this.State                    = TelescopeHost.StateType.In;
            this.BitTimer                 = 0.0f;
            this.MessageIndex             = -3;
            this.Fader                    = TimeSpan.Zero;
            this.NowViewing               = this.CameraManager.Viewpoint;
            this.PlayerManager.CanControl = false;
            this.PlayerManager.Action     = ActionType.ReadTurnAround;
            this.DotManager.Hidden        = true;
            this.DotManager.PreventPoI    = true;
        }
示例#8
0
        private void TryInitialize()
        {
            this.DoorAo           = (ArtObjectInstance)null;
            this.AttachedGroup    = (TrileGroup)null;
            this.AssociatedVolume = (Volume)null;
            this.Enabled          = false;
            this.sRumble          = (SoundEffect)null;
            this.sLightUp         = (SoundEffect)null;
            this.sFadeOut         = (SoundEffect)null;
            if (this.eRumble != null && !this.eRumble.Dead)
            {
                this.eRumble.Cue.Stop(false);
            }
            this.eRumble = (SoundEmitter)null;
            foreach (ArtObjectInstance artObjectInstance in (IEnumerable <ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
            {
                if (artObjectInstance.ArtObject.ActorType == ActorType.SecretPassage)
                {
                    this.DoorAo  = artObjectInstance;
                    this.Enabled = true;
                    break;
                }
            }
            if (!this.Enabled)
            {
                if (this.GlowPlane != null)
                {
                    this.GlowPlane.Dispose();
                }
                this.GlowPlane = (BackgroundPlane)null;
            }
            if (!this.Enabled)
            {
                return;
            }
            this.AttachedGroup    = this.LevelManager.Groups[this.DoorAo.ActorSettings.AttachedGroup.Value];
            this.AssociatedVolume = Enumerable.FirstOrDefault <Volume>((IEnumerable <Volume>) this.LevelManager.Volumes.Values, (Func <Volume, bool>)(x =>
            {
                if (x.ActorSettings != null)
                {
                    return(x.ActorSettings.IsSecretPassage);
                }
                else
                {
                    return(false);
                }
            }));
            string key = (string)null;

            foreach (Script script in (IEnumerable <Script>) this.LevelManager.Scripts.Values)
            {
                foreach (ScriptAction scriptAction in script.Actions)
                {
                    if (scriptAction.Object.Type == "Level" && scriptAction.Operation.Contains("Level"))
                    {
                        foreach (ScriptTrigger scriptTrigger in script.Triggers)
                        {
                            if (scriptTrigger.Object.Type == "Volume" && scriptTrigger.Event == "Enter" && scriptTrigger.Object.Identifier.HasValue)
                            {
                                key = scriptAction.Arguments[0];
                            }
                        }
                    }
                }
            }
            this.Accessible = this.GameState.SaveData.World.ContainsKey(key);
            this.sRumble    = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/MiscActors/Rumble");
            this.sLightUp   = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Zu/DoorBitLightUp");
            this.sFadeOut   = this.CMProvider.CurrentLevel.Load <SoundEffect>("Sounds/Zu/DoorBitFadeOut");
            if (!this.Accessible)
            {
                this.Enabled = false;
            }
            else
            {
                this.GlowPlane = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, (Texture)this.CMProvider.CurrentLevel.Load <Texture2D>("Other Textures/glow/secret_passage"))
                {
                    Fullbright    = true,
                    Opacity       = 0.0f,
                    Position      = this.DoorAo.Position + FezMath.AsVector(Enumerable.First <FaceOrientation>((IEnumerable <FaceOrientation>) this.AssociatedVolume.Orientations)) / (65.0 / 32.0),
                    Rotation      = FezMath.QuaternionFromPhi(FezMath.ToPhi(Enumerable.First <FaceOrientation>((IEnumerable <FaceOrientation>) this.AssociatedVolume.Orientations))),
                    AttachedGroup = new int?(this.AttachedGroup.Id)
                };
                this.LevelManager.AddPlane(this.GlowPlane);
                this.ExpectedViewpoint = FezMath.AsViewpoint(Enumerable.First <FaceOrientation>((IEnumerable <FaceOrientation>) this.AssociatedVolume.Orientations));
                if (!this.LevelManager.WentThroughSecretPassage)
                {
                    return;
                }
                this.MoveUp            = true;
                this.GlowPlane.Opacity = 1f;
                this.SinceStarted      = TimeSpan.Zero;
                this.AoOrigin          = this.DoorAo.Position;
                this.PlaneOrigin       = this.GlowPlane.Position;
            }
        }
示例#9
0
            public void Update(TimeSpan elapsed)
            {
                if (!this.Enabled || this.Path.NeedsTrigger)
                {
                    return;
                }
                if (this.justStarted)
                {
                    this.originalViewpoint       = this.CameraManager.Viewpoint;
                    this.originalCenter          = this.CameraManager.Center;
                    this.originalDirection       = this.CameraManager.Direction;
                    this.originalPixelsPerTrixel = this.CameraManager.PixelsPerTrixel;
                    this.originalRadius          = this.CameraManager.Radius;
                    bool perspective = (this.Nodes[0].CustomData as CameraNodeData).Perspective;
                    if (this.Path.InTransition)
                    {
                        this.nodeIndex = 1;
                        this.Nodes.Insert(0, new PathSegment()
                        {
                            Destination = this.originalCenter,
                            Orientation = Quaternion.Inverse(this.CameraManager.Rotation),
                            CustomData  = (ICloneable) new CameraNodeData()
                            {
                                PixelsPerTrixel = (int)this.originalPixelsPerTrixel,
                                Perspective     = perspective
                            }
                        });
                    }
                    if (this.Path.OutTransition)
                    {
                        this.Nodes.Add(new PathSegment()
                        {
                            Destination = this.originalCenter,
                            Orientation = Quaternion.Inverse(this.CameraManager.Rotation),
                            CustomData  = (ICloneable) new CameraNodeData()
                            {
                                PixelsPerTrixel = (int)this.originalPixelsPerTrixel,
                                Perspective     = perspective
                            }
                        });
                    }
                    if (this.Nodes.Count < 2)
                    {
                        this.EndPath();
                        return;
                    }
                    else
                    {
                        CameraNodeData cameraNodeData = this.Nodes[0].CustomData as CameraNodeData;
                        this.firstNodeViewpoint = FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.MaxClampXZ(Vector3.Transform(Vector3.Forward, this.Nodes[0].Orientation))));
                        this.CameraManager.ChangeViewpoint(cameraNodeData.Perspective ? Viewpoint.Perspective : this.firstNodeViewpoint);
                        if (cameraNodeData.Perspective)
                        {
                            this.CameraManager.Radius = 1.0 / 1000.0;
                        }
                        if (cameraNodeData.PixelsPerTrixel != 0 && (double)this.CameraManager.PixelsPerTrixel != (double)cameraNodeData.PixelsPerTrixel)
                        {
                            this.CameraManager.PixelsPerTrixel = (float)cameraNodeData.PixelsPerTrixel;
                        }
                        this.StartNewSegment();
                        this.justStarted = false;
                    }
                }
                if (this.CameraManager.ActionRunning)
                {
                    this.sinceSegmentStarted += elapsed;
                }
                if (this.sinceSegmentStarted >= this.CurrentNode.Duration + this.CurrentNode.WaitTimeOnFinish)
                {
                    this.ChangeSegment();
                }
                if (!this.Enabled || this.Path.NeedsTrigger)
                {
                    return;
                }
                float       num1         = (float)FezMath.Saturate(this.sinceSegmentStarted.TotalSeconds / this.CurrentNode.Duration.TotalSeconds);
                float       amount       = (double)this.CurrentNode.Deceleration != 0.0 || (double)this.CurrentNode.Acceleration != 0.0 ? ((double)this.CurrentNode.Acceleration != 0.0 ? ((double)this.CurrentNode.Deceleration != 0.0 ? Easing.EaseInOut((double)num1, EasingType.Sine, this.CurrentNode.Acceleration, EasingType.Sine, this.CurrentNode.Deceleration) : Easing.Ease((double)num1, this.CurrentNode.Acceleration, EasingType.Quadratic)) : Easing.Ease((double)num1, -this.CurrentNode.Deceleration, EasingType.Quadratic)) : num1;
                PathSegment pathSegment1 = this.Nodes[Math.Max(this.nodeIndex - 1, 0)];
                PathSegment currentNode  = this.CurrentNode;
                Vector3     vector3_1;
                Quaternion  quat;

                if (this.Path.IsSpline)
                {
                    PathSegment pathSegment2 = this.Nodes[Math.Max(this.nodeIndex - 2, 0)];
                    PathSegment pathSegment3 = this.Nodes[Math.Min(this.nodeIndex + 1, this.Nodes.Count - 1)];
                    vector3_1 = Vector3.CatmullRom(pathSegment2.Destination, pathSegment1.Destination, currentNode.Destination, pathSegment3.Destination, amount);
                    quat      = Quaternion.Slerp(pathSegment1.Orientation, currentNode.Orientation, amount);
                }
                else
                {
                    vector3_1 = Vector3.Lerp(pathSegment1.Destination, currentNode.Destination, amount);
                    quat      = Quaternion.Slerp(pathSegment1.Orientation, currentNode.Orientation, amount);
                }
                float num2 = MathHelper.Lerp(pathSegment1.JitterFactor, currentNode.JitterFactor, amount);

                if ((double)num2 > 0.0)
                {
                    vector3_1 += new Vector3(RandomHelper.Centered((double)num2) * 0.5f, RandomHelper.Centered((double)num2) * 0.5f, RandomHelper.Centered((double)num2) * 0.5f);
                }
                Vector3        vector3_2       = Vector3.Transform(Vector3.Forward, quat);
                CameraNodeData cameraNodeData1 = pathSegment1.CustomData as CameraNodeData;
                CameraNodeData cameraNodeData2 = currentNode.CustomData as CameraNodeData;

                if (!cameraNodeData2.Perspective)
                {
                    this.CameraManager.PixelsPerTrixel = MathHelper.Lerp(cameraNodeData1.PixelsPerTrixel == 0 ? this.originalPixelsPerTrixel : (float)cameraNodeData1.PixelsPerTrixel, cameraNodeData2.PixelsPerTrixel == 0 ? this.originalPixelsPerTrixel : (float)cameraNodeData2.PixelsPerTrixel, amount);
                }
                Viewpoint view = cameraNodeData2.Perspective ? Viewpoint.Perspective : this.firstNodeViewpoint;

                if (view != this.CameraManager.Viewpoint)
                {
                    if (view == Viewpoint.Perspective)
                    {
                        this.CameraManager.Radius = 1.0 / 1000.0;
                    }
                    this.CameraManager.ChangeViewpoint(view);
                }
                this.CameraManager.Center    = vector3_1;
                this.CameraManager.Direction = vector3_2;
                if (!cameraNodeData2.Perspective)
                {
                    return;
                }
                if (this.nodeIndex == 1)
                {
                    this.CameraManager.Radius = MathHelper.Lerp(this.originalRadius, 1.0 / 1000.0, amount);
                }
                else if (this.nodeIndex == this.Nodes.Count - 1)
                {
                    this.CameraManager.Radius = MathHelper.Lerp(1.0 / 1000.0, this.originalRadius, amount);
                }
                else
                {
                    this.CameraManager.Radius = 1.0 / 1000.0;
                }
            }
示例#10
0
 public void ChangeLevel(string levelName)
 {
     this.GameState.SaveToCloud(false);
     this.GameState.DotLoading = this.DotLoadLevels.Contains(this.Name + "+" + levelName) || this.PlayerManager.Action == ActionType.LesserWarp || this.PlayerManager.Action == ActionType.GateWarp;
     if (this.GameState.DotLoading)
     {
         this.SoundManager.PlayNewSong((string)null, 1f);
         List <AmbienceTrack> ambienceTracks = this.levelData.AmbienceTracks;
         this.levelData.AmbienceTracks = new List <AmbienceTrack>();
         this.SoundManager.PlayNewAmbience();
         this.levelData.AmbienceTracks = ambienceTracks;
     }
     this.GameService.CloseScroll((string)null);
     if (levelName == this.Name && this.DestinationVolumeId.HasValue && this.Volumes.ContainsKey(this.DestinationVolumeId.Value))
     {
         this.LastLevelName = this.Name;
         Volume    volume = this.Volumes[this.DestinationVolumeId.Value];
         Viewpoint view   = FezMath.AsViewpoint(Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume.Orientations));
         this.CameraManager.ChangeViewpoint(view, 1.5f);
         Vector3 position = (volume.BoundingBox.Min + volume.BoundingBox.Max) / 2f + new Vector3(1.0 / 1000.0);
         position.Y = volume.BoundingBox.Min.Y - 0.25f;
         TrileInstance trileInstance = this.NearestTrile(position, QueryOptions.None, new Viewpoint?(view)).Deep;
         this.GameState.SaveData.Ground = trileInstance.Center;
         this.GameState.SaveData.View   = view;
         float num = this.PlayerManager.Position.Y;
         this.PlayerManager.Position      = trileInstance.Center + (trileInstance.TransformedSize / 2f + this.PlayerManager.Size / 2f) * Vector3.UnitY * (float)Math.Sign(this.CollisionManager.GravityFactor);
         this.PlayerManager.WallCollision = new MultipleHits <CollisionResult>();
         this.PlayerManager.Ground        = new MultipleHits <TrileInstance>();
         this.PlayerManager.Velocity      = (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464 * 0.0166666675359011) * -Vector3.UnitY;
         this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager);
         this.PlayerManager.Velocity = (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464 * 0.0166666675359011) * -Vector3.UnitY;
         Vector3 originalCenter = this.CameraManager.Center;
         float   diff           = this.PlayerManager.Position.Y - num;
         Waiters.Interpolate(1.5, (Action <float>)(s => this.CameraManager.Center = new Vector3(originalCenter.X, originalCenter.Y + diff / 2f * Easing.EaseInOut((double)s, EasingType.Sine), originalCenter.Z)));
         this.OnLevelChanging();
         this.OnLevelChanged();
     }
     else
     {
         bool   flag1 = this.GameState.SaveData.World.Count > 0;
         string str1  = this.GameState.SaveData.Level;
         this.LastLevelName = !flag1 ? (string)null : this.Name;
         this.Load(levelName);
         this.Rebuild();
         if (!this.GameState.SaveData.World.ContainsKey(this.Name))
         {
             this.GameState.SaveData.World.Add(this.Name, new LevelSaveData()
             {
                 FirstVisit = true
             });
         }
         this.GameState.SaveData.Level = this.Name;
         this.OnLevelChanging();
         LevelSaveData thisLevel = this.GameState.SaveData.ThisLevel;
         foreach (TrileEmplacement emplacement in thisLevel.DestroyedTriles)
         {
             this.ClearTrile(emplacement);
         }
         foreach (int num in thisLevel.InactiveArtObjects)
         {
             if (num < 0)
             {
                 this.RemoveArtObject(this.ArtObjects[-(num + 1)]);
             }
         }
         TrileInstance trileInstance = !flag1 || !(str1 == levelName) ? (TrileInstance)null : this.ActualInstanceAt(this.GameState.SaveData.Ground);
         float?        nullable      = new float?();
         Viewpoint     spawnView     = !flag1 || !(str1 == levelName) ? Viewpoint.Left : this.GameState.SaveData.View;
         bool          flag2         = false;
         if (this.LastLevelName != null)
         {
             Volume volume = (Volume)null;
             if (this.DestinationVolumeId.HasValue && this.DestinationVolumeId.Value != -1 && this.Volumes.ContainsKey(this.DestinationVolumeId.Value))
             {
                 volume = this.Volumes[this.DestinationVolumeId.Value];
                 flag2  = true;
                 this.DestinationVolumeId = new int?();
             }
             else
             {
                 string str2       = this.LastLevelName.Replace('\\', '/');
                 string trimmedLln = str2.Substring(str2.LastIndexOf('/') + 1);
                 foreach (Script script in Enumerable.Where <Script>(Enumerable.Where <Script>((IEnumerable <Script>) this.Scripts.Values, (Func <Script, bool>)(s => Enumerable.Any <ScriptTrigger>((IEnumerable <ScriptTrigger>)s.Triggers, (Func <ScriptTrigger, bool>)(t => t.Object.Type == "Volume")))), (Func <Script, bool>)(s => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a =>
                 {
                     if (!(a.Object.Type == "Level") || !a.Operation.Contains("ChangeLevel"))
                     {
                         return(false);
                     }
                     if (!(a.Arguments[0] == this.LastLevelName))
                     {
                         return(a.Arguments[0] == trimmedLln);
                     }
                     else
                     {
                         return(true);
                     }
                 })))))
                 {
                     int key = Enumerable.First <ScriptTrigger>(Enumerable.Where <ScriptTrigger>((IEnumerable <ScriptTrigger>)script.Triggers, (Func <ScriptTrigger, bool>)(x => x.Object.Type == "Volume"))).Object.Identifier.Value;
                     if (this.Volumes.ContainsKey(key))
                     {
                         volume = this.Volumes[key];
                         flag2  = true;
                     }
                 }
             }
             if (flag2 && volume != null)
             {
                 Vector3 vector3 = (volume.BoundingBox.Min + volume.BoundingBox.Max) / 2f + new Vector3(1.0 / 1000.0);
                 vector3.Y = volume.BoundingBox.Min.Y - 0.25f;
                 spawnView = FezMath.AsViewpoint(Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume.Orientations));
                 nullable  = new float?(FezMath.Dot(vector3, FezMath.SideMask(spawnView)));
                 float   num      = (float)((double)FezMath.Dot(volume.BoundingBox.Max - volume.BoundingBox.Min, FezMath.DepthMask(spawnView)) / 2.0 + 0.5);
                 Vector3 position = vector3 + num * -FezMath.ForwardVector(spawnView);
                 foreach (TrileEmplacement trileEmplacement in Enumerable.Union <TrileEmplacement>((IEnumerable <TrileEmplacement>)thisLevel.InactiveTriles, (IEnumerable <TrileEmplacement>)thisLevel.DestroyedTriles))
                 {
                     if ((double)Vector3.DistanceSquared(trileEmplacement.AsVector, position) < 2.0)
                     {
                         position -= FezMath.ForwardVector(spawnView);
                         break;
                     }
                 }
                 trileInstance = this.ActualInstanceAt(position) ?? this.NearestTrile(vector3, QueryOptions.None, new Viewpoint?(spawnView)).Deep;
             }
         }
         InstanceFace instanceFace = new InstanceFace();
         if (!flag1 || trileInstance == null)
         {
             if (this.StartingPosition != (TrileFace)null)
             {
                 instanceFace.Instance = this.TrileInstanceAt(ref this.StartingPosition.Id);
                 instanceFace.Face     = this.StartingPosition.Face;
             }
             else
             {
                 instanceFace.Face = FezMath.VisibleOrientation(spawnView);
             }
             if (instanceFace.Instance == null)
             {
                 instanceFace.Instance = Enumerable.FirstOrDefault <TrileInstance>((IEnumerable <TrileInstance>)Enumerable.OrderBy <TrileInstance, float>(Enumerable.Where <TrileInstance>((IEnumerable <TrileInstance>) this.Triles.Values, (Func <TrileInstance, bool>)(x => !FezMath.In <CollisionType>(x.GetRotatedFace(FezMath.VisibleOrientation(spawnView)), CollisionType.None, CollisionType.Immaterial, (IEqualityComparer <CollisionType>)CollisionTypeComparer.Default))), (Func <TrileInstance, float>)(x => Math.Abs(FezMath.Dot(x.Center - this.Size / 2f, FezMath.ScreenSpaceMask(spawnView))))));
             }
             trileInstance = instanceFace.Instance;
             spawnView     = FezMath.AsViewpoint(instanceFace.Face);
         }
         this.CameraManager.Constrained        = false;
         this.CameraManager.PanningConstraints = new Vector2?();
         if (trileInstance != null)
         {
             this.GameState.SaveData.Ground = trileInstance.Center;
         }
         this.GameState.SaveData.View      = spawnView;
         this.GameState.SaveData.TimeOfDay = this.TimeManager.CurrentTime.TimeOfDay;
         if (flag2)
         {
             this.PlayerManager.CheckpointGround = (TrileInstance)null;
         }
         this.PlayerManager.RespawnAtCheckpoint();
         if (nullable.HasValue)
         {
             this.PlayerManager.Position = this.PlayerManager.Position * (Vector3.One - FezMath.SideMask(spawnView)) + nullable.Value * FezMath.SideMask(spawnView);
         }
         this.PlayerManager.Action        = ActionType.Idle;
         this.PlayerManager.WallCollision = new MultipleHits <CollisionResult>();
         this.PlayerManager.Ground        = new MultipleHits <TrileInstance>();
         this.PlayerManager.Velocity      = (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464 * 0.0166666675359011) * -Vector3.UnitY;
         this.PhysicsManager.Update((IComplexPhysicsEntity)this.PlayerManager);
         this.PlayerManager.Velocity           = (float)(3.15000009536743 * (double)Math.Sign(this.CollisionManager.GravityFactor) * 0.150000005960464 * 0.0166666675359011) * -Vector3.UnitY;
         this.CameraManager.InterpolatedCenter = this.CameraManager.Center = this.PlayerManager.Position;
         this.OnLevelChanged();
         this.LevelService.OnStart();
         ScriptingHost.Instance.ForceUpdate(new GameTime());
         if (!this.PlayerManager.SpinThroughDoor)
         {
             if (!this.CameraManager.Constrained)
             {
                 this.CameraManager.Center = this.PlayerManager.Position + (float)(4.0 * (this.Descending ? -1.0 : 1.0)) / this.CameraManager.PixelsPerTrixel * Vector3.UnitY;
                 this.CameraManager.SnapInterpolation();
             }
             if (!this.GameState.FarawaySettings.InTransition)
             {
                 this.LevelMaterializer.ForceCull();
             }
         }
         if (this.Name != "HEX_REBUILD" && this.Name != "DRUM" && (this.Name != "VILLAGEVILLE_3D_END_64" && this.Name != "VILLAGEVILLE_3D_END_32"))
         {
             this.GameState.Save();
         }
         GC.Collect(3);
     }
 }
示例#11
0
        private void TryInitialize()
        {
            this.ThisLevelMesh.ClearGroups();
            this.NextLevelMesh.ClearGroups();
            lock (FarawayPlaceHost.FarawayWaterMutex)
                this.FarawayWaterMesh = (Mesh)null;
            (this.NextLevelMesh.Effect as FarawayEffect).CleanUp();
            foreach (Script script1 in Enumerable.Where <Script>((IEnumerable <Script>) this.LevelManager.Scripts.Values, (Func <Script, bool>)(x => Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)x.Actions, (Func <ScriptAction, bool>)(y => y.Operation == "ChangeToFarAwayLevel")))))
            {
                Volume volume1;
                if (this.LevelManager.Volumes.TryGetValue(Enumerable.FirstOrDefault <ScriptTrigger>((IEnumerable <ScriptTrigger>)script1.Triggers, (Func <ScriptTrigger, bool>)(x =>
                {
                    if (x.Object.Type == "Volume")
                    {
                        return(x.Event == "Enter");
                    }
                    else
                    {
                        return(false);
                    }
                })).Object.Identifier.Value, out volume1))
                {
                    FaceOrientation faceOrientation = Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume1.Orientations);
                    ScriptAction    scriptAction1   = Enumerable.FirstOrDefault <ScriptAction>((IEnumerable <ScriptAction>)script1.Actions, (Func <ScriptAction, bool>)(x => x.Operation == "ChangeToFarAwayLevel"));
                    string          str1            = scriptAction1.Arguments[0];
                    int             num1            = 0;
                    string          songName;
                    FaceOrientation orientation;
                    Vector2         vector2;
                    bool            flag;
                    float           num2;
                    float           num3;
                    float           num4;
                    using (MemoryContentManager memoryContentManager = new MemoryContentManager((IServiceProvider)this.Game.Services, this.Game.Content.RootDirectory))
                    {
                        string str2 = str1;
                        if (!MemoryContentManager.AssetExists("Levels" + (object)'\\' + str1.Replace('/', '\\')))
                        {
                            str2 = this.LevelManager.FullPath.Substring(0, this.LevelManager.FullPath.LastIndexOf("/") + 1) + str1.Substring(str1.LastIndexOf("/") + 1);
                        }
                        LevelReader.MinimalRead = true;
                        Level level;
                        try
                        {
                            level = memoryContentManager.Load <Level>("Levels/" + str2);
                        }
                        catch (Exception ex)
                        {
                            Logger.Log("FarawayPlaceHost", Common.LogSeverity.Warning, "Couldn't load faraway place destination level : " + str1);
                            continue;
                        }
                        LevelReader.MinimalRead = false;
                        songName = level.SongName;
                        int key;
                        try
                        {
                            key = int.Parse(scriptAction1.Arguments[1]);
                        }
                        catch (Exception ex)
                        {
                            key = -1;
                        }
                        Volume volume2 = key == -1 || !level.Volumes.ContainsKey(key) ? level.Volumes[Enumerable.First <ScriptTrigger>((IEnumerable <ScriptTrigger>)Enumerable.First <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" && a.Operation.Contains("Level"))
                            {
                                return(a.Arguments[0] == this.LevelManager.Name);
                            }
                            else
                            {
                                return(false);
                            }
                        })))).Triggers, (Func <ScriptTrigger, bool>)(t =>
                        {
                            if (t.Object.Type == "Volume")
                            {
                                return(t.Event == "Enter");
                            }
                            else
                            {
                                return(false);
                            }
                        })).Object.Identifier.Value] : level.Volumes[key];
                        orientation = Enumerable.FirstOrDefault <FaceOrientation>((IEnumerable <FaceOrientation>)volume2.Orientations);
                        Vector3 vector3 = (level.Size / 2f - (volume2.From + volume2.To) / 2f) * (FezMath.RightVector(FezMath.AsViewpoint(orientation)) + Vector3.Up);
                        vector2 = new Vector2(vector3.X + vector3.Z, vector3.Y);
                        flag    = level.WaterType != LiquidType.None;
                        num2    = level.WaterHeight - (volume2.From + volume2.To).Y / 2f + this.EngineState.WaterLevelOffset;
                        num3    = this.LevelManager.WaterHeight - (volume1.From + volume1.To).Y / 2f - num2 / 4f;
                        num4    = level.Size.Y;
                        Script script2 = Enumerable.FirstOrDefault <Script>((IEnumerable <Script>)level.Scripts.Values, (Func <Script, bool>)(s =>
                        {
                            if (Enumerable.Any <ScriptTrigger>((IEnumerable <ScriptTrigger>)s.Triggers, (Func <ScriptTrigger, bool>)(t =>
                            {
                                if (t.Event == "Start")
                                {
                                    return(t.Object.Type == "Level");
                                }
                                else
                                {
                                    return(false);
                                }
                            })))
                            {
                                return(Enumerable.Any <ScriptAction>((IEnumerable <ScriptAction>)s.Actions, (Func <ScriptAction, bool>)(a =>
                                {
                                    if (a.Object.Type == "Camera")
                                    {
                                        return a.Operation == "SetPixelsPerTrixel";
                                    }
                                    else
                                    {
                                        return false;
                                    }
                                })));
                            }
                            else
                            {
                                return(false);
                            }
                        }));
                        if (script2 != null)
                        {
                            ScriptAction scriptAction2 = Enumerable.First <ScriptAction>((IEnumerable <ScriptAction>)script2.Actions, (Func <ScriptAction, bool>)(a =>
                            {
                                if (a.Object.Type == "Camera")
                                {
                                    return(a.Operation == "SetPixelsPerTrixel");
                                }
                                else
                                {
                                    return(false);
                                }
                            }));
                            try
                            {
                                num1 = int.Parse(scriptAction2.Arguments[0]);
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                        num2 = level.WaterHeight;
                    }
                    Texture2D texture;
                    try
                    {
                        string assetName = "Other Textures/faraway_thumbs/" + (object)str1 + " (" + (string)(object)FezMath.AsViewpoint(orientation) + ")";
                        texture      = this.CMProvider.CurrentLevel.Load <Texture2D>(assetName);
                        texture.Name = assetName;
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("FarawayPlacesHost", Common.LogSeverity.Warning, "Couldn't load faraway thumbnail for " + (object)str1 + " (viewpoint = " + (string)(object)FezMath.AsViewpoint(orientation) + ")");
                        continue;
                    }
                    if (!Enumerable.Any <Group>((IEnumerable <Group>) this.ThisLevelMesh.Groups, (Func <Group, bool>)(x => x.Texture == texture)))
                    {
                        if (num1 == 0)
                        {
                            num1 = (int)this.CameraManager.PixelsPerTrixel;
                        }
                        Group            group1           = this.ThisLevelMesh.AddFace(new Vector3((float)texture.Width, (float)texture.Height, (float)texture.Width) / 16f / 2f, Vector3.Zero, faceOrientation, true);
                        Group            group2           = this.NextLevelMesh.AddFace(new Vector3((float)texture.Width, (float)texture.Height, (float)texture.Width) / 16f / 2f, Vector3.Zero, faceOrientation, true);
                        FarawayPlaceData farawayPlaceData = new FarawayPlaceData()
                        {
                            OriginalCenter        = (volume1.From + volume1.To) / 2f,
                            Viewpoint             = FezMath.AsViewpoint(faceOrientation),
                            Volume                = volume1,
                            DestinationOffset     = vector2.X * FezMath.RightVector(FezMath.AsViewpoint(faceOrientation)) + Vector3.Up * vector2.Y,
                            WaterLevelOffset      = new float?(num3),
                            DestinationLevelName  = str1,
                            DestinationWaterLevel = num2,
                            DestinationLevelSize  = num4
                        };
                        if (this.LevelManager.WaterType == LiquidType.None && flag)
                        {
                            if (this.HorizontalGradientTex == null || this.HorizontalGradientTex.IsDisposed)
                            {
                                this.HorizontalGradientTex = this.CMProvider.Global.Load <Texture2D>("Other Textures/WaterHorizGradient");
                            }
                            lock (FarawayPlaceHost.FarawayWaterMutex)
                            {
                                FarawayPlaceHost temp_380 = this;
                                // ISSUE: explicit reference operation
                                // ISSUE: variable of a reference type
                                FarawayPlaceData& temp_381 = @farawayPlaceData;
                                Mesh local_28 = new Mesh();
                                Mesh temp_383 = local_28;
                                DefaultEffect.Textured local_29 = new DefaultEffect.Textured();
                                local_29.AlphaIsEmissive = false;
                                DefaultEffect.Textured temp_387 = local_29;
                                temp_383.Effect = (BaseEffect)temp_387;
                                Mesh temp_388;
                                Mesh local_43 = temp_388 = local_28;
                                // ISSUE: explicit reference operation
                                (^ temp_381).WaterBodyMesh = temp_388;
                                Mesh temp_389 = local_43;
                                temp_380.FarawayWaterMesh = temp_389;
                                this.FarawayWaterMesh.AddFace(Vector3.One, new Vector3(-0.5f, -1f, -0.5f) + FezMath.Abs(FezMath.AsVector(faceOrientation)) * 0.5f, faceOrientation, false).Material = new Material();
                                this.FarawayWaterMesh.AddFace(Vector3.One, new Vector3(-0.5f, -1f, -0.5f) + FezMath.Abs(FezMath.AsVector(faceOrientation)) * 0.5f, faceOrientation, false).Material = new Material();
                            }
                        }
                        group2.CustomData = group1.CustomData = (object)farawayPlaceData;
                        group2.Position   = group1.Position = farawayPlaceData.OriginalCenter;
                        group2.Texture    = group1.Texture = (Texture)texture;
                        group2.Material   = new Material()
                        {
                            Opacity = 0.125f
                        };
                        group1.Material = new Material()
                        {
                            Opacity = 0.125f
                        };
                        if (volume1.ActorSettings == null)
                        {
                            volume1.ActorSettings = new VolumeActorSettings();
                        }
                        volume1.ActorSettings.DestinationSong = songName;
                        switch (num1)
                        {
                        case 1:
                            volume1.ActorSettings.DestinationRadius = 80f;
                            break;

                        case 2:
                            volume1.ActorSettings.DestinationRadius = 40f;
                            break;

                        case 3:
                            volume1.ActorSettings.DestinationRadius = 26.66667f;
                            break;

                        case 4:
                            volume1.ActorSettings.DestinationRadius = 20f;
                            break;

                        case 5:
                            volume1.ActorSettings.DestinationRadius = 16f;
                            break;
                        }
                        volume1.ActorSettings.DestinationPixelsPerTrixel = (float)num1;
                        volume1.ActorSettings.DestinationOffset          = vector2;
                    }
                }
            }
        }