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