Exemple #1
0
        public void ChangeLevel(Level level)
        {
            ContentManager cm = CMProvider.GetForLevel(level.Name);
            if (level.SkyName != null) {
                level.Sky = cm.Load<Sky>("Skies/" + level.SkyName);
            }
            if (level.TrileSetName != null) {
                level.TrileSet = cm.Load<TrileSet>("Trile Sets/" + level.TrileSetName);
            }
            if (level.SongName != null) {
                level.Song = cm.Load<TrackedSong>("Music/" + level.SongName);
                level.Song.Initialize();
            }

            tmpLevel = level;
            ChangeLevel(level.Name);

            GameLevelManagerHelper.Level = level;
        }
Exemple #2
0
        public void Load(string levelName)
        {
            if (levelName.StartsWith("JAFM_WORKAROUND_SAVE:")) {
                string[] split = levelName.Split(new char[] {':'});
                Save(split[1], (split.Length > 2) ? bool.Parse(split[2]) : false);
                return;
            }
            if (levelName == "JAFM_WORKAROUND_CHANGELEVEL") {
                ChangeLevel(GameLevelManagerHelper.ChangeLevel_);
                return;
            }

            if (tmpLevel != null) {
                ClearArtSatellites();

                oldLevel = levelData;
                levelData = tmpLevel;
                tmpLevel = null;

                levelData.OnDeserialization();
                return;
            }

            levelName = FEZMod.ProcessLevelName(levelName);

            string filePath_ = ("Resources\\levels\\"+(levelName.ToLower())).Replace("\\", Path.DirectorySeparatorChar.ToString()).Replace("/", Path.DirectorySeparatorChar.ToString())+".";

            string filePathFMB = filePath_ + "fmb";
            FileInfo fileFMB = new FileInfo(filePathFMB);
            if (fileFMB.Exists) {
                ModLogger.Log("FEZMod", "Loading level from FMB: "+levelName);

                using (FileStream fs = new FileStream(fileFMB.FullName, FileMode.Open)) {
                    throw new FormatException("FEZMod can't load FMB files yet.");
                }

                return;
            }

            string filePathXML = filePath_+"xml";
            FileInfo fileXML = new FileInfo(filePathXML);
            if (!fileXML.Exists) {
                if (MemoryContentManager.AssetExists("LEVELS/"+levelName)) {
                    orig_Load(levelName);
                } else {
                    //Fallback: Spawn at the original VILLAGEVILLE_3D if the level wasn't found at all
                    ModLogger.Log("FEZMod", "Level not found: " + levelName + "; Falling back to the original VILLAGEVILLE_3D...");
                    orig_Load("VILLAGEVILLE_3D");
                }
                FEZMod.ProcessLevelData(levelData);
                GameLevelManagerHelper.Level = levelData;
                return;
            }

            ModLogger.Log("FEZMod", "Loading level from XML: "+levelName);

            ClearArtSatellites();

            oldLevel = levelData;

            FileStream fis = new FileStream(fileXML.FullName, FileMode.Open);
            XmlReader xmlReader = XmlReader.Create(fis);
            XmlDocument xmlDocument = new XmlDocument();
            xmlDocument.Load(xmlReader);
            xmlReader.Close();
            fis.Close();

            ContentManager cm = CMProvider.GetForLevel(levelName);
            levelData = (Level) xmlDocument.Deserialize(null, cm, true);
            levelData.Name = levelName;

            LevelSaveData save = GameState.SaveData.ThisLevel;
            if (save != null) {
                save.FirstVisit = false;
            }

            FEZMod.ProcessLevelData(levelData);
            GameLevelManagerHelper.Level = levelData;
        }
 public static void ChangeLevel(Level level)
 {
     ChangeLevel_ = level;
     LevelManager.Load("JAFM_WORKAROUND_CHANGELEVEL");
 }
Exemple #4
0
 public Level CreateNewLevel(string name, int width, int height, int depth, string trileset) {
     Level level = new Level();
     level.Name = name;
     level.Size = new Vector3(width, height, depth);
     level.TrileSetName = trileset;
     level.StartingPosition = new TrileFace();
     level.StartingPosition.Face = FaceOrientation.Front;
     level.StartingPosition.Id = new TrileEmplacement(width / 2, height / 2, depth / 2);
     PlayerManager.Position = level.StartingPosition.Id.AsVector;
     return level;
 }
Exemple #5
0
 public virtual void ProcessLevelData(Level levelData)
 {
 }
Exemple #6
0
 public override void Rebuild()
 {
   this.OnSkyChanged();
   this.LevelMaterializer.ClearBatches();
   this.LevelMaterializer.RebuildTriles(this.levelData.TrileSet, this.levelData.TrileSet == this.oldLevel.TrileSet);
   this.LevelMaterializer.RebuildInstances();
   if (!this.Quantum)
     this.LevelMaterializer.CleanUp();
   this.LevelMaterializer.InitializeArtObjects();
   foreach (BackgroundPlane backgroundPlane in this.levelData.BackgroundPlanes.Values)
   {
     backgroundPlane.HostMesh = backgroundPlane.Animated ? this.LevelMaterializer.AnimatedPlanesMesh : this.LevelMaterializer.StaticPlanesMesh;
     backgroundPlane.Initialize();
   }
   if (!this.levelData.BackgroundPlanes.ContainsKey(-1) && this.GomezHaloName != null)
     this.levelData.BackgroundPlanes.Add(-1, new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, this.GomezHaloName, false)
     {
       Id = -1,
       LightMap = true,
       AlwaysOnTop = true,
       Billboard = true,
       Filter = this.HaloFiltering ? new Color(0.425f, 0.425f, 0.425f, 1f) : new Color(0.5f, 0.5f, 0.5f, 1f),
       PixelatedLightmap = !this.HaloFiltering
     });
   this.pickupGroups.Clear();
   foreach (TrileGroup trileGroup in (IEnumerable<TrileGroup>) this.Groups.Values)
   {
     if (trileGroup.ActorType != ActorType.SuckBlock && Enumerable.All<TrileInstance>((IEnumerable<TrileInstance>) trileGroup.Triles, (Func<TrileInstance, bool>) (x =>
     {
       if (ActorTypeExtensions.IsPickable(x.Trile.ActorSettings.Type))
         return x.Trile.ActorSettings.Type != ActorType.Couch;
       else
         return false;
     })))
     {
       foreach (TrileInstance key in trileGroup.Triles)
         this.pickupGroups.Add(key, trileGroup);
     }
   }
   this.SongChanged = this.Song == null != (this.SoundManager.CurrentlyPlayingSong == null) || this.Song != null && this.SoundManager.CurrentlyPlayingSong != null && this.Song.Name != this.SoundManager.CurrentlyPlayingSong.Name;
   if (this.SongChanged)
   {
     this.SoundManager.ScriptChangedSong = false;
     if (!this.GameState.InCutscene || this.GameState.IsTrialMode)
       Waiters.Wait((Func<bool>) (() =>
       {
         if (!this.GameState.Loading)
           return !this.GameState.FarawaySettings.InTransition;
         else
           return false;
       }), (Action) (() =>
       {
         if (!this.SoundManager.ScriptChangedSong)
           this.SoundManager.PlayNewSong(8f);
         this.SoundManager.ScriptChangedSong = false;
       }));
   }
   else if (this.Song != null)
   {
     if (!this.GameState.DotLoading)
       this.SoundManager.UpdateSongActiveTracks();
     else
       Waiters.Wait((Func<bool>) (() => !this.GameState.Loading), (Action) (() => this.SoundManager.UpdateSongActiveTracks()));
   }
   this.SoundManager.FadeFrequencies(this.LowPass, 2f);
   this.SoundManager.UnmuteAmbienceTracks();
   if (!this.GameState.InCutscene || this.GameState.IsTrialMode)
     Waiters.Wait((Func<bool>) (() =>
     {
       if (!this.GameState.Loading)
         return !this.GameState.FarawaySettings.InTransition;
       else
         return false;
     }), (Action) (() => this.SoundManager.PlayNewAmbience()));
   this.oldLevel = (Level) null;
   this.FullPath = this.Name;
 }
Exemple #7
0
 public override void Load(string levelName)
 {
   levelName = levelName.Replace('\\', '/');
   string str = levelName;
   Level level;
   using (MemoryContentManager memoryContentManager = new MemoryContentManager((IServiceProvider) this.Game.Services, this.Game.Content.RootDirectory))
   {
     if (!string.IsNullOrEmpty(this.Name))
       levelName = this.Name.Substring(0, this.Name.LastIndexOf("/") + 1) + levelName.Substring(levelName.LastIndexOf("/") + 1);
     if (!MemoryContentManager.AssetExists("Levels" + (object) '\\' + levelName.Replace('/', '\\')))
       levelName = str;
     try
     {
       level = memoryContentManager.Load<Level>("Levels/" + levelName);
     }
     catch (Exception ex)
     {
       Logger.LogError(ex);
       this.oldLevel = new Level();
       return;
     }
   }
   level.Name = levelName;
   ContentManager forLevel = this.CMProvider.GetForLevel(levelName);
   foreach (ArtObjectInstance artObjectInstance in level.ArtObjects.Values)
     artObjectInstance.ArtObject = forLevel.Load<ArtObject>(string.Format("{0}/{1}", (object) "Art Objects", (object) artObjectInstance.ArtObjectName));
   if (level.Sky == null)
     level.Sky = forLevel.Load<Sky>("Skies/" + level.SkyName);
   if (level.TrileSetName != null)
     level.TrileSet = forLevel.Load<TrileSet>("Trile Sets/" + level.TrileSetName);
   if (level.SongName != null)
   {
     level.Song = forLevel.Load<TrackedSong>("Music/" + level.SongName);
     level.Song.Initialize();
   }
   if (this.levelData != null)
     this.GameState.SaveData.ThisLevel.FirstVisit = false;
   this.ClearArtSatellites();
   this.oldLevel = this.levelData ?? new Level();
   this.levelData = level;
 }