Exemplo n.º 1
0
 private void TryInitialize()
 {
   this.Enabled = this.LevelManager.Name != null && this.LevelManager.Name == "ORRERY";
   this.Moon = this.Earth = this.Sun = this.PlanetW = (ArtObjectInstance) null;
   this.MoonBranch = this.EarthBranch = this.SubBranch = this.SunBranch = this.PlanetWBranch = (ArtObjectInstance) null;
   this.SmallGear1 = this.SmallGear2 = this.MediumGear = this.LargeGear1 = this.LargeGear2 = (ArtObjectInstance) null;
   if (!this.Enabled)
     return;
   this.Moon = Enumerable.Single<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_MOONAO"));
   this.Earth = Enumerable.Single<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_EARTHAO"));
   this.Sun = Enumerable.Single<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_SUNAO"));
   this.PlanetW = Enumerable.Single<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_PLANET_WAO"));
   this.MoonBranch = Enumerable.Single<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_MOON_BRANCHAO"));
   this.EarthBranch = Enumerable.Single<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_EARTH_BRANCHAO"));
   this.SubBranch = Enumerable.First<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_SUN_BRANCHAO"));
   this.SunBranch = Enumerable.First<ArtObjectInstance>(Enumerable.Skip<ArtObjectInstance>(Enumerable.Where<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_SUN_BRANCHAO")), 1));
   this.PlanetWBranch = Enumerable.Single<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_W_BRANCHAO"));
   this.SmallGear1 = Enumerable.First<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_COG_SAO"));
   this.SmallGear2 = Enumerable.First<ArtObjectInstance>(Enumerable.Skip<ArtObjectInstance>(Enumerable.Where<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_COG_SAO")), 1));
   this.MediumGear = Enumerable.First<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_COG_MAO"));
   this.LargeGear1 = Enumerable.First<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_COG_LAO"));
   this.LargeGear2 = Enumerable.First<ArtObjectInstance>(Enumerable.Skip<ArtObjectInstance>(Enumerable.Where<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "ORR_COG_LAO")), 1));
   this.MoonDistance = Vector3.Distance(this.Earth.Position, this.Moon.Position);
   this.EarthDistance = Vector3.Distance(this.Sun.Position, this.Earth.Position);
   this.PlanetWDistance = Vector3.Distance(this.Sun.Position, this.PlanetW.Position);
   this.MoonBranchHeight = this.MoonBranch.Position.Y;
   this.EarthBranchHeight = this.EarthBranch.Position.Y;
   this.PlanetWBranchHeight = this.PlanetWBranch.Position.Y;
 }
Exemplo n.º 2
0
 private void TryInitialize()
 {
   this.sRumble = (SoundEffect) null;
   this.eRumble = (SoundEmitter) null;
   this.OwlHeadAo = Enumerable.SingleOrDefault<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x =>
   {
     if (!(x.ArtObjectName == "OWL_STATUE_HEADAO") && !(x.ArtObjectName == "BIG_OWL_HEADAO"))
       return x.ArtObjectName == "OWL_STATUE_DRAPES_BAO";
     else
       return true;
   }));
   this.AttachedCandlesAo = (ArtObjectInstance) null;
   this.IsBig = this.OwlHeadAo != null && this.OwlHeadAo.ArtObjectName == "BIG_OWL_HEADAO";
   this.Enabled = this.OwlHeadAo != null;
   this.SinceStarted = 0.0f;
   if (!this.Enabled)
     return;
   this.sRumble = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/Rumble");
   this.eRumble = SoundEffectExtensions.EmitAt(this.sRumble, this.OwlHeadAo.Position, true, true);
   this.eRumble.VolumeFactor = 0.0f;
   this.IsInverted = false;
   if (this.OwlHeadAo.ArtObjectName == "OWL_STATUE_DRAPES_BAO")
   {
     this.AttachedCandlesAo = this.LevelManager.ArtObjects[14];
     this.OriginalRotation = Quaternion.Identity;
     this.IsInverted = true;
   }
   else
     this.OriginalRotation = this.OwlHeadAo.Rotation * Quaternion.CreateFromAxisAngle(Vector3.Up, FezMath.ToPhi(this.CameraManager.Viewpoint));
   this.OriginalTranslation = this.OwlHeadAo.Position;
 }
Exemplo n.º 3
0
 public GlitchyDespawner(Game game, ArtObjectInstance instance)
   : this(game)
 {
   this.AoInstance = instance;
   this.CreateTreasure = false;
   instance.Hidden = true;
   this.IsArtObject = true;
 }
Exemplo n.º 4
0
 public GlitchyDespawner(Game game, ArtObjectInstance instance, Vector3 treasureCenter)
   : this(game)
 {
   this.AoInstance = instance;
   this.TreasureCenter = treasureCenter;
   this.CreateTreasure = true;
   instance.Hidden = true;
   this.IsArtObject = true;
 }
Exemplo n.º 5
0
 private void TryInitialize()
 {
   this.Enabled = false;
   this.ArtObject = Enumerable.FirstOrDefault<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x =>
   {
     if (x.ArtObject.ActorType == ActorType.QrCode)
       return x.ActorSettings.VibrationPattern != null;
     else
       return false;
   }));
   if (this.ArtObject != null)
   {
     this.Enabled = true;
     if (this.GameService.IsSewerQrResolved)
     {
       if (this.ArtObject.ActorSettings.AttachedGroup.HasValue)
       {
         int key = this.ArtObject.ActorSettings.AttachedGroup.Value;
         foreach (TrileInstance instance in this.LevelManager.Groups[this.ArtObject.ActorSettings.AttachedGroup.Value].Triles.ToArray())
           this.LevelManager.ClearTrile(instance);
         this.LevelManager.Groups.Remove(key);
       }
       this.LevelManager.Volumes[1].Enabled = false;
       this.LevelManager.ArtObjects.Remove(this.ArtObject.Id);
       this.ArtObject.Dispose();
       this.LevelMaterializer.RegisterSatellites();
       Vector3 position1 = this.ArtObject.Position;
       if (this.GameState.SaveData.ThisLevel.ScriptingState == "NOT_COLLECTED")
       {
         Trile trile = Enumerable.FirstOrDefault<Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube));
         if (trile != null)
         {
           Vector3 position2 = position1 - Vector3.One / 2f;
           this.LevelManager.ClearTrile(new TrileEmplacement(position2));
           TrileInstance toAdd;
           this.LevelManager.RestoreTrile(toAdd = new TrileInstance(position2, trile.Id)
           {
             OriginalEmplacement = new TrileEmplacement(position2)
           });
           this.GomezService.CollectedAnti += (Action) (() => this.GameState.SaveData.ThisLevel.ScriptingState = (string) null);
           if (toAdd.InstanceId == -1)
             this.LevelMaterializer.CullInstanceIn(toAdd);
         }
       }
       this.Enabled = false;
     }
   }
   if (!this.Enabled)
     return;
   this.ArtObject.ActorSettings.VibrationPattern = Util.JoinArrays<VibrationMotor>(this.ArtObject.ActorSettings.VibrationPattern, new VibrationMotor[3]);
 }
Exemplo n.º 6
0
 private void TryInitialize()
 {
   this.warpGateAo = Enumerable.FirstOrDefault<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObject.ActorType == ActorType.WarpGate));
   this.Visible = this.Enabled = this.warpGateAo != null;
   if (!this.Enabled)
   {
     foreach (KeyValuePair<WarpDestinations, WarpPanel> keyValuePair in this.panels)
     {
       keyValuePair.Value.PanelMask.Dispose();
       keyValuePair.Value.Layers.Dispose();
     }
     this.panels.Clear();
   }
   else
   {
     if (this.panels.Count == 0)
     {
       Mesh mesh1 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         DepthWrites = false,
         Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/fullwhite"))
       };
       mesh1.AddFace(new Vector3(3.875f), Vector3.Backward * (25.0 / 16.0), FaceOrientation.Front, true);
       Mesh mesh2 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         AlwaysOnTop = true,
         DepthWrites = false,
         SamplerState = SamplerState.PointClamp
       };
       Texture2D texture2D1 = this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/nature/background");
       mesh2.AddFace(new Vector3(10f, 4f, 10f), Vector3.Forward * 5f, FaceOrientation.Front, true).Texture = (Texture) texture2D1;
       mesh2.AddFace(new Vector3(10f, 4f, 10f), Vector3.Right * 5f, FaceOrientation.Left, true).Texture = (Texture) texture2D1;
       mesh2.AddFace(new Vector3(10f, 4f, 10f), Vector3.Left * 5f, FaceOrientation.Right, true).Texture = (Texture) texture2D1;
       Group group1 = mesh2.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 2f, -8f), FaceOrientation.Front, true);
       group1.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/WATERFRONT/WATERFRONT_C");
       group1.Material = new Material()
       {
         Opacity = 0.3f,
         Diffuse = Vector3.Lerp(Vector3.One, new Vector3(0.1215686f, 0.96f, 1f), 0.7f)
       };
       Group group2 = mesh2.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 2f, -8f), FaceOrientation.Front, true);
       group2.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/WATERFRONT/WATERFRONT_B");
       group2.Material = new Material()
       {
         Opacity = 0.5f,
         Diffuse = Vector3.Lerp(Vector3.One, new Vector3(0.1215686f, 0.96f, 1f), 0.5f)
       };
       Group group3 = mesh2.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 2f, -8f), FaceOrientation.Front, true);
       group3.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/WATERFRONT/WATERFRONT_A");
       group3.Material = new Material()
       {
         Opacity = 1f,
         Diffuse = Vector3.Lerp(Vector3.One, new Vector3(0.1215686f, 0.96f, 1f), 0.4f)
       };
       this.panels.Add(WarpDestinations.First, new WarpPanel()
       {
         PanelMask = mesh1,
         Layers = mesh2,
         Face = FaceOrientation.Front,
         Destination = "NATURE_HUB"
       });
       Mesh mesh3 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         DepthWrites = false,
         Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/fullwhite"))
       };
       mesh3.AddFace(new Vector3(3.875f), Vector3.Right * (25.0 / 16.0), FaceOrientation.Right, true);
       Mesh mesh4 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         AlwaysOnTop = true,
         DepthWrites = false,
         SamplerState = SamplerState.PointClamp
       };
       Texture2D texture2D2 = this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/graveyard/back");
       Group group4 = mesh4.AddFace(Vector3.One * 16f, Vector3.Zero, FaceOrientation.Right, true);
       group4.Texture = (Texture) texture2D2;
       group4.SamplerState = SamplerState.PointWrap;
       mesh4.AddFace(new Vector3(1f, 16f, 32f), new Vector3(-8f, 4f, 0.0f), FaceOrientation.Right, true).Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/GRAVE/GRAVE_CLOUD_C");
       mesh4.AddFace(new Vector3(1f, 16f, 32f), new Vector3(-8f, 4f, 0.0f), FaceOrientation.Right, true).Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/GRAVE/GRAVE_CLOUD_B");
       mesh4.AddFace(new Vector3(1f, 16f, 32f), new Vector3(-8f, 4f, 0.0f), FaceOrientation.Right, true).Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/GRAVE/GRAVE_CLOUD_A");
       Group group5 = mesh4.AddFace(Vector3.One * 16f, Vector3.Zero, FaceOrientation.Right, true);
       group5.SamplerState = SamplerState.PointWrap;
       group5.Blending = new BlendingMode?(BlendingMode.Additive);
       group5.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/graveyard/rainoverlay");
       this.panels.Add(WarpDestinations.Graveyard, new WarpPanel()
       {
         PanelMask = mesh3,
         Layers = mesh4,
         Face = FaceOrientation.Right,
         Destination = "GRAVEYARD_GATE"
       });
       Mesh mesh5 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         DepthWrites = false,
         Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/fullwhite"))
       };
       mesh5.AddFace(new Vector3(3.875f), Vector3.Left * (25.0 / 16.0), FaceOrientation.Left, true);
       Mesh mesh6 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         AlwaysOnTop = true,
         DepthWrites = false,
         SamplerState = SamplerState.PointClamp
       };
       Texture2D texture2D3 = this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/industrial/background");
       mesh6.AddFace(new Vector3(10f, 4f, 10f), Vector3.Right * 5f, FaceOrientation.Left, true).Texture = (Texture) texture2D3;
       mesh6.AddFace(new Vector3(10f, 4f, 10f), Vector3.Backward * 5f, FaceOrientation.Back, true).Texture = (Texture) texture2D3;
       mesh6.AddFace(new Vector3(10f, 4f, 10f), Vector3.Forward * 5f, FaceOrientation.Front, true).Texture = (Texture) texture2D3;
       Group group6 = mesh6.AddFace(new Vector3(1f, 8f, 8f), new Vector3(8f, 0.0f, 0.0f), FaceOrientation.Left, true);
       group6.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/industrial/INDUST_CLOUD_B");
       group6.Material = new Material()
       {
         Opacity = 0.5f
       };
       Group group7 = mesh6.AddFace(new Vector3(1f, 8f, 8f), new Vector3(8f, 0.0f, 0.0f), FaceOrientation.Left, true);
       group7.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/industrial/INDUST_CLOUD_F");
       group7.Material = new Material()
       {
         Opacity = 0.325f
       };
       this.panels.Add(WarpDestinations.Mechanical, new WarpPanel()
       {
         PanelMask = mesh5,
         Layers = mesh6,
         Face = FaceOrientation.Left,
         Destination = "INDUSTRIAL_HUB"
       });
       Mesh mesh7 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         DepthWrites = false,
         Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/fullwhite"))
       };
       mesh7.AddFace(new Vector3(3.875f), Vector3.Forward * (25.0 / 16.0), FaceOrientation.Back, true);
       Mesh mesh8 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         AlwaysOnTop = true,
         DepthWrites = false,
         SamplerState = SamplerState.PointClamp
       };
       Texture2D texture2D4 = this.CMProvider.Global.Load<Texture2D>("Skies/SEWER/BRICK_BACKGROUND");
       Group group8 = mesh8.AddFace(Vector3.One * 16f, Vector3.Backward * 8f, FaceOrientation.Back, true);
       group8.Texture = (Texture) texture2D4;
       group8.SamplerState = SamplerState.PointWrap;
       Group group9 = mesh8.AddFace(Vector3.One * 16f, Vector3.Right * 8f, FaceOrientation.Left, true);
       group9.Texture = (Texture) texture2D4;
       group9.SamplerState = SamplerState.PointWrap;
       Group group10 = mesh8.AddFace(Vector3.One * 16f, Vector3.Left * 8f, FaceOrientation.Right, true);
       group10.Texture = (Texture) texture2D4;
       group10.SamplerState = SamplerState.PointWrap;
       Group group11 = mesh8.AddFace(new Vector3(128f, 8f, 1f), new Vector3(0.0f, 4f, -8f), FaceOrientation.Back, true);
       group11.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/sewer/sewage");
       group11.SamplerState = SamplerState.PointWrap;
       this.panels.Add(WarpDestinations.Sewers, new WarpPanel()
       {
         PanelMask = mesh7,
         Layers = mesh8,
         Face = FaceOrientation.Back,
         Destination = "SEWER_HUB"
       });
       Mesh mesh9 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         DepthWrites = false,
         Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/fullwhite"))
       };
       mesh9.AddFace(new Vector3(3.875f), Vector3.Backward * (25.0 / 16.0), FaceOrientation.Front, true);
       Mesh mesh10 = new Mesh()
       {
         Effect = (BaseEffect) new DefaultEffect.Textured(),
         AlwaysOnTop = true,
         DepthWrites = false,
         SamplerState = SamplerState.PointClamp
       };
       Texture2D texture2D5 = this.CMProvider.Global.Load<Texture2D>("Other Textures/warp/zu/back");
       Group group12 = mesh10.AddFace(new Vector3(16f, 32f, 16f), Vector3.Zero, FaceOrientation.Front, true);
       group12.Texture = (Texture) texture2D5;
       group12.SamplerState = SamplerState.PointWrap;
       Group group13 = mesh10.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 0.0f, -8f), FaceOrientation.Front, true);
       group13.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/ABOVE/ABOVE_C");
       group13.Material = new Material()
       {
         Opacity = 0.4f,
         Diffuse = Vector3.Lerp(new Vector3(0.6862745f, 1f, 0.97647f), new Vector3(0.1294118f, 0.4f, 1f), 0.7f)
       };
       Group group14 = mesh10.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 0.0f, -8f), FaceOrientation.Front, true);
       group14.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/ABOVE/ABOVE_B");
       group14.Material = new Material()
       {
         Opacity = 0.6f,
         Diffuse = Vector3.Lerp(new Vector3(0.6862745f, 1f, 0.97647f), new Vector3(0.1294118f, 0.4f, 1f), 0.6f)
       };
       Group group15 = mesh10.AddFace(new Vector3(32f, 32f, 1f), new Vector3(0.0f, 0.0f, -8f), FaceOrientation.Front, true);
       group15.Texture = (Texture) this.CMProvider.Global.Load<Texture2D>("Skies/ABOVE/ABOVE_A");
       group15.Material = new Material()
       {
         Opacity = 1f,
         Diffuse = Vector3.Lerp(new Vector3(0.6862745f, 1f, 0.97647f), new Vector3(0.1294118f, 0.4f, 1f), 0.5f)
       };
       this.panels.Add(WarpDestinations.Zu, new WarpPanel()
       {
         PanelMask = mesh9,
         Layers = mesh10,
         Face = FaceOrientation.Front,
         Destination = "ZU_CITY_RUINS"
       });
     }
     if (Fez.LongScreenshot)
     {
       this.GameState.SaveData.UnlockedWarpDestinations.Add("SEWER_HUB");
       this.GameState.SaveData.UnlockedWarpDestinations.Add("GRAVEYARD_GATE");
       this.GameState.SaveData.UnlockedWarpDestinations.Add("INDUSTRIAL_HUB");
       this.GameState.SaveData.UnlockedWarpDestinations.Add("ZU_CITY_RUINS");
     }
     string str = this.LevelManager.Name.Replace('\\', '/');
     this.CurrentLevelName = str.Substring(str.LastIndexOf('/') + 1);
     if (!this.GameState.SaveData.UnlockedWarpDestinations.Contains(this.CurrentLevelName))
       this.GameState.SaveData.UnlockedWarpDestinations.Add(this.CurrentLevelName);
     else if (this.GameState.SaveData.UnlockedWarpDestinations.Count > 1)
     {
       ICollection<Volume> values = this.LevelManager.Volumes.Values;
       Func<Volume, bool> predicate = (Func<Volume, bool>) (x =>
       {
         if (x.ActorSettings != null && x.ActorSettings.IsPointOfInterest)
           return (double) Vector3.DistanceSquared(FezMath.GetCenter(x.BoundingBox), this.warpGateAo.Position) < 4.0;
         else
           return false;
       });
       Volume volume;
       if ((volume = Enumerable.FirstOrDefault<Volume>((IEnumerable<Volume>) values, predicate)) != null)
       {
         volume.ActorSettings.DotDialogue.Clear();
         volume.ActorSettings.DotDialogue.AddRange((IEnumerable<DotDialogueLine>) new DotDialogueLine[3]
         {
           new DotDialogueLine()
           {
             ResourceText = "DOT_WARP_A",
             Grouped = true
           },
           new DotDialogueLine()
           {
             ResourceText = "DOT_WARP_B",
             Grouped = true
           },
           new DotDialogueLine()
           {
             ResourceText = "DOT_WARP_UP",
             Grouped = true
           }
         });
         bool flag;
         if (this.GameState.SaveData.OneTimeTutorials.TryGetValue("DOT_WARP_A", out flag) && flag)
           volume.ActorSettings.PreventHey = true;
       }
     }
     Vector3 zero = Vector3.Zero;
     if (this.warpGateAo.ArtObject.Cubemap.Height == 128)
       zero -= Vector3.UnitY;
     foreach (WarpPanel warpPanel in this.panels.Values)
     {
       warpPanel.PanelMask.Position = this.warpGateAo.Position + zero;
       warpPanel.Layers.Position = this.warpGateAo.Position + zero;
       warpPanel.Enabled = warpPanel.Destination != this.CurrentLevelName && this.GameState.SaveData.UnlockedWarpDestinations.Contains(warpPanel.Destination);
       if (warpPanel.Destination == "ZU_CITY_RUINS")
       {
         switch (this.CurrentLevelName)
         {
           case "NATURE_HUB":
             warpPanel.Face = FaceOrientation.Front;
             warpPanel.PanelMask.Rotation = Quaternion.Identity;
             warpPanel.Layers.Rotation = Quaternion.Identity;
             continue;
           case "GRAVEYARD_GATE":
             warpPanel.Face = FaceOrientation.Right;
             warpPanel.PanelMask.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 1.570796f);
             warpPanel.Layers.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 1.570796f);
             continue;
           case "INDUSTRIAL_HUB":
             warpPanel.Face = FaceOrientation.Left;
             warpPanel.PanelMask.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 4.712389f);
             warpPanel.Layers.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 4.712389f);
             continue;
           case "SEWER_HUB":
             warpPanel.Face = FaceOrientation.Back;
             warpPanel.PanelMask.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 3.141593f);
             warpPanel.Layers.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 3.141593f);
             continue;
           default:
             continue;
         }
       }
     }
   }
 }
Exemplo n.º 7
0
 protected override bool Act(TimeSpan elapsed)
 {
   this.sinceActive += elapsed;
   float num1 = (float) this.sinceActive.TotalSeconds;
   float num2 = FezMath.Saturate((float) this.sinceActive.Ticks / (float) OpenTreasure.OpeningDuration.Ticks);
   float num3 = MathHelper.Lerp(num2, Easing.EaseInOut((double) num2, EasingType.Sine, EasingType.Linear), 0.5f) * (float) Math.Pow(0.5, 0.5);
   if ((double) num2 > Math.Pow(0.5, 0.5))
     num3 = (float) Math.Pow((double) num2, 2.0);
   bool flag = this.PlayerManager.Action == ActionType.OpeningTreasure;
   if (flag)
   {
     this.chestAO.Position = this.aoOrigin + num3 * 1.375f * FezMath.ForwardVector(this.CameraManager.Viewpoint) + (float) (Math.Sin((double) num3 * 1.57079637050629 * 3.0) * 4.0 / 16.0) * Vector3.UnitY;
     this.chestAO.Rotation = this.aoInitialRotation * Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float) (-(double) num3 * 1.57079637050629 * 3.0 / 2.0));
     float num4 = num3 * 6.283185f + FezMath.ToPhi(this.CameraManager.Viewpoint);
     this.CameraManager.Direction = new Vector3((float) Math.Sin((double) num4), 0.0f, (float) Math.Cos((double) num4));
     this.CameraManager.Center = this.aoOrigin + Vector3.UnitY * 1.5f * num2;
   }
   if (!flag)
   {
     IPlayerManager playerManager = this.PlayerManager;
     Vector3 vector3 = playerManager.Velocity * 0.95f;
     playerManager.Velocity = vector3;
   }
   this.lightBox.Material.Diffuse = new Vector3(FezMath.Saturate(num3 * 1.5f) * 0.75f);
   this.lightBox.Material.Diffuse *= new Vector3(1f, 1f, 0.5f);
   this.lightBox.Scale = new Vector3(1.6f, FezMath.Saturate(num3 * 1.5f) * 1.5f, 1.2f);
   if ((double) num3 > 0.5)
   {
     if (!this.restored && this.chestAO != null)
     {
       this.restored = true;
       if (this.treasureIsAo)
       {
         this.treasureOrigin = this.aoOrigin - new Vector3(0.0f, 0.125f, 0.0f);
         int key = IdentifierPool.FirstAvailable<ArtObjectInstance>(this.LevelManager.ArtObjects);
         this.treasureAoInstance = new ArtObjectInstance(this.treasureAo)
         {
           Id = key
         };
         this.LevelManager.ArtObjects.Add(key, this.treasureAoInstance);
         this.treasureAoInstance.Initialize();
       }
       else if (this.treasureIsMail)
       {
         this.treasureOrigin = this.aoOrigin - new Vector3(0.0f, 0.125f, 0.0f);
         string treasureMapName = this.chestAO.ActorSettings.TreasureMapName;
         Texture2D texture2D1 = this.CMProvider.Global.Load<Texture2D>("Other Textures/mail/" + treasureMapName + "_1");
         Texture2D texture2D2 = this.CMProvider.Global.Load<Texture2D>("Other Textures/mail/" + treasureMapName + "_2");
         this.mail.Groups[0].Texture = (Texture) texture2D1;
         this.mail.Groups[1].Texture = (Texture) texture2D2;
       }
       else if (this.treasureIsMap)
       {
         this.treasureOrigin = this.aoOrigin - new Vector3(0.0f, 0.125f, 0.0f);
         string treasureMapName = this.chestAO.ActorSettings.TreasureMapName;
         Texture2D texture2D1 = this.CMProvider.Global.Load<Texture2D>("Other Textures/maps/" + treasureMapName + "_1");
         Texture2D texture2D2 = this.CMProvider.Global.Load<Texture2D>("Other Textures/maps/" + treasureMapName + "_2");
         for (int index = 0; index < this.map.Groups.Count; ++index)
           this.map.Groups[index].Texture = index % 2 == 0 ? (Texture) texture2D1 : (Texture) texture2D2;
       }
       else
       {
         this.treasureOrigin = this.aoOrigin - this.treasureTrile.Size / 2f - new Vector3(0.0f, 0.125f, 0.0f);
         this.LevelManager.ClearTrile(new TrileEmplacement(this.treasureOrigin));
         this.LevelManager.RestoreTrile(this.treasureInstance = new TrileInstance(this.treasureOrigin, this.treasureTrile.Id));
         this.LevelMaterializer.CullInstanceIn(this.treasureInstance, true);
       }
     }
     float num4 = 2f;
     if (!flag)
       num4 = !this.treasureIsMap ? (float) (((double) Easing.EaseIn((1.0 - (double) num3) * 2.0, EasingType.Quadratic) * 2.0 + 0.5) * 2.0) : (float) (((double) Easing.EaseIn((1.0 - (double) num3) * 2.0, EasingType.Quadratic) * 4.0 + 0.5) * 2.0);
     else if (this.treasureIsAo)
       this.treasureAoInstance.Position = this.treasureOrigin + Vector3.UnitY * (num3 - 0.5f) * 4f;
     else if (this.treasureIsMap)
       this.map.Position = this.treasureOrigin + Vector3.UnitY * (num3 - 0.5f) * 4f;
     else if (this.treasureIsMail)
       this.mail.Position = this.treasureOrigin + Vector3.UnitY * (num3 - 0.5f) * 4f;
     else
       this.treasureInstance.Position = this.treasureOrigin + Vector3.UnitY * (num3 - 0.5f) * 4f;
     if (this.treasureIsAo)
     {
       Quaternion quaternion = Quaternion.CreateFromAxisAngle(Vector3.Right, -(float) Math.Asin(Math.Sqrt(2.0) / Math.Sqrt(3.0))) * Quaternion.CreateFromAxisAngle(Vector3.Up, 0.7853982f);
       this.treasureAoInstance.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, FezMath.WrapAngle(-num1 * num4)) * quaternion;
     }
     else if (this.treasureIsMap)
     {
       if (flag)
       {
         Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(Vector3.Right, (float) Math.Asin(Math.Sqrt(2.0) / Math.Sqrt(3.0)));
         this.map.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, FezMath.WrapAngle(-num1 * num4)) * fromAxisAngle;
       }
       else
         this.map.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, (float) ((double) num4 * 1.0 / 30.0)) * this.map.Rotation;
     }
     else if (this.treasureIsMail)
     {
       Quaternion fromAxisAngle = Quaternion.CreateFromAxisAngle(Vector3.Right, 0.3926991f);
       this.mail.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, FezMath.WrapAngle(-num1 * num4)) * fromAxisAngle;
     }
     else
     {
       this.treasureInstance.Phi = FezMath.WrapAngle(-num1 * num4);
       this.LevelManager.UpdateInstance(this.treasureInstance);
     }
     this.flare.Position = this.solidStar.Position = this.fadedStar.Position = (this.treasureIsMail ? this.mail.Position : (this.treasureIsMap ? this.map.Position : (this.treasureIsAo ? this.treasureAoInstance.Position : this.treasureInstance.Center))) + Vector3.Normalize(-this.CameraManager.Direction) * 0.5f;
     if (this.treasureIsAo)
       this.treasureAoInstance.Position += Vector3.Transform(-FezMath.XYX(ActorTypeExtensions.GetArtifactOffset(this.treasureActorType)) * new Vector3(1f, -1f, 1f) / 16f, this.treasureAoInstance.Rotation);
   }
   float num5 = FezMath.Saturate((float) (((double) num3 - 0.949999988079071) * 19.9999961853027));
   this.fadedStar.Material.Opacity = this.treasureIsMail || this.treasureIsMap || (this.treasureIsAo || ActorTypeExtensions.IsCubeShard(this.treasureTrile.ActorSettings.Type)) ? num5 : 0.0f;
   this.flare.Material.Diffuse = new Vector3(num5 / 3f);
   this.flare.Scale = this.solidStar.Scale = this.fadedStar.Scale = MathHelper.Lerp(this.CameraManager.Radius * 0.6f, this.CameraManager.Radius * 0.5f, (float) (Math.Sin(this.sinceActive.TotalSeconds * 5.0) / 2.0 + 0.5)) * Vector3.One * num5;
   this.solidStar.Rotation = this.fadedStar.Rotation = this.CameraManager.Rotation * Quaternion.CreateFromAxisAngle(Vector3.UnitZ, num1 * 1f);
   if (this.LevelManager.WaterType == LiquidType.Sewer)
   {
     this.lightBox.Material.Diffuse *= new Vector3(0.682353f, 0.7686275f, 0.2509804f);
     this.flare.Material.Diffuse = new Vector3(0.682353f, 0.7686275f, 0.2509804f) * new Vector3(num5 / 3f);
     this.flare.Scale *= 0.75f;
     this.solidStar.Enabled = true;
     this.solidStar.Material.Opacity = this.fadedStar.Material.Opacity * 0.75f;
     this.solidStar.Scale = this.CameraManager.Radius * Vector3.One;
     this.fadedStar.Material.Opacity = 0.0f;
     this.solidStar.Material.Diffuse = (new Vector3(0.682353f, 0.7686275f, 0.2509804f) + new Vector3(0.8431373f, 0.9098039f, 0.5803922f)) / 2f;
   }
   else if (this.LevelManager.WaterType == LiquidType.Lava)
   {
     this.lightBox.Material.Diffuse *= new Vector3(0.9960784f, 0.003921569f, 0.0f);
     this.flare.Material.Diffuse = new Vector3(0.9960784f, 0.003921569f, 0.0f) * num5 / 2.5f;
     this.flare.Scale *= 0.75f;
     this.solidStar.Enabled = true;
     this.solidStar.Material.Opacity = this.fadedStar.Material.Opacity * 0.75f;
     this.solidStar.Scale = this.CameraManager.Radius * Vector3.One;
     this.fadedStar.Material.Opacity = 0.0f;
     this.solidStar.Material.Diffuse = new Vector3(0.9960784f, 0.003921569f, 0.0f);
   }
   else
     this.solidStar.Enabled = false;
   if ((double) num3 == 1.0)
   {
     this.sinceCollect += elapsed;
     if (!this.reculled && FezMath.AlmostEqual(this.CameraManager.View.Forward, FezMath.AlmostClamp(this.CameraManager.View.Forward)))
     {
       int num4 = flag ? 1 : 0;
       this.LevelMaterializer.CullInstances();
       this.reculled = true;
     }
     if (this.sinceCollect.TotalSeconds > 3.0 || this.InputManager.Jump == FezButtonState.Pressed || this.InputManager.GrabThrow == FezButtonState.Pressed)
     {
       this.SoundManager.FadeVolume(0.125f, 1f, 2f);
       if (flag)
       {
         this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(this.chestAO.Id);
         ++this.GameState.SaveData.ThisLevel.FilledConditions.ChestCount;
         this.ArtObjectService.OnTreasureOpened(this.chestAO.Id);
       }
       else if (this.PlayerManager.ForcedTreasure == null)
       {
         if (this.treasureIsMap)
         {
           this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(this.treasureAoInstance.Id);
           ++this.GameState.SaveData.ThisLevel.FilledConditions.OtherCollectibleCount;
         }
         else
         {
           this.GameState.SaveData.ThisLevel.DestroyedTriles.Add(this.treasureInstance.OriginalEmplacement);
           if (!this.treasureInstance.Foreign)
           {
             if (this.treasureInstance.Trile.ActorSettings.Type == ActorType.CubeShard)
               ++this.GameState.SaveData.ThisLevel.FilledConditions.CubeShardCount;
             else
               ++this.GameState.SaveData.ThisLevel.FilledConditions.OtherCollectibleCount;
           }
         }
       }
       if (!flag)
         this.CameraManager.PixelsPerTrixel = this.lastZoom;
       this.CameraManager.Constrained = this.WasConstrained;
       if (this.WasConstrained)
       {
         this.CameraManager.Center = this.OldCenter;
         this.CameraManager.PixelsPerTrixel = this.OldPixPerTrix;
       }
       this.CameraManager.PanningConstraints = this.OldPan;
       this.PlayerManager.Action = ActionType.Idle;
       switch (this.treasureActorType)
       {
         case ActorType.TreasureMap:
           if (!flag)
             this.GameState.SaveData.Maps.Add(this.treasureAoInstance.ActorSettings.TreasureMapName);
           else
             this.GameState.SaveData.Maps.Add(this.chestAO.ActorSettings.TreasureMapName);
           if (this.GameState.SaveData.Maps.Count == 1)
           {
             this.DotService.Say("DOT_TREASURE_MAP_A", true, false).Ended = (Action) (() => this.DotService.Say("DOT_TREASURE_MAP_B", true, false).Ended = (Action) (() => this.DotService.Say("DOT_TREASURE_MAP_C", true, false).Ended = (Action) (() => this.DotService.Say("DOT_TREASURE_MAP_D", true, true))));
             break;
           }
           else
             break;
         case ActorType.PieceOfHeart:
           ++this.GameState.SaveData.PiecesOfHeart;
           if (this.GameState.SaveData.PiecesOfHeart > 3)
             this.GameState.SaveData.PiecesOfHeart = 3;
           this.GameState.SaveData.ScoreDirty = true;
           this.GomezService.OnCollectedPieceOfHeart();
           this.DotService.Say("DOT_HEART_A", true, false).Ended = (Action) (() => this.DotService.Say("DOT_HEART_B", true, false).Ended = (Action) (() => this.DotService.Say("DOT_HEART_C", true, true)));
           break;
         case ActorType.CubeShard:
           ++this.GameState.SaveData.CubeShards;
           if (this.GameState.SaveData.CubeShards > 32)
             this.GameState.SaveData.CubeShards = 32;
           if (this.PlayerManager.ForcedTreasure != null)
             this.GameState.SaveData.CollectedParts = 0;
           this.GameState.SaveData.ScoreDirty = true;
           this.GomezService.OnCollectedShard();
           this.CheckCubes();
           break;
         case ActorType.SkeletonKey:
           ++this.GameState.SaveData.Keys;
           if (!this.GameState.SaveData.OneTimeTutorials.ContainsKey("DOT_KEY_A"))
           {
             this.GameState.SaveData.OneTimeTutorials.Add("DOT_KEY_A", true);
             this.DotService.Say("DOT_KEY_A", true, false).Ended = (Action) (() => this.DotService.Say("DOT_KEY_B", true, true));
             break;
           }
           else
             break;
         case ActorType.NumberCube:
           this.GameState.SaveData.Artifacts.Add(this.treasureActorType);
           this.DotService.Say("DOT_ANCIENT_ARTIFACT", true, false).Ended = (Action) (() => this.DotService.Say("DOT_NUMBERS_A", true, true));
           break;
         case ActorType.LetterCube:
           this.GameState.SaveData.Artifacts.Add(this.treasureActorType);
           this.DotService.Say("DOT_ANCIENT_ARTIFACT", true, false).Ended = (Action) (() => this.DotService.Say("DOT_ALPHABET_A", true, true));
           break;
         case ActorType.TriSkull:
           this.GameState.SaveData.Artifacts.Add(this.treasureActorType);
           this.DotService.Say("DOT_ANCIENT_ARTIFACT", true, false).Ended = (Action) (() => this.DotService.Say("DOT_TRISKULL_A", true, false).Ended = (Action) (() => this.DotService.Say("DOT_TRISKULL_B", true, false).Ended = (Action) (() => this.DotService.Say("DOT_TRISKULL_C", true, false).Ended = (Action) (() => this.DotService.Say("DOT_TRISKULL_D", true, true)))));
           break;
         case ActorType.Tome:
           this.GameState.SaveData.Artifacts.Add(this.treasureActorType);
           this.DotService.Say("DOT_ANCIENT_ARTIFACT", true, false).Ended = (Action) (() => this.DotService.Say("DOT_TOME_A", true, false).Ended = (Action) (() => this.DotService.Say("DOT_TOME_B", true, true)));
           break;
         case ActorType.SecretCube:
           ++this.GameState.SaveData.SecretCubes;
           if (this.GameState.SaveData.SecretCubes > 32)
             this.GameState.SaveData.SecretCubes = 32;
           this.GameState.SaveData.ScoreDirty = true;
           this.treasureInstance.Collected = true;
           this.GomezService.OnCollectedAnti();
           if (this.GameState.SaveData.SecretCubes == 1)
           {
             this.DotService.Say("DOT_ANTI_A", true, false).Ended = (Action) (() => this.DotService.Say("DOT_ANTI_B", true, false).Ended = (Action) (() => this.DotService.Say("DOT_ANTI_C", true, false).Ended = (Action) (() => this.DotService.Say("DOT_ANTI_D", true, true).Ended = new Action(this.CheckCubes))));
             break;
           }
           else
           {
             this.CheckCubes();
             break;
           }
       }
       this.PlayerManager.ForcedTreasure = (TrileInstance) null;
       if (this.treasureActorType != ActorType.PieceOfHeart)
         this.GameState.OnHudElementChanged();
       this.chestAO = (ArtObjectInstance) null;
       if (this.treasureIsAo)
       {
         this.treasureAoInstance.SoftDispose();
         this.LevelManager.ArtObjects.Remove(this.treasureAoInstance.Id);
         this.treasureAoInstance = (ArtObjectInstance) null;
       }
       else if (!this.treasureIsMap && !this.treasureIsMail)
       {
         this.treasureInstance.Phi = 0.0f;
         this.treasureInstance.Collected = true;
         this.LevelManager.UpdateInstance(this.treasureInstance);
         this.LevelManager.ClearTrile(this.treasureInstance);
         this.treasureInstance = (TrileInstance) null;
       }
       this.GameState.Save();
     }
   }
   this.PlayerManager.Animation.Timing.Update(elapsed, 0.9f);
   return false;
 }
Exemplo n.º 8
0
 private void TryInitialize()
 {
   this.sBellHit = (SoundEffect[]) null;
   this.BellAo = Enumerable.FirstOrDefault<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObject.ActorType == ActorType.Bell));
   this.Enabled = this.BellAo != null;
   if (!this.Enabled)
     return;
   this.OriginalPosition = this.BellAo.Position;
   this.Hits.Clear();
   this.Hits.Add(Viewpoint.Front, 0);
   this.Hits.Add(Viewpoint.Back, 0);
   this.Hits.Add(Viewpoint.Left, 0);
   this.Hits.Add(Viewpoint.Right, 0);
   this.sBellHit = new SoundEffect[4]
   {
     this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/BellHit1"),
     this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/BellHit2"),
     this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/BellHit3"),
     this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/BellHit4")
   };
   this.Solved = this.GameState.SaveData.ThisLevel.InactiveArtObjects.Contains(this.BellAo.Id);
   if (!this.Solved)
     return;
   this.LevelManager.ArtObjects.Remove(this.BellAo.Id);
   this.BellAo.Dispose();
   this.LevelMaterializer.RegisterSatellites();
   if (!this.GameState.SaveData.ThisLevel.DestroyedTriles.Contains(new TrileEmplacement(this.OriginalPosition)))
   {
     Trile trile = Enumerable.FirstOrDefault<Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube));
     if (trile != null)
     {
       Vector3 position = this.OriginalPosition - Vector3.One / 2f;
       this.LevelManager.ClearTrile(new TrileEmplacement(position));
       TrileInstance toAdd;
       this.LevelManager.RestoreTrile(toAdd = new TrileInstance(position, trile.Id)
       {
         OriginalEmplacement = new TrileEmplacement(position)
       });
       toAdd.Foreign = true;
       if (toAdd.InstanceId == -1)
         this.LevelMaterializer.CullInstanceIn(toAdd);
     }
   }
   this.Enabled = false;
 }
Exemplo n.º 9
0
 private void TryInitialize()
 {
   this.Visible = this.Enabled = this.LevelManager.Name == "PYRAMID";
   this.Clear();
   if (!this.Enabled)
     return;
   this.MotherCubeAo = this.LevelManager.ArtObjects[217];
   this.OriginalPosition = this.MotherCubeAo.Position;
   this.RaysMesh = new Mesh()
   {
     Effect = (BaseEffect) new DefaultEffect.Textured(),
     Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/smooth_ray")),
     Blending = new BlendingMode?(BlendingMode.Additive),
     SamplerState = SamplerState.AnisotropicClamp,
     DepthWrites = false,
     AlwaysOnTop = true
   };
   this.FlareMesh = new Mesh()
   {
     Effect = (BaseEffect) new DefaultEffect.Textured(),
     Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/flare_alpha")),
     Blending = new BlendingMode?(BlendingMode.Alphablending),
     SamplerState = SamplerState.AnisotropicClamp,
     DepthWrites = false,
     AlwaysOnTop = true
   };
   this.FlareMesh.AddFace(Vector3.One, Vector3.Zero, FaceOrientation.Front, true);
   this.sRotationDrone = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Ending/Pyramid/MothercubeRotateDrone");
   this.sWhiteOut = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ending/Pyramid/WhiteOut");
   this.eRotationDrone = SoundEffectExtensions.EmitAt(this.sRotationDrone, this.OriginalPosition, true);
 }
Exemplo n.º 10
0
 private void TryInitialize()
 {
   this.TrackedStones.Clear();
   this.GrabSound = (SoundEffect) null;
   this.TurnLeft = (SoundEffect) null;
   this.TurnRight = (SoundEffect) null;
   this.sRumble = (SoundEffect) null;
   this.eRumble = (SoundEmitter) null;
   foreach (ArtObjectInstance ao in (IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
   {
     if (ao.ArtObject.ActorType == ActorType.Tombstone)
       this.TrackedStones.Add(new TombstonesHost.TombstoneState(this, ao));
   }
   this.SkullAo = Enumerable.SingleOrDefault<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObjectName == "GIANT_SKULLAO"));
   this.Enabled = this.Visible = this.TrackedStones.Count > 0 && this.SkullAo != null;
   if (!this.Enabled)
     return;
   int index = this.SkullAo.ActorSettings.AttachedGroup.Value;
   this.SkullTopLayer = Enumerable.ToArray<TrileInstance>(Enumerable.Where<TrileInstance>((IEnumerable<TrileInstance>) this.LevelManager.Groups[index].Triles, (Func<TrileInstance, bool>) (x => x.Trile.Faces[FaceOrientation.Back] == CollisionType.TopOnly)));
   this.SkullAttachedTriles = Enumerable.ToArray<TrileInstance>(Enumerable.Where<TrileInstance>((IEnumerable<TrileInstance>) this.LevelManager.Groups[index].Triles, (Func<TrileInstance, bool>) (x => x.Trile.Immaterial)));
   this.SkullAttachedTrilesOriginalStates = Enumerable.ToArray<Vector4>(Enumerable.Select<TrileInstance, Vector4>((IEnumerable<TrileInstance>) this.SkullAttachedTriles, (Func<TrileInstance, Vector4>) (x => new Vector4(x.Position, x.Phi))));
   this.GrabSound = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/GrabLever");
   this.TurnLeft = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Graveyard/TombRotateLeft");
   this.TurnRight = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Graveyard/TombRotateRight");
   this.sRumble = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/Rumble");
   this.eRumble = SoundEffectExtensions.Emit(this.sRumble, true, true);
   this.SkullRotates = Enumerable.Count<TombstonesHost.TombstoneState>((IEnumerable<TombstonesHost.TombstoneState>) this.TrackedStones, (Func<TombstonesHost.TombstoneState, bool>) (x => x.LastViewpoint == this.TrackedStones[0].LastViewpoint)) < 4;
   this.OriginalRotation = this.SkullAo.Rotation * Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f);
 }
Exemplo n.º 11
0
 private void TryInitialize()
 {
   if (this.eIdleSpin != null && this.eIdleSpin.Cue != null && (!this.eIdleSpin.Cue.IsDisposed && this.eIdleSpin.Cue.State != SoundState.Stopped))
     this.eIdleSpin.Cue.Stop(false);
   this.eIdleSpin = (SoundEmitter) null;
   this.rgbPlanes = (Mesh) null;
   this.particles = (PlaneParticleSystem) null;
   this.Phase = LesserWarp.Phases.None;
   this.sinceInitialized = 0.0f;
   this.GateAo = Enumerable.FirstOrDefault<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObject.ActorType == ActorType.LesserGate));
   if (this.GateAo == null)
     return;
   this.InitializeRgbGate();
   LesserWarp lesserWarp = this;
   Mesh mesh1 = new Mesh();
   Mesh mesh2 = mesh1;
   DefaultEffect.Textured textured1 = new DefaultEffect.Textured();
   textured1.Fullbright = true;
   DefaultEffect.Textured textured2 = textured1;
   mesh2.Effect = (BaseEffect) textured2;
   mesh1.DepthWrites = false;
   mesh1.Texture = (Dirtyable<Texture>) ((Texture) this.WhiteTexture);
   mesh1.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Right, -1.570796f);
   Mesh mesh3 = mesh1;
   lesserWarp.MaskMesh = mesh3;
   this.MaskMesh.AddFace(new Vector3(2f), Vector3.Zero, FaceOrientation.Front, true, true);
   this.MaskMesh.BakeTransformWithNormal<FezVertexPositionNormalTexture>();
   this.MaskMesh.Position = this.GateAo.Position - Vector3.UnitY * 1.25f;
   this.HasCubeShard = Enumerable.Any<TrileInstance>((IEnumerable<TrileInstance>) this.LevelManager.Triles.Values, (Func<TrileInstance, bool>) (x =>
   {
     if (ActorTypeExtensions.IsCubeShard(x.Trile.ActorSettings.Type))
       return (double) Vector3.Distance(x.Center, this.GateAo.Position) < 3.0;
     else
       return false;
   }));
   this.OriginalPosition = this.GateAo.Position;
   this.sRise = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Zu/LesserWarpRise");
   this.sLower = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Zu/LesserWarpLower");
   this.sActivate = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Zu/WarpGateActivate");
   this.eIdleSpin = SoundEffectExtensions.EmitAt(this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Zu/LesserWarpIdleSpin"), this.GateAo.Position, true, true);
 }
Exemplo n.º 12
0
 private void TryInitialize()
 {
   this.Enabled = this.LevelManager.Name == "CLOCK";
   this.RedAo = this.BlueAo = this.GreenAo = this.WhiteAo = (ArtObjectInstance) null;
   this.sTickTock = (SoundEffect) null;
   this.eTickTock = (SoundEmitter) null;
   if (!this.Enabled)
     return;
   foreach (ArtObjectInstance artObjectInstance in (IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
   {
     if (artObjectInstance.ArtObjectName == "CLOCKHAND_RAO")
       this.RedAo = artObjectInstance;
     if (artObjectInstance.ArtObjectName == "CLOCKHAND_GAO")
       this.GreenAo = artObjectInstance;
     if (artObjectInstance.ArtObjectName == "CLOCKHAND_BAO")
       this.BlueAo = artObjectInstance;
     if (artObjectInstance.ArtObjectName == "CLOCKHAND_WAO")
       this.WhiteAo = artObjectInstance;
   }
   this.RedOriginalRotation = this.RedAo.Rotation;
   this.BlueOriginalRotation = this.BlueAo.Rotation;
   this.GreenOriginalRotation = this.GreenAo.Rotation;
   this.WhiteOriginalRotation = this.WhiteAo.Rotation;
   this.RedOriginalPosition = this.RedAo.Position + 1.125f * Vector3.UnitX;
   this.GreenOriginalPosition = this.GreenAo.Position - 1.125f * Vector3.UnitX;
   this.BlueOriginalPosition = this.BlueAo.Position + 1.125f * Vector3.UnitZ;
   this.WhiteOriginalPosition = this.WhiteAo.Position - 1.125f * Vector3.UnitZ;
   this.RedGroup = this.LevelManager.Groups[23];
   this.BlueGroup = this.LevelManager.Groups[24];
   this.GreenGroup = this.LevelManager.Groups[25];
   this.WhiteGroup = this.LevelManager.Groups[26];
   this.RedTopMost = Enumerable.First<TrileInstance>((IEnumerable<TrileInstance>) this.RedGroup.Triles, (Func<TrileInstance, bool>) (x => x.Emplacement.Y == 58));
   this.BlueTopMost = Enumerable.First<TrileInstance>((IEnumerable<TrileInstance>) this.BlueGroup.Triles, (Func<TrileInstance, bool>) (x => x.Emplacement.Y == 58));
   this.GreenTopMost = Enumerable.First<TrileInstance>((IEnumerable<TrileInstance>) this.GreenGroup.Triles, (Func<TrileInstance, bool>) (x => x.Emplacement.Y == 58));
   this.WhiteTopMost = Enumerable.First<TrileInstance>((IEnumerable<TrileInstance>) this.WhiteGroup.Triles, (Func<TrileInstance, bool>) (x => x.Emplacement.Y == 58));
   if (this.GameState.SaveData.ThisLevel.InactiveArtObjects.Contains(this.RedAo.Id))
   {
     this.RedAo.Enabled = false;
     this.LevelManager.RemoveArtObject(this.RedAo);
   }
   if (this.GameState.SaveData.ThisLevel.InactiveArtObjects.Contains(this.GreenAo.Id))
   {
     this.GreenAo.Enabled = false;
     this.LevelManager.RemoveArtObject(this.GreenAo);
   }
   if (this.GameState.SaveData.ThisLevel.InactiveArtObjects.Contains(this.BlueAo.Id))
   {
     this.BlueAo.Enabled = false;
     this.LevelManager.RemoveArtObject(this.BlueAo);
   }
   if (this.GameState.SaveData.ThisLevel.InactiveArtObjects.Contains(this.WhiteAo.Id))
   {
     this.WhiteAo.Enabled = false;
     this.LevelManager.RemoveArtObject(this.WhiteAo);
   }
   TimeSpan timeSpan = TimeSpan.FromTicks((DateTime.UtcNow - DateTime.FromFileTimeUtc(this.GameState.SaveData.CreationTime)).Ticks);
   if (this.RedAo.Enabled)
   {
     float angle = FezMath.WrapAngle((float) ((double) FezMath.Round(timeSpan.TotalSeconds) / 60.0 * 6.28318548202515));
     this.lastRedAngle = angle;
     this.RedAo.Rotation = Quaternion.CreateFromAxisAngle(-Vector3.UnitZ, angle) * this.RedOriginalRotation;
   }
   if (!this.WhiteAo.Enabled && !this.BlueAo.Enabled && (!this.GreenAo.Enabled && !this.RedAo.Enabled))
     return;
   this.sTickTock = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/TickTockLoop");
   Waiters.Wait(FezMath.Frac(timeSpan.TotalSeconds), (Action) (() => this.eTickTock = SoundEffectExtensions.EmitAt(this.sTickTock, new Vector3(41.5f, 61.5f, 35.5f), true)));
 }
Exemplo n.º 13
0
 private TrileInstance TestSecretFor(bool condition, ArtObjectInstance ao, TrileInstance secretTrile, TrileInstance topMost)
 {
   Vector3 position = topMost.Position + Vector3.Up * 1.5f;
   if (condition)
   {
     if (secretTrile != null && secretTrile.Collected)
     {
       ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, ao));
       this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(ao.Id);
       ao.Enabled = false;
       this.TestAllSolved();
       this.LevelService.ResolvePuzzle();
       return (TrileInstance) null;
     }
     else
     {
       if (secretTrile == null)
       {
         secretTrile = new TrileInstance(position, Enumerable.FirstOrDefault<Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube)).Id);
         ServiceHelper.AddComponent((IGameComponent) new GlitchyRespawner(this.Game, secretTrile)
         {
           DontCullIn = true
         });
       }
       secretTrile.Position = position;
       if (!secretTrile.Hidden)
         this.LevelManager.UpdateInstance(secretTrile);
     }
   }
   else if (secretTrile != null)
   {
     if (secretTrile.Collected)
     {
       ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, ao));
       this.GameState.SaveData.ThisLevel.InactiveArtObjects.Add(ao.Id);
       ao.Enabled = false;
       this.TestAllSolved();
       this.LevelService.ResolvePuzzle();
       return (TrileInstance) null;
     }
     else
     {
       ServiceHelper.AddComponent((IGameComponent) new GlitchyDespawner(this.Game, secretTrile));
       TrileInstance rs = secretTrile;
       Vector3 p = position;
       Waiters.Interpolate(2.5, (Action<float>) (_ => rs.Position = p));
       return (TrileInstance) null;
     }
   }
   return secretTrile;
 }
Exemplo n.º 14
0
 public override void Initialize()
 {
   base.Initialize();
   ServiceHelper.AddComponent((IGameComponent) (this.Starfield = new StarField(this.Game)
   {
     Opacity = 0.0f,
     HasHorizontalTrails = true,
     FollowCamera = true
   }));
   ServiceHelper.AddComponent((IGameComponent) (this.SfRenderer = new EldersHexahedron.StarfieldRenderer(this.Game, this)));
   this.StatuePlanes = Enumerable.ToArray<BackgroundPlane>(Enumerable.Where<BackgroundPlane>((IEnumerable<BackgroundPlane>) this.LevelManager.BackgroundPlanes.Values, (Func<BackgroundPlane, bool>) (x => x.Id >= 0)));
   this.DealGlassesPlane = new Mesh()
   {
     Effect = (BaseEffect) new DefaultEffect.Textured(),
     DepthWrites = false,
     AlwaysOnTop = false,
     Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.CurrentLevel.Load<Texture2D>("Other Textures" + (this.GameState.SaveData.Finished64 ? "/deal_with_3d" : "/deal_with_it"))),
     SamplerState = SamplerState.PointClamp
   };
   this.DealGlassesPlane.AddFace(new Vector3(1f, 0.25f, 1f), Vector3.Zero, FaceOrientation.Right, true, true);
   ArtObject artObject = this.CMProvider.CurrentLevel.Load<ArtObject>("Art Objects/TINY_CHAPEAUAO");
   int key = IdentifierPool.FirstAvailable<ArtObjectInstance>(this.LevelManager.ArtObjects);
   this.TinyChapeau = new ArtObjectInstance(artObject)
   {
     Id = key
   };
   this.LevelManager.ArtObjects.Add(key, this.TinyChapeau);
   this.TinyChapeau.Initialize();
   this.TinyChapeau.Hidden = true;
   this.TinyChapeau.ArtObject.Group.Position = new Vector3(-0.125f, 0.375f, -0.125f);
   this.TinyChapeau.ArtObject.Group.BakeTransformInstanced<VertexPositionNormalTextureInstance, Matrix>();
   this.BeamMesh = new Mesh()
   {
     Effect = (BaseEffect) new DefaultEffect.Textured(),
     DepthWrites = false,
     AlwaysOnTop = false,
     Material = {
       Diffuse = new Vector3(221f, 178f, (float) byte.MaxValue) / (float) byte.MaxValue
     }
   };
   this.BeamMesh.AddFace(new Vector3(1f, 1f, 1f), Vector3.Zero, FaceOrientation.Right, true, true).Texture = (Texture) this.CMProvider.CurrentLevel.Load<Texture2D>("Other Textures/VerticalGradient");
   Group group = this.BeamMesh.AddFace(new Vector3(2f, 1f, 2f), Vector3.Zero, FaceOrientation.Right, true, true);
   group.Texture = (Texture) this.CMProvider.CurrentLevel.Load<Texture2D>("Other Textures/HorizontalGradient");
   group.Material = new Material()
   {
     Opacity = 0.4f,
     Diffuse = new Vector3(221f, 178f, (float) byte.MaxValue) / (float) byte.MaxValue
   };
   group.Enabled = false;
   this.BeamMask = new Mesh()
   {
     Effect = (BaseEffect) new DefaultEffect.Textured(),
     DepthWrites = false,
     AlwaysOnTop = false
   };
   this.BeamMask.AddFace(new Vector3(1f, 1f, 1f), Vector3.Zero, FaceOrientation.Right, true, true);
   this.MatrixMesh = new Mesh()
   {
     Effect = (BaseEffect) new MatrixEffect(),
     DepthWrites = false,
     AlwaysOnTop = false,
     Blending = new BlendingMode?(BlendingMode.Multiply2X)
   };
   this.RaysMesh = new Mesh()
   {
     Effect = (BaseEffect) new DefaultEffect.VertexColored(),
     DepthWrites = false,
     AlwaysOnTop = false,
     Blending = new BlendingMode?(BlendingMode.Alphablending)
   };
   this.FlareMesh = new Mesh()
   {
     Effect = (BaseEffect) new DefaultEffect.Textured(),
     DepthWrites = false,
     AlwaysOnTop = false,
     SamplerState = SamplerState.LinearClamp,
     Blending = new BlendingMode?(BlendingMode.Alphablending),
     Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.CurrentLevel.Load<Texture2D>("Other Textures/flare_alpha"))
   };
   this.FlareMesh.AddFace(new Vector3(1f, 1f, 1f), Vector3.Zero, FaceOrientation.Right, true, true);
   this.TrialRaysMesh = new Mesh()
   {
     Effect = (BaseEffect) new DefaultEffect.VertexColored(),
     Blending = new BlendingMode?(BlendingMode.Additive),
     SamplerState = SamplerState.AnisotropicClamp,
     DepthWrites = false,
     AlwaysOnTop = true
   };
   if (this.GameState.IsTrialMode)
     this.TrialRaysMesh.Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/smooth_ray"));
   this.TrialFlareMesh = new Mesh()
   {
     Effect = (BaseEffect) new DefaultEffect.Textured(),
     Texture = (Dirtyable<Texture>) ((Texture) this.CMProvider.Global.Load<Texture2D>("Other Textures/flare_alpha")),
     Blending = new BlendingMode?(BlendingMode.Alphablending),
     SamplerState = SamplerState.AnisotropicClamp,
     DepthWrites = false,
     AlwaysOnTop = true
   };
   this.TrialFlareMesh.AddFace(Vector3.One, Vector3.Zero, FaceOrientation.Right, true);
   this.LoadSounds();
   this.AoInstance.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 1.570796f) * Quaternion.CreateFromAxisAngle(Vector3.Right, (float) Math.Asin(Math.Sqrt(2.0) / Math.Sqrt(3.0))) * Quaternion.CreateFromAxisAngle(Vector3.Up, 0.7853982f);
   this.Origin = this.AoInstance.Position;
   this.AoRotationOrigin = Quaternion.CreateFromAxisAngle(Vector3.Forward, 0.7853982f) * Quaternion.CreateFromAxisAngle(Vector3.Up, 0.7853982f);
   this.AoInstance.Material = new Material();
   this.PlayerManager.Position = new Vector3(18.5f, 879.0 / 32.0, 34.5f);
   this.PlayerManager.Position = this.PlayerManager.Position * Vector3.UnitY + FezMath.XZMask * this.AoInstance.Position;
   this.GomezOrigin = this.PlayerManager.Position;
   this.CameraManager.Center = new Vector3(18.5f, 879.0 / 32.0, 34.5f);
   this.CameraManager.Center = this.CameraManager.Center * Vector3.UnitY + FezMath.XZMask * this.AoInstance.Position + new Vector3(0.0f, 4f, 0.0f);
   this.CameraManager.SnapInterpolation();
   this.CameraOrigin = this.CameraManager.Center;
   while (!this.PlayerManager.CanControl)
     this.PlayerManager.CanControl = true;
   this.PlayerManager.CanControl = false;
   this.CameraManager.Constrained = true;
   this.PlayerManager.HideFez = true;
   this.GenerateCubes();
   for (int index = 1; index < 9; ++index)
     this.MatrixWords[index - 1] = this.CMProvider.CurrentLevel.Load<Texture2D>("Other Textures/zuish_matrix/" + (object) index);
   this.SpinSpeed = 225f;
   SoundEffectExtensions.Emit(this.sHexSlowDown);
   this.eAmbientHex = SoundEffectExtensions.Emit(this.sAmbientHex, true, 0.0f, 0.5f);
   Vector3 vector3 = -FezMath.ForwardVector(this.CameraManager.Viewpoint) * 4f;
   IPlaneParticleSystems planeParticleSystems = this.PlaneParticleSystems;
   EldersHexahedron eldersHexahedron = this;
   Game game = this.Game;
   int maximumCount = 200;
   PlaneParticleSystemSettings particleSystemSettings = new PlaneParticleSystemSettings();
   particleSystemSettings.SpawnVolume = new BoundingBox()
   {
     Min = this.PlayerManager.Position + new Vector3(-1f, 5f, -1f) + vector3,
     Max = this.PlayerManager.Position + new Vector3(1f, 20f, 1f) + vector3
   };
   particleSystemSettings.Velocity.Base = new Vector3(0.0f, -0.5f, 0.0f);
   particleSystemSettings.Velocity.Variation = new Vector3(0.0f, -0.25f, 0.1f);
   particleSystemSettings.SpawningSpeed = 12f;
   particleSystemSettings.ParticleLifetime = 15f;
   particleSystemSettings.Acceleration = -0.1f;
   particleSystemSettings.SizeBirth = (VaryingVector3) new Vector3(0.125f, 0.125f, 0.125f);
   particleSystemSettings.ColorBirth = (VaryingColor) Color.Black;
   particleSystemSettings.ColorLife.Base = new Color(0.6f, 0.6f, 0.6f, 1f);
   particleSystemSettings.ColorLife.Variation = new Color(0.1f, 0.1f, 0.1f, 0.0f);
   particleSystemSettings.ColorDeath = (VaryingColor) Color.Black;
   particleSystemSettings.FullBright = true;
   particleSystemSettings.RandomizeSpawnTime = true;
   particleSystemSettings.FadeInDuration = 0.25f;
   particleSystemSettings.FadeOutDuration = 0.5f;
   particleSystemSettings.Texture = this.CMProvider.Global.Load<Texture2D>("Background Planes/dust_particle");
   particleSystemSettings.BlendingMode = BlendingMode.Additive;
   PlaneParticleSystemSettings settings = particleSystemSettings;
   PlaneParticleSystem planeParticleSystem1;
   PlaneParticleSystem planeParticleSystem2 = planeParticleSystem1 = new PlaneParticleSystem(game, maximumCount, settings);
   eldersHexahedron.Particles = planeParticleSystem1;
   PlaneParticleSystem system = planeParticleSystem2;
   planeParticleSystems.Add(system);
   this.Particles.Enabled = false;
   this.LevelManager.LevelChanged += new Action(this.Kill);
 }
Exemplo n.º 15
0
 public EldersHexahedron(Game game, ArtObjectInstance aoInstance)
   : base(game)
 {
   this.UpdateOrder = 20;
   this.DrawOrder = 101;
   this.AoInstance = aoInstance;
 }
Exemplo n.º 16
0
 private void TryInitialize()
 {
   this.Enabled = false;
   this.ArtObject = Enumerable.FirstOrDefault<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x =>
   {
     if (x.ArtObject.ActorType == ActorType.Rumbler)
       return x.ActorSettings.VibrationPattern != null;
     else
       return false;
   }));
   if (this.ArtObject != null)
   {
     this.Enabled = true;
     if (this.GameState.SaveData.ThisLevel.InactiveArtObjects.Contains(this.ArtObject.Id))
     {
       if (this.ArtObject.ActorSettings.AttachedGroup.HasValue)
       {
         int key = this.ArtObject.ActorSettings.AttachedGroup.Value;
         foreach (TrileInstance instance in this.LevelManager.Groups[this.ArtObject.ActorSettings.AttachedGroup.Value].Triles.ToArray())
           this.LevelManager.ClearTrile(instance);
         this.LevelManager.Groups.Remove(key);
       }
       this.LevelManager.ArtObjects.Remove(this.ArtObject.Id);
       this.ArtObject.Dispose();
       this.LevelMaterializer.RegisterSatellites();
       Vector3 position1 = this.ArtObject.Position;
       if (!this.GameState.SaveData.ThisLevel.DestroyedTriles.Contains(new TrileEmplacement(position1 - Vector3.One / 2f)))
       {
         Trile trile = Enumerable.FirstOrDefault<Trile>(this.LevelManager.ActorTriles(ActorType.SecretCube));
         if (trile != null)
         {
           Vector3 position2 = position1 - Vector3.One / 2f;
           this.LevelManager.ClearTrile(new TrileEmplacement(position2));
           TrileInstance toAdd;
           this.LevelManager.RestoreTrile(toAdd = new TrileInstance(position2, trile.Id)
           {
             OriginalEmplacement = new TrileEmplacement(position2)
           });
           if (toAdd.InstanceId == -1)
             this.LevelMaterializer.CullInstanceIn(toAdd);
         }
       }
       this.Enabled = false;
     }
   }
   if (this.Enabled)
   {
     this.eForkRumble = SoundEffectExtensions.Emit(this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Zu/ForkRumble"), true, 0.0f, 0.0f);
     this.ActivateSound = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/ForkActivate");
     this.ArtObject.ActorSettings.VibrationPattern = Util.JoinArrays<VibrationMotor>(this.ArtObject.ActorSettings.VibrationPattern, new VibrationMotor[3]);
   }
   else
   {
     this.ActivateSound = (SoundEffect) null;
     this.eForkRumble = (SoundEmitter) null;
   }
 }
Exemplo n.º 17
0
 protected override void Begin()
 {
   base.Begin();
   this.SinceStarted = TimeSpan.Zero;
   this.PlayerManager.LookingDirection = HorizontalDirection.Left;
   this.SinceRisen = TimeSpan.Zero;
   this.Phase = GateWarp.Phases.Rise;
   foreach (SoundEmitter soundEmitter in this.SoundManager.Emitters)
     soundEmitter.FadeOutAndDie(2f);
   this.SoundManager.FadeFrequencies(true, 2f);
   this.SoundManager.FadeVolume(this.SoundManager.MusicVolumeFactor, 0.0f, 3f);
   SoundEffectExtensions.EmitAt(this.WarpSound, this.PlayerManager.Position);
   this.rgbPlanes = (Mesh) null;
   this.particles = (PlaneParticleSystem) null;
   this.sinceInitialized = 0.0f;
   this.originalCenter = this.CameraManager.Center;
   this.CameraManager.Constrained = true;
   this.GateAo = Enumerable.FirstOrDefault<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values, (Func<ArtObjectInstance, bool>) (x => x.ArtObject.ActorType == ActorType.WarpGate));
   if (this.GateAo == null || this.GameState.SaveData.UnlockedWarpDestinations.Count <= 1)
     return;
   this.InitializeRgbGate();
 }
Exemplo n.º 18
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();
 }
Exemplo n.º 19
0
 protected override void TestConditions()
 {
   if (!this.PlayerManager.Grounded)
     this.UnDotize();
   else if (this.PlayerManager.CarriedInstance != null)
   {
     this.UnDotize();
   }
   else
   {
     bool flag = false;
     foreach (NearestTriles nearestTriles in this.PlayerManager.AxisCollision.Values)
     {
       TrileInstance trileInstance = nearestTriles.Surface;
       if (trileInstance != null)
       {
         Trile trile = trileInstance.Trile;
         FaceOrientation faceOrientation = FezMath.OrientationFromPhi(FezMath.ToPhi(trile.ActorSettings.Face) + trileInstance.Phi);
         if (ActorTypeExtensions.IsDoor(trile.ActorSettings.Type) && faceOrientation == FezMath.VisibleOrientation(this.CameraManager.Viewpoint))
         {
           flag = this.GameState.SaveData.Keys > 0 && this.LevelManager.Name != "VILLAGEVILLE_2D" || trile.ActorSettings.Type == ActorType.UnlockedDoor;
           this.isUnlocked = trile.ActorSettings.Type == ActorType.UnlockedDoor;
           this.doorBottom = trileInstance;
           break;
         }
       }
     }
     if (!flag)
       this.UnDotize();
     else if (this.doorBottom.ActorSettings.Inactive)
     {
       this.UnDotize();
     }
     else
     {
       if (!this.PlayerManager.HideFez && this.PlayerManager.CanControl && (!this.DotManager.PreventPoI && this.doorBottom.Trile.ActorSettings.Type == ActorType.Door))
       {
         this.DotManager.Behaviour = DotHost.BehaviourType.ThoughtBubble;
         this.DotManager.FaceButton = DotFaceButton.Up;
         this.DotManager.ComeOut();
         if (this.DotManager.Owner != this)
           this.DotManager.Hey();
         this.DotManager.Owner = (object) this;
       }
       if (this.GameState.IsTrialMode && this.LevelManager.Name == "trial/VILLAGEVILLE_2D" || this.InputManager.ExactUp != FezButtonState.Pressed)
         return;
       TrileGroup trileGroup1 = (TrileGroup) null;
       this.aoInstance = (ArtObjectInstance) null;
       foreach (TrileGroup trileGroup2 in (IEnumerable<TrileGroup>) this.LevelManager.Groups.Values)
       {
         if (trileGroup2.Triles.Contains(this.doorBottom))
         {
           trileGroup1 = trileGroup2;
           break;
         }
       }
       if (trileGroup1 != null)
       {
         foreach (ArtObjectInstance artObjectInstance in (IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
         {
           int? attachedGroup = artObjectInstance.ActorSettings.AttachedGroup;
           int id = trileGroup1.Id;
           if ((attachedGroup.GetValueOrDefault() != id ? 0 : (attachedGroup.HasValue ? 1 : 0)) != 0)
           {
             this.aoInstance = artObjectInstance;
             break;
           }
         }
         if (this.aoInstance != null)
         {
           this.aoInitialRotation = this.aoInstance.Rotation;
           this.initialAoPosition = this.aoInstance.Position;
         }
       }
       this.WalkTo.Destination = new Func<Vector3>(this.GetDestination);
       this.PlayerManager.Action = ActionType.WalkingTo;
       this.WalkTo.NextAction = ActionType.OpeningDoor;
     }
   }
 }
Exemplo n.º 20
0
 public SpinBlockState(List<TrileInstance> triles, ArtObjectInstance aoInstance, SoundEffect soundEffect)
 {
   ServiceHelper.InjectServices((object) this);
   this.Triles = triles;
   this.ArtObject = aoInstance;
   this.OriginalPosition = this.ArtObject.Position;
   if (this.ArtObject.ActorSettings.OffCenter)
     this.RotationOffset = this.ArtObject.ActorSettings.RotationCenter - this.ArtObject.Position;
   if (this.ArtObject.ActorSettings.SpinView == Viewpoint.None)
     this.ArtObject.ActorSettings.SpinView = Viewpoint.Front;
   foreach (TrileInstance trileInstance in this.Triles)
     trileInstance.Unsafe = true;
   this.SoundEffect = soundEffect;
   this.SinceChanged -= TimeSpan.FromSeconds((double) this.ArtObject.ActorSettings.SpinOffset);
   this.IsRotato = this.ArtObject.ActorSettings.SpinView == Viewpoint.Up || this.ArtObject.ActorSettings.SpinView == Viewpoint.Down;
 }
Exemplo n.º 21
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))));
 }
Exemplo n.º 22
0
 private void DoTomeOpen(ArtObjectInstance ao, float s)
 {
   Vector3 vector3_1 = Vector3.Transform(MenuCubeFaceExtensions.GetForward(this.zoomedFace), this.AoInstance.Rotation);
   Vector3 vector3_2 = Vector3.Transform(MenuCubeFaceExtensions.GetRight(this.zoomedFace), this.AoInstance.Rotation);
   Vector3 position = -vector3_1 * 13f / 16f + vector3_2 * 2f / 16f;
   Vector3 scale;
   Quaternion rotation;
   Vector3 translation;
   (Matrix.CreateFromQuaternion(Quaternion.CreateFromAxisAngle(Vector3.Up, 3.141593f) * this.AoInstance.Rotation) * Matrix.CreateTranslation(position) * Matrix.CreateFromAxisAngle(Vector3.UnitY, -2.356194f * s) * Matrix.CreateTranslation(this.AoInstance.Position + vector3_1 * 12f - position)).Decompose(out scale, out rotation, out translation);
   ao.Position = translation;
   ao.Rotation = rotation;
   this.TomePages.Position = translation;
 }
Exemplo n.º 23
0
 private void Clear()
 {
   this.MotherCubeAo = (ArtObjectInstance) null;
   this.DoCapture = false;
   this.TimeAccumulator = 0.0f;
   if (this.RaysMesh != null)
     this.RaysMesh.Dispose();
   if (this.FlareMesh != null)
     this.FlareMesh.Dispose();
   this.FlareMesh = this.RaysMesh = (Mesh) null;
   this.sRotationDrone = this.sWhiteOut = (SoundEffect) null;
   if (this.eRotationDrone == null || this.eRotationDrone.Dead)
     return;
   this.eRotationDrone.FadeOutAndDie(0.0f);
 }
Exemplo n.º 24
0
 private void DoArtifactZoom(ArtObjectInstance ao)
 {
   if (this.zoomed)
   {
     ao.Material = new Material();
     this.originalObjectPosition = ao.Position;
     MenuCube menuCube1 = this;
     int num1 = menuCube1.TomeZoom | ao.ArtObjectName == "TOME_BAO" ? 1 : 0;
     menuCube1.TomeZoom = num1 != 0;
     MenuCube menuCube2 = this;
     int num2 = menuCube2.NumberZoom | ao.ArtObjectName == "NUMBER_CUBEAO" ? 1 : 0;
     menuCube2.NumberZoom = num2 != 0;
     MenuCube menuCube3 = this;
     int num3 = menuCube3.LetterZoom | ao.ArtObjectName == "LETTER_CUBEAO" ? 1 : 0;
     menuCube3.LetterZoom = num3 != 0;
     this.ZoomedArtifact = ao;
   }
   else
   {
     this.NumberZoom = this.LetterZoom = this.TomeZoom = false;
     this.codeInputs.Clear();
     this.ZoomedArtifact = (ArtObjectInstance) null;
   }
   Waiters.Interpolate(0.25, (Action<float>) (s =>
   {
     s = Easing.EaseOut((double) s, EasingType.Quadratic);
     if (!this.zoomed)
       s = 1f - s;
     Vector2 local_0 = ActorTypeExtensions.GetArtifactOffset(ao.ArtObject.ActorType);
     this.AoInstance.Material.Opacity = FezMath.Saturate((float) (1.0 - (double) s * 1.5));
     this.AoInstance.MarkDirty();
     ao.Position = Vector3.Lerp(this.originalObjectPosition, this.AoInstance.Position + Vector3.Transform(MenuCubeFaceExtensions.GetForward(this.zoomedFace), this.AoInstance.Rotation) * 12f, s);
     this.CameraManager.Center = Vector3.Lerp(this.AoInstance.Position, ao.Position - Vector3.Transform(FezMath.XZMask * local_0.X / 16f, this.AoInstance.Rotation) - Vector3.UnitY * local_0.Y / 16f, s);
     this.CameraManager.Radius = MathHelper.Lerp(17.82f, 4.192941f, Easing.EaseIn((double) s, EasingType.Quadratic));
   }), (Action) (() =>
   {
     if (!this.zoomed)
     {
       ao.Material = this.AoInstance.Material;
       this.GameState.MenuCubeIsZoomed = false;
     }
     this.zooming = false;
   }));
 }
Exemplo n.º 25
0
 public ValveState(ValvesBoltsTimeswitchesHost host, ArtObjectInstance ao)
 {
   ServiceHelper.InjectServices((object) this);
   this.Host = host;
   this.ArtObject = ao;
   this.IsBolt = this.ArtObject.ArtObject.ActorType == ActorType.BoltHandle;
   this.IsTimeswitch = this.ArtObject.ArtObject.ActorType == ActorType.Timeswitch;
   BoundingBox boundingBox = new BoundingBox(this.ArtObject.Position - this.ArtObject.ArtObject.Size / 2f, this.ArtObject.Position + this.ArtObject.ArtObject.Size / 2f);
   if (this.ArtObject.ActorSettings.AttachedGroup.HasValue)
     this.AttachedGroup = this.LevelManager.Groups[this.ArtObject.ActorSettings.AttachedGroup.Value];
   if (this.IsTimeswitch)
   {
     this.eTimeswitchWindBack = SoundEffectExtensions.EmitAt(this.Host.TimeswitchWindBackSound, ao.Position, true, true);
     foreach (ArtObjectInstance artObjectInstance in (IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
     {
       if (artObjectInstance != ao && artObjectInstance.ArtObject.ActorType == ActorType.TimeswitchMovingPart)
       {
         BoundingBox box = new BoundingBox(artObjectInstance.Position - artObjectInstance.ArtObject.Size / 2f, artObjectInstance.Position + artObjectInstance.ArtObject.Size / 2f);
         if (boundingBox.Intersects(box))
         {
           this.TimeswitchScrewAo = artObjectInstance;
           break;
         }
       }
     }
   }
   int num1;
   if (!this.IsBolt && !this.IsTimeswitch && (this.GameState.SaveData.ThisLevel.PivotRotations.TryGetValue(this.ArtObject.Id, out num1) && num1 != 0))
   {
     int num2 = Math.Abs(num1);
     int num3 = Math.Sign(num1);
     for (int index = 0; index < num2; ++index)
       this.ArtObject.Rotation *= Quaternion.CreateFromAxisAngle(Vector3.UnitY, 1.570796f * (float) num3);
   }
   if (this.IsBolt)
   {
     foreach (TrileInstance instance in this.AttachedGroup.Triles)
       instance.PhysicsState = new InstancePhysicsState(instance);
   }
   foreach (Volume volume in (IEnumerable<Volume>) this.LevelManager.Volumes.Values)
   {
     Vector3 vector3 = FezMath.Abs(volume.To - volume.From);
     if ((double) vector3.X == 3.0 && (double) vector3.Z == 3.0 && ((double) vector3.Y == 1.0 && boundingBox.Contains(volume.BoundingBox) == ContainmentType.Contains))
     {
       this.CenterOffset = (volume.From + volume.To) / 2f - this.ArtObject.Position;
       break;
     }
   }
 }
Exemplo n.º 26
0
 protected override void TestConditions()
 {
   if (this.PlayerManager.Action == ActionType.OpeningTreasure || this.PlayerManager.Action == ActionType.FindingTreasure || (this.PlayerManager.Action == ActionType.ReadingSign || this.PlayerManager.Action == ActionType.FreeFalling) || (this.PlayerManager.Action == ActionType.Dying || this.GameState.InFpsMode))
     return;
   TrileInstance trileInstance = this.PlayerManager.AxisCollision[VerticalDirection.Up].Surface;
   if (trileInstance != null && !trileInstance.Hidden && ActorTypeExtensions.IsTreasure(trileInstance.Trile.ActorSettings.Type))
   {
     this.treasureIsMap = this.treasureIsAo = false;
     this.treasureIsAo = false;
     this.chestAO = (ArtObjectInstance) null;
     this.treasureInstance = trileInstance;
     this.treasureTrile = trileInstance.Trile;
     this.treasureActorType = this.treasureTrile.ActorSettings.Type;
     this.PlayerManager.Action = ActionType.FindingTreasure;
     this.sinceCollect = TimeSpan.Zero;
     this.oldDepth = FezMath.Dot(this.PlayerManager.Position, FezMath.DepthMask(this.CameraManager.Viewpoint));
     this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + this.treasureInstance.Position * FezMath.DepthMask(this.CameraManager.Viewpoint) + 2f * -FezMath.ForwardVector(this.CameraManager.Viewpoint);
   }
   else
   {
     foreach (Mesh mesh in this.FloatingMaps)
     {
       Vector3 vector3_1 = new Vector3(0.75f);
       Vector3 a = FezMath.Abs(mesh.Position - this.PlayerManager.Center);
       if ((double) FezMath.Dot(a, FezMath.SideMask(this.CameraManager.Viewpoint)) < (double) vector3_1.X && (double) a.Y < (double) vector3_1.Y)
       {
         Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint);
         NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.PlayerManager.Position);
         if (nearestTriles.Deep != null)
         {
           Vector3 vector3_2 = nearestTriles.Deep.Center - nearestTriles.Deep.TransformedSize * b / 2f;
           if ((double) FezMath.Dot(mesh.Position - b - vector3_2, b) > 0.0)
             continue;
         }
         this.treasureIsMap = true;
         this.treasureIsAo = false;
         this.chestAO = (ArtObjectInstance) null;
         this.treasureAo = ((OpenTreasure.TreasureActorSettings) mesh.CustomData).ArtObject;
         this.treasureAoInstance = ((OpenTreasure.TreasureActorSettings) mesh.CustomData).AoInstance;
         this.treasureActorType = this.treasureAo.ActorType;
         this.PlayerManager.Action = ActionType.FindingTreasure;
         this.sinceCollect = TimeSpan.Zero;
         this.oldDepth = FezMath.Dot(this.PlayerManager.Position, FezMath.DepthMask(this.CameraManager.Viewpoint));
         this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + mesh.Position * FezMath.DepthMask(this.CameraManager.Viewpoint) + 2f * -FezMath.ForwardVector(this.CameraManager.Viewpoint);
         return;
       }
     }
     if (!this.PlayerManager.Grounded || this.PlayerManager.Background)
       return;
     this.chestAO = (ArtObjectInstance) null;
     foreach (ArtObjectInstance artObjectInstance in this.LevelChests)
     {
       if (artObjectInstance.Visible && !artObjectInstance.ActorSettings.Inactive)
       {
         Vector3 vector3_1 = artObjectInstance.ArtObject.Size / 2f;
         Vector3 a = FezMath.Abs(artObjectInstance.Position - this.PlayerManager.Center);
         if ((double) FezMath.Dot(a, FezMath.SideMask(this.CameraManager.Viewpoint)) < (double) vector3_1.X && (double) a.Y < (double) vector3_1.Y)
         {
           Vector3 b = FezMath.ForwardVector(this.CameraManager.Viewpoint);
           NearestTriles nearestTriles = this.LevelManager.NearestTrile(this.PlayerManager.Position);
           if (nearestTriles.Deep != null)
           {
             Vector3 vector3_2 = nearestTriles.Deep.Center - nearestTriles.Deep.TransformedSize * b / 2f;
             if ((double) FezMath.Dot(artObjectInstance.Position - b - vector3_2, b) > 0.0)
               continue;
           }
           if (FezMath.AsViewpoint(FezMath.OrientationFromDirection(FezMath.AlmostClamp(Vector3.Transform(Vector3.UnitZ, artObjectInstance.Rotation)))) == this.CameraManager.Viewpoint)
           {
             this.chestAO = artObjectInstance;
             this.sinceCollect = TimeSpan.Zero;
             break;
           }
         }
       }
     }
     if (this.chestAO == null || this.InputManager.GrabThrow != FezButtonState.Pressed)
       return;
     this.GomezService.OnOpenTreasure();
     Volume volume;
     if ((volume = Enumerable.FirstOrDefault<Volume>((IEnumerable<Volume>) this.PlayerManager.CurrentVolumes, (Func<Volume, bool>) (x =>
     {
       if (x.ActorSettings != null && x.ActorSettings.IsPointOfInterest)
         return (double) Vector3.DistanceSquared(FezMath.GetCenter(x.BoundingBox), this.chestAO.Position) < 2.0;
       else
         return false;
     }))) != null)
     {
       volume.Enabled = false;
       this.GameState.SaveData.ThisLevel.InactiveVolumes.Add(volume.Id);
     }
     this.PlayerManager.Action = ActionType.OpeningTreasure;
   }
 }
Exemplo n.º 27
0
        public override void Initialize() {
            base.Initialize();

            LevelEditorOptions.Initialize();

            Scheduled = new List<Action>();

            #if FNA
            TextInputEXT.TextInput += OnTextInput;
            SDL.SDL_StartTextInput();
            #else
            Game.Window.TextInput += OnTextInput;
            #endif

            Widgets = new List<GuiWidget>();

            ButtonWidget button;

            //TOP BAR
            Widgets.Add(TopBarWidget = new TopBarWidget(Game));

            TopBarWidget.Widgets.Add(button = new ButtonWidget(Game, "File"));
            button.Background.A = 0;

            button.Widgets.Add(new ButtonWidget(Game, "New", delegate() {
                ContainerWidget window;
                Widgets.Add(window = new ContainerWidget(Game) {
                    Size = new Vector2(256f, 144f),
                    Label = "New level"
                });
                window.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (window.Size.X / 2);
                window.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (window.Size.Y / 2);
                WindowHeaderWidget windowHeader;
                window.Widgets.Add(windowHeader = new WindowHeaderWidget(Game));

                ButtonWidget windowLabelName;
                window.Widgets.Add(windowLabelName = new ButtonWidget(Game, "Name:") {
                    Background = new Color(DefaultBackground, 0f),
                    Size = new Vector2(96f, 24f),
                    UpdateBounds = false,
                    LabelCentered = false,
                    Position = new Vector2(0f, 0f)
                });
                TextFieldWidget windowFieldName;
                window.Widgets.Add(windowFieldName = new TextFieldWidget(Game) {
                    Size = new Vector2(window.Size.X - windowLabelName.Size.X, 24f),
                    UpdateBounds = false,
                    Position = new Vector2(windowLabelName.Size.X, windowLabelName.Position.Y)
                });
                windowFieldName.Fill(ContentPaths.Levels);

                ButtonWidget windowLabelWidth;
                window.Widgets.Add(windowLabelWidth = new ButtonWidget(Game, "Width:") {
                    Background = new Color(DefaultBackground, 0f),
                    Size = new Vector2(96f, 24f),
                    UpdateBounds = false,
                    LabelCentered = false,
                    Position = new Vector2(0f, 24f)
                });
                TextFieldWidget windowFieldWidth;
                window.Widgets.Add(windowFieldWidth = new TextFieldWidget(Game) {
                    Size = new Vector2(window.Size.X - windowLabelWidth.Size.X, 24f),
                    UpdateBounds = false,
                    Position = new Vector2(windowLabelWidth.Size.X, windowLabelWidth.Position.Y)
                });

                ButtonWidget windowLabelHeight;
                window.Widgets.Add(windowLabelHeight = new ButtonWidget(Game, "Height:") {
                    Background = new Color(DefaultBackground, 0f),
                    Size = new Vector2(96f, 24f),
                    UpdateBounds = false,
                    LabelCentered = false,
                    Position = new Vector2(0f, 48f)
                });
                TextFieldWidget windowFieldHeight;
                window.Widgets.Add(windowFieldHeight = new TextFieldWidget(Game) {
                    Size = new Vector2(window.Size.X - windowLabelHeight.Size.X, 24f),
                    UpdateBounds = false,
                    Position = new Vector2(windowLabelHeight.Size.X, windowLabelHeight.Position.Y)
                });

                ButtonWidget windowLabelDepth;
                window.Widgets.Add(windowLabelDepth = new ButtonWidget(Game, "Depth:") {
                    Background = new Color(DefaultBackground, 0f),
                    Size = new Vector2(96f, 24f),
                    UpdateBounds = false,
                    LabelCentered = false,
                    Position = new Vector2(0f, 72f)
                });
                TextFieldWidget windowFieldDepth;
                window.Widgets.Add(windowFieldDepth = new TextFieldWidget(Game) {
                    Size = new Vector2(window.Size.X - windowLabelDepth.Size.X, 24f),
                    UpdateBounds = false,
                    Position = new Vector2(windowLabelDepth.Size.X, windowLabelDepth.Position.Y)
                });

                ButtonWidget windowLabelTrileset;
                window.Widgets.Add(windowLabelTrileset = new ButtonWidget(Game, "Trileset:") {
                    Background = new Color(DefaultBackground, 0f),
                    Size = new Vector2(96f, 24f),
                    UpdateBounds = false,
                    LabelCentered = false,
                    Position = new Vector2(0f, 96f)
                });
                TextFieldWidget windowFieldTrileset;
                window.Widgets.Add(windowFieldTrileset = new TextFieldWidget(Game) {
                    Size = new Vector2(window.Size.X - windowLabelTrileset.Size.X, 24f),
                    UpdateBounds = false,
                    Position = new Vector2(windowLabelTrileset.Size.X, windowLabelTrileset.Position.Y)
                });
                windowFieldTrileset.Fill(ContentPaths.TrileSets);

                window.Widgets.Add(new ButtonWidget(Game, "CREATE", delegate() {
                    Level level = CreateNewLevel(
                        windowFieldName.Text,
                        int.Parse(windowFieldWidth.Text),
                        int.Parse(windowFieldHeight.Text),
                        int.Parse(windowFieldDepth.Text),
                        windowFieldTrileset.Text
                    );
                    GameState.Loading = true;
                    SkipLoading = 8;
                    GameLevelManagerHelper.ChangeLevel(level);
                    windowHeader.CloseButtonWidget.Action();
                }) {
                    Size = new Vector2(window.Size.X, 24f),
                    UpdateBounds = false,
                    LabelCentered = true,
                    Position = new Vector2(0f, window.Size.Y - 24f)
                });
            }));

            TextFieldWidget fieldOpen;
            button.Widgets.Add(new ButtonWidget(Game, "Open", new GuiWidget[] {
                fieldOpen = new TextFieldWidget(Game, "", "Levels") {
                    Size = new Vector2(160f, 24f),
                    Position = new Vector2(0f, 0f)
                },
                new ButtonWidget(Game, "LOAD", delegate() {
                    GameState.Loading = true;
                    SkipLoading = 8;
                    LevelManager.ChangeLevel(fieldOpen.Text);
                }) {
                    LabelCentered = true
                }
            }));

            button.Widgets.Add(new ButtonWidget(Game, "Recreate thumbnail", new GuiWidget[] {
                new ButtonWidget(Game, "128px (default)", () => CreateThumbnail(128)),
                new ButtonWidget(Game, "256px", () => CreateThumbnail(256)),
                new ButtonWidget(Game, "512px", () => CreateThumbnail(512))
            }));
            button.Widgets.Add(new ButtonWidget(Game, "Save (XML)", () => Save()));
            button.Widgets.Add(new ButtonWidget(Game, "Save (binary)", () => Save(true)));

            TopBarWidget.Widgets.Add(button = new ButtonWidget(Game, "View"));
            button.Background.A = 0;

            button.Widgets.Add(new ButtonWidget(Game, "Perspective", new GuiWidget[] {
                new ButtonWidget(Game, "Front", () => CameraManager.ChangeViewpoint(Viewpoint.Front)),
                new ButtonWidget(Game, "Left", () => CameraManager.ChangeViewpoint(Viewpoint.Left)),
                new ButtonWidget(Game, "Back", () => CameraManager.ChangeViewpoint(Viewpoint.Back)),
                new ButtonWidget(Game, "Right", () => CameraManager.ChangeViewpoint(Viewpoint.Right)),
                new ButtonWidget(Game, "Perspective", () => CameraManager.ChangeViewpoint(Viewpoint.Perspective))
            }));

            TextFieldWidget fieldPPT;
            button.Widgets.Add(new ButtonWidget(Game, "Pixels per Trixel", new GuiWidget[] {
                fieldPPT = new TextFieldWidget(Game, "", new string[] {
                    "0.25",
                    "1",
                    "2",
                    "3",
                    "4"
                }) {
                    Size = new Vector2(160f, 24f),
                    Position = new Vector2(0f, 0f)
                },
                new ButtonWidget(Game, "CHANGE", delegate() {
                    CameraManager.PixelsPerTrixel = float.Parse(fieldPPT.Text);
                }) {
                    LabelCentered = true
                }
            }));

            TopBarWidget.Widgets.Add(button = new ButtonWidget(Game, "Level"));
            button.Background.A = 0;
            TextFieldWidget fieldName;
            TextFieldWidget fieldWidth;
            TextFieldWidget fieldHeight;
            TextFieldWidget fieldDepth;
            button.Widgets.Add(new ButtonWidget(Game, "Settings", new GuiWidget[] {
                new ContainerWidget(Game, new GuiWidget[] {
                    new ButtonWidget(Game, "Name:") {
                        Background = new Color(DefaultBackground, 0f),
                        LabelCentered = false,
                        Position = new Vector2(0f, 0f)
                    },
                    fieldName = new TextFieldWidget(Game) {
                        RefreshValue = () => LevelManager.Name,
                        Size = new Vector2(160f, 24f),
                        Position = new Vector2(96f, 0f)
                    }
                }) {
                    Size = new Vector2(256f, 24f)
                },
                new ContainerWidget(Game, new GuiWidget[] {
                    new ButtonWidget(Game, "Width:") {
                        Background = new Color(DefaultBackground, 0f),
                        LabelCentered = false,
                        Position = new Vector2(0f, 0f)
                    },
                    fieldWidth = new TextFieldWidget(Game) {
                        RefreshValue = () => ((int) LevelManager.Size.X).ToString(),
                        Size = new Vector2(160f, 24f),
                        Position = new Vector2(96f, 0f)
                    }
                }) {
                    Size = new Vector2(256f, 24f)
                },
                new ContainerWidget(Game, new GuiWidget[] {
                    new ButtonWidget(Game, "Height:") {
                        Background = new Color(DefaultBackground, 0f),
                        LabelCentered = false,
                        Position = new Vector2(0f, 0f)
                    },
                    fieldHeight = new TextFieldWidget(Game) {
                        RefreshValue = () => ((int) LevelManager.Size.Y).ToString(),
                        Size = new Vector2(160f, 24f),
                        Position = new Vector2(96f, 0f)
                    }
                }) {
                    Size = new Vector2(256f, 24f)
                },
                new ContainerWidget(Game, new GuiWidget[] {
                    new ButtonWidget(Game, "Depth:") {
                        Background = new Color(DefaultBackground, 0f),
                        LabelCentered = false,
                        Position = new Vector2(0f, 0f)
                    },
                    fieldDepth = new TextFieldWidget(Game) {
                        RefreshValue = () => ((int) LevelManager.Size.Z).ToString(),
                        Size = new Vector2(160f, 24f),
                        Position = new Vector2(96f, 0f)
                    }
                }) {
                    Size = new Vector2(256f, 24f)
                },
                new ButtonWidget(Game, "CHANGE", delegate() {
                    GameLevelManagerHelper.Level.Name = fieldName.Text;
                    GameLevelManagerHelper.Level.Size = new Vector3(
                        int.Parse(fieldWidth.Text),
                        int.Parse(fieldHeight.Text),
                        int.Parse(fieldDepth.Text)
                    );
                }) {
                    LabelCentered = true
                }
            }));

            TextFieldWidget fieldSpawnX;
            TextFieldWidget fieldSpawnY;
            TextFieldWidget fieldSpawnZ;
            TextFieldWidget fieldSpawnFace;
            button.Widgets.Add(new ButtonWidget(Game, "Spawnpoint", new GuiWidget[] {
                new ContainerWidget(Game, new GuiWidget[] {
                    new ButtonWidget(Game, "X:") {
                        Background = new Color(DefaultBackground, 0f),
                        LabelCentered = false,
                        Position = new Vector2(0f, 0f)
                    },
                    fieldSpawnX = new TextFieldWidget(Game) {
                        RefreshValue = () => LevelManager.StartingPosition.Id.X.ToString(),
                        Size = new Vector2(160f, 24f),
                        Position = new Vector2(96f, 0f)
                    }
                }) {
                    Size = new Vector2(256f, 24f)
                },
                new ContainerWidget(Game, new GuiWidget[] {
                    new ButtonWidget(Game, "Y:") {
                        Background = new Color(DefaultBackground, 0f),
                        LabelCentered = false,
                        Position = new Vector2(0f, 0f)
                    },
                    fieldSpawnY = new TextFieldWidget(Game) {
                        RefreshValue = () => LevelManager.StartingPosition.Id.Y.ToString(),
                        Size = new Vector2(160f, 24f),
                        Position = new Vector2(96f, 0f)
                    }
                }) {
                    Size = new Vector2(256f, 24f)
                },
                new ContainerWidget(Game, new GuiWidget[] {
                    new ButtonWidget(Game, "Z:") {
                        Background = new Color(DefaultBackground, 0f),
                        LabelCentered = false,
                        Position = new Vector2(0f, 0f)
                    },
                    fieldSpawnZ = new TextFieldWidget(Game) {
                        RefreshValue = () => LevelManager.StartingPosition.Id.Z.ToString(),
                        Size = new Vector2(160f, 24f),
                        Position = new Vector2(96f, 0f)
                    }
                }) {
                    Size = new Vector2(256f, 24f)
                },
                new ContainerWidget(Game, new GuiWidget[] {
                    new ButtonWidget(Game, "Face:") {
                        Background = new Color(DefaultBackground, 0f),
                        LabelCentered = false,
                        Position = new Vector2(0f, 0f)
                    },
                    fieldSpawnFace = new TextFieldWidget(Game, "", Enum.GetNames(typeof(FaceOrientation))) {
                        RefreshValue = () => LevelManager.StartingPosition.Face.ToString(),
                        Size = new Vector2(160f, 24f),
                        Position = new Vector2(96f, 0f)
                    }
                }) {
                    Size = new Vector2(256f, 24f)
                },
                new ButtonWidget(Game, "CHANGE", delegate() {
                    LevelManager.StartingPosition.Id.X = int.Parse(fieldSpawnX.Text);
                    LevelManager.StartingPosition.Id.Y = int.Parse(fieldSpawnY.Text);
                    LevelManager.StartingPosition.Id.Z = int.Parse(fieldSpawnZ.Text);
                    LevelManager.StartingPosition.Face = (FaceOrientation) Enum.Parse(typeof(FaceOrientation), fieldSpawnFace.Text);
                }) {
                    LabelCentered = true
                }
            }));

            TextFieldWidget fieldSky;
            button.Widgets.Add(new ButtonWidget(Game, "Sky", new GuiWidget[] {
                fieldSky = new TextFieldWidget(Game, "", ContentPaths.Skies) {
                    RefreshValue = () => (LevelManager.Sky != null) ? LevelManager.Sky.Name : "",
                    Size = new Vector2(160f, 24f),
                    Position = new Vector2(0f, 0f)
                },
                new ButtonWidget(Game, "CHANGE", delegate() {
                    Sky sky = fieldSky.Text.Length > 0 ? CMProvider.CurrentLevel.Load<Sky>("Skies/" + fieldSky.Text) : null;
                    if (sky != null) {
                        GameLevelManagerHelper.Level.Sky = sky;
                        GameLevelManagerHelper.Level.SkyName = sky.Name;
                        LevelManager.ChangeSky(sky);
                    }
                }) {
                    LabelCentered = true
                }
            }));

            TextFieldWidget fieldSong;
            button.Widgets.Add(new ButtonWidget(Game, "Song", new GuiWidget[] {
                fieldSong = new TextFieldWidget(Game, "", ContentPaths.Music) {
                    RefreshValue = () => (LevelManager.Song != null) ? LevelManager.SongName : "",
                    Size = new Vector2(160f, 24f),
                    Position = new Vector2(0f, 0f)
                },
                new ButtonWidget(Game, "CHANGE", delegate() {
                    TrackedSong song = fieldSong.Text.Length > 0 ? CMProvider.CurrentLevel.Load<TrackedSong>("Music/" + fieldSong.Text) : null;
                    if (song != null) {
                        song.Initialize();
                        GameLevelManagerHelper.Level.Song = song;
                        LevelManager.SongChanged = true;
                        SoundManager.PlayNewSong(song.Name);
                        SoundManager.UpdateSongActiveTracks();
                    }
                    GameLevelManagerHelper.Level.SongName = song != null ? song.Name : null;
                }) {
                    LabelCentered = true
                }
            }));

            TextFieldWidget fieldWaterHeight;
            TextFieldWidget fieldWaterType;
            button.Widgets.Add(new ButtonWidget(Game, "Water", new GuiWidget[] {
                new ContainerWidget(Game, new GuiWidget[] {
                    new ButtonWidget(Game, "Type:") {
                        Background = new Color(DefaultBackground, 0f),
                        LabelCentered = false,
                        Position = new Vector2(0f, 0f)
                    },
                    fieldWaterType = new TextFieldWidget(Game, "", Enum.GetNames(typeof(LiquidType))) {
                        RefreshValue = () => LevelManager.WaterType.ToString(),
                        Size = new Vector2(160f, 24f),
                        Position = new Vector2(96f, 0f)
                    },
                }) {
                    Size = new Vector2(256f, 24f)
                },
                new ContainerWidget(Game, new GuiWidget[] {
                    new ButtonWidget(Game, "Height:") {
                        Background = new Color(DefaultBackground, 0f),
                        LabelCentered = false,
                        Position = new Vector2(0f, 0f)
                    },
                    fieldWaterHeight = new TextFieldWidget(Game, "") {
                        RefreshValue = () => LevelManager.WaterHeight.ToString(),
                        Size = new Vector2(160f, 24f),
                        Position = new Vector2(96f, 0f)
                    },
                }) {
                    Size = new Vector2(256f, 24f)
                },
                new ButtonWidget(Game, "CHANGE", delegate() {
                    LevelManager.WaterType = (LiquidType) Enum.Parse(typeof(LiquidType), fieldWaterType.Text);
                    LevelManager.WaterHeight = float.Parse(fieldWaterHeight.Text);
                }) {
                    LabelCentered = true
                }
            }));


            TopBarWidget.Widgets.Add(button = new ButtonWidget(Game, "Scripting"));
            button.Background.A = 0;

            button.Widgets.Add(new ButtonWidget(Game, "Volumes", delegate() {
                ContainerWidget window;
                Widgets.Add(window = new ContainerWidget(Game) {
                    UpdateBounds = true,
                    Size = new Vector2(512f, 24f),
                    Label = "Volumes"
                });

                window.RefreshValue = delegate() {
                    window.Widgets.Clear();
                    window.Widgets.Add(new WindowHeaderWidget(Game));

                    int i = 0;
                    foreach (Volume volume in LevelManager.Volumes.Values) {
                        window.Widgets.Add(new ContainerWidget(Game, new GuiWidget[] {
                            new ButtonWidget(Game, "["+volume.Id+"] "+EditorUtils.ToString(volume.From)+" - "+EditorUtils.ToString(volume.To)) {
                                Size = new Vector2(window.Size.X - 24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = false,
                                Position = new Vector2(0f, 0f)
                            },
                            new ButtonWidget(Game, "X", delegate() {
                                LevelManager.Volumes.Remove(volume.Id);
                                window.Refresh();
                            }) {
                                Background = new Color(0.5f, 0f, 0f, 1f),
                                Size = new Vector2(24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = true,
                                Position = new Vector2(window.Size.X - 24f, 0f)
                            }
                        }) {
                            Size = new Vector2(window.Size.X, 24f),
                            Background = new Color(DefaultBackground, 0f)
                        });

                        i++;
                    }

                    window.Size.Y = (i+1) * 24f;
                    window.Size.Y = Math.Min(512f, window.Size.Y);

                    window.Widgets.Add(new ButtonWidget(Game, "+", delegate() {
                        ContainerWidget windowAdd;
                        Widgets.Add(windowAdd = new ContainerWidget(Game) {
                            Size = new Vector2(256f, 192f),
                            Label = "Add Volume"
                        });
                        WindowHeaderWidget windowAddHeader;
                        windowAdd.Widgets.Add(windowAddHeader = new WindowHeaderWidget(Game));

                        ButtonWidget windowLabelId;
                        windowAdd.Widgets.Add(windowLabelId = new ButtonWidget(Game, "ID:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 0f)
                        });
                        TextFieldWidget windowFieldId;
                        windowAdd.Widgets.Add(windowFieldId = new TextFieldWidget(Game) {
                            Size = new Vector2(windowAdd.Size.X - windowLabelId.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelId.Size.X, windowLabelId.Position.Y)
                        });

                        ButtonWidget windowLabelFrom;
                        windowAdd.Widgets.Add(windowLabelFrom = new ButtonWidget(Game, "From:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 24f)
                        });
                        TextFieldWidget windowFieldFrom;
                        windowAdd.Widgets.Add(windowFieldFrom = new TextFieldWidget(Game, "0; 0; 0") {
                            Size = new Vector2(windowAdd.Size.X - windowLabelFrom.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelFrom.Size.X, windowLabelFrom.Position.Y)
                        });

                        ButtonWidget windowLabelTo;
                        windowAdd.Widgets.Add(windowLabelTo = new ButtonWidget(Game, "To:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 48f)
                        });
                        TextFieldWidget windowFieldTo;
                        windowAdd.Widgets.Add(windowFieldTo = new TextFieldWidget(Game, "1; 1; 1") {
                            Size = new Vector2(windowAdd.Size.X - windowLabelTo.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelTo.Size.X, windowLabelTo.Position.Y)
                        });

                        CheckboxWidget windowCheckFront;
                        windowAdd.Widgets.Add(windowCheckFront = new CheckboxWidget(Game, "Front") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(windowAdd.Size.X, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 72f)
                        });

                        CheckboxWidget windowCheckLeft;
                        windowAdd.Widgets.Add(windowCheckLeft = new CheckboxWidget(Game, "Left") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(windowAdd.Size.X, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 96f)
                        });

                        CheckboxWidget windowCheckBack;
                        windowAdd.Widgets.Add(windowCheckBack = new CheckboxWidget(Game, "Back") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(windowAdd.Size.X, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 120f)
                        });

                        CheckboxWidget windowCheckRight;
                        windowAdd.Widgets.Add(windowCheckRight = new CheckboxWidget(Game, "Right") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(windowAdd.Size.X, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 144f)
                        });

                        windowAdd.Widgets.Add(new ButtonWidget(Game, "ADD", delegate() {
                            string[] fromSplit = windowFieldFrom.Text.Split(new char[] {';'});
                            string[] toSplit = windowFieldTo.Text.Split(new char[] {';'});
                            Volume volume = new Volume() {
                                Id = int.Parse(windowFieldId.Text),
                                From = new Vector3(
                                    float.Parse(fromSplit[0].Trim()),
                                    float.Parse(fromSplit[1].Trim()),
                                    float.Parse(fromSplit[2].Trim())
                                ),
                                To = new Vector3(
                                    float.Parse(toSplit[0].Trim()),
                                    float.Parse(toSplit[1].Trim()),
                                    float.Parse(toSplit[2].Trim())
                                )
                            };
                            if (windowCheckFront.Checked) {volume.Orientations.Add(FaceOrientation.Front);}
                            if (windowCheckLeft.Checked) {volume.Orientations.Add(FaceOrientation.Left);}
                            if (windowCheckBack.Checked) {volume.Orientations.Add(FaceOrientation.Back);}
                            if (windowCheckRight.Checked) {volume.Orientations.Add(FaceOrientation.Right);}
                            LevelManager.Volumes.Add(volume.Id, volume);
                            windowAddHeader.CloseButtonWidget.Action();
                            window.Refresh();
                        }) {
                            Size = new Vector2(windowAdd.Size.X, 24f),
                            UpdateBounds = false,
                            LabelCentered = true,
                            Position = new Vector2(0f, windowAdd.Size.Y - 24f)
                        });

                        windowAdd.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (windowAdd.Size.X / 2);
                        windowAdd.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (windowAdd.Size.Y / 2);
                    }) {
                        Background = new Color(0f, 0.125f, 0f, 1f),
                        Size = new Vector2(window.Size.X, 24f),
                        UpdateBounds = false,
                        LabelCentered = true,
                        Position = new Vector2(0f, window.Size.Y - 24f)
                    });

                    return null;
                };
                window.Refresh();

                window.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (window.Size.X / 2);
                window.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (window.Size.Y / 2);
            }));

            button.Widgets.Add(new ButtonWidget(Game, "Scripts", delegate() {
                ContainerWidget window;
                Widgets.Add(window = new ContainerWidget(Game) {
                    UpdateBounds = true
                });
                window.Size.X = 512f;
                window.Size.Y = 24f;
                window.Label = "Scripts";
                window.Widgets.Add(new WindowHeaderWidget(Game));

                int i = 0;
                foreach (Script script in LevelManager.Scripts.Values) {
                    window.Widgets.Add(new ContainerWidget(Game, new GuiWidget[] {
                        new ButtonWidget(Game, "["+script.Id+"] "+script.Name+" ("+(script.Triggerless ? "none" : (script.Triggers.Count == 1 ? script.Triggers[0].ToString() : "..."))+") : "+(script.Actions.Count == 1 ? script.Actions[0].ToString() : "...")) {
                            Size = new Vector2(window.Size.X - 48f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 0f)
                        },
                        new ButtonWidget(Game, "C") {
                            Background = new Color(0f, 0f, 0.125f, 1f),
                            Size = new Vector2(24f, 24f),
                            UpdateBounds = false,
                            LabelCentered = true,
                            Position = new Vector2(window.Size.X - 48f, 0f)
                        },
                        new ButtonWidget(Game, "X") {
                            Background = new Color(0.5f, 0f, 0f, 1f),
                            Size = new Vector2(24f, 24f),
                            UpdateBounds = false,
                            LabelCentered = true,
                            Position = new Vector2(window.Size.X - 24f, 0f)
                        }
                    }) {
                        Size = new Vector2(window.Size.X, 24f),
                        Background = new Color(DefaultBackground, 0f)
                    });

                    i++;
                }

                window.Size.Y += i * 24f;
                window.Size.Y = Math.Min(512f, window.Size.Y);

                window.Widgets.Add(new ButtonWidget(Game, "+", delegate() {
                }) {
                    Background = new Color(0f, 0.125f, 0f, 1f),
                    Size = new Vector2(window.Size.X, 24f),
                    UpdateBounds = false,
                    LabelCentered = true,
                    Position = new Vector2(0f, window.Size.Y - 24f)
                });

                window.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (window.Size.X / 2);
                window.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (window.Size.Y / 2);
            }));
            button.Widgets.Add(new ButtonWidget(Game, "Art Objects", delegate() {
                ContainerWidget window;

                Widgets.Add(window = new ContainerWidget(Game) {
                    UpdateBounds = true,
                    Size = new Vector2(512f, 24f),
                    Label = "Art Objects"
                });

                window.RefreshValue = delegate() {
                    window.Widgets.Clear();

                    window.Widgets.Add(new WindowHeaderWidget(Game));

                    int i = 0;
                    foreach (ArtObjectInstance ao in LevelManager.ArtObjects.Values) {
                        window.Widgets.Add(new ContainerWidget(Game, new GuiWidget[] {
                            new ButtonWidget(Game, "["+ao.Id+"] "+ao.ArtObjectName+": "+EditorUtils.ToString(ao.Position)) {
                                Size = new Vector2(window.Size.X - 24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = false,
                                Position = new Vector2(0f, 0f)
                            },
                            new ButtonWidget(Game, "X", delegate() {
                                int trileGroupId = ao.ActorSettings.AttachedGroup.HasValue ? ao.ActorSettings.AttachedGroup.Value : -1;
                                if (LevelManager.Groups.ContainsKey(trileGroupId)) {
                                    TrileGroup trileGroup = LevelManager.Groups[trileGroupId];
                                    while (trileGroup.Triles.Count > 0) {
                                        LevelManager.ClearTrile(trileGroup.Triles[0]);
                                    }
                                    LevelManager.Groups.Remove(trileGroupId);
                                }
                                LevelManager.ArtObjects.Remove(ao.Id);
                                ao.Dispose();
                                LevelMaterializer.RegisterSatellites();

                                window.Refresh();
                            }) {
                                Background = new Color(0.5f, 0f, 0f, 1f),
                                Size = new Vector2(24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = true,
                                Position = new Vector2(window.Size.X - 24f, 0f)
                            }
                        }) {
                            Size = new Vector2(window.Size.X, 24f),
                            Background = new Color(DefaultBackground, 0f)
                        });

                        i++;
                    }

                    window.Size.Y = (i+1) * 24f;
                    window.Size.Y = Math.Min(512f, window.Size.Y);

                    window.Widgets.Add(new ButtonWidget(Game, "+", delegate() {
                        ContainerWidget windowAdd;
                        Widgets.Add(windowAdd = new ContainerWidget(Game) {
                            Size = new Vector2(256f, 168f),
                            Label = "Add Art Object"
                        });
                        WindowHeaderWidget windowAddHeader;
                        windowAdd.Widgets.Add(windowAddHeader = new WindowHeaderWidget(Game));

                        int maxID = 0;
                        foreach (int id in LevelManager.ArtObjects.Keys) {
                            if (id >= maxID) {
                                maxID = id + 1;
                            }
                        }

                        ButtonWidget windowLabelId;
                        windowAdd.Widgets.Add(windowLabelId = new ButtonWidget(Game, "ID:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 0f)
                        });
                        TextFieldWidget windowFieldId;
                        windowAdd.Widgets.Add(windowFieldId = new TextFieldWidget(Game, maxID.ToString()) {
                            Size = new Vector2(windowAdd.Size.X - windowLabelId.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelId.Size.X, windowLabelId.Position.Y)
                        });

                        ButtonWidget windowLabelName;
                        windowAdd.Widgets.Add(windowLabelName = new ButtonWidget(Game, "Name:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 24f)
                        });
                        TextFieldWidget windowFieldName;
                        windowAdd.Widgets.Add(windowFieldName = new TextFieldWidget(Game, "", ContentPaths.ArtObjects) {
                            Size = new Vector2(windowAdd.Size.X - windowLabelName.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelName.Size.X, windowLabelName.Position.Y)
                        });

                        ButtonWidget windowLabelPosition;
                        windowAdd.Widgets.Add(windowLabelPosition = new ButtonWidget(Game, "Position:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 48f)
                        });
                        TextFieldWidget windowFieldPosition;
                        windowAdd.Widgets.Add(windowFieldPosition = new TextFieldWidget(Game, "0; 0; 0") {
                            Size = new Vector2(windowAdd.Size.X - windowLabelPosition.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelPosition.Size.X, windowLabelPosition.Position.Y)
                        });

                        ButtonWidget windowLabelRotation;
                        windowAdd.Widgets.Add(windowLabelRotation = new ButtonWidget(Game, "Rotation:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 72f)
                        });
                        TextFieldWidget windowFieldRotation;
                        windowAdd.Widgets.Add(windowFieldRotation = new TextFieldWidget(Game, "0; 0; 0; 1") {
                            Size = new Vector2(windowAdd.Size.X - windowLabelRotation.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelRotation.Size.X, windowLabelRotation.Position.Y)
                        });

                        ButtonWidget windowLabelCenter;
                        windowAdd.Widgets.Add(windowLabelCenter = new ButtonWidget(Game, "Center:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 96f)
                        });
                        TextFieldWidget windowFieldCenter;
                        windowAdd.Widgets.Add(windowFieldCenter = new TextFieldWidget(Game, "0; 0; 0") {
                            Size = new Vector2(windowAdd.Size.X - windowLabelCenter.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelCenter.Size.X, windowLabelCenter.Position.Y)
                        });

                        ButtonWidget windowLabelScale;
                        windowAdd.Widgets.Add(windowLabelScale = new ButtonWidget(Game, "Scale:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 120f)
                        });
                        TextFieldWidget windowFieldScale;
                        windowAdd.Widgets.Add(windowFieldScale = new TextFieldWidget(Game, "1; 1; 1") {
                            Size = new Vector2(windowAdd.Size.X - windowLabelScale.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelScale.Size.X, windowLabelScale.Position.Y)
                        });

                        windowAdd.Widgets.Add(new ButtonWidget(Game, "ADD", delegate() {
                            string[] positionSplit = windowFieldPosition.Text.Split(new char[] {';'});
                            string[] rotationSplit = windowFieldRotation.Text.Split(new char[] {';'});
                            string[] centerSplit = windowFieldCenter.Text.Split(new char[] {';'});
                            string[] scaleSplit = windowFieldScale.Text.Split(new char[] {';'});
                            ArtObjectInstance ao = new ArtObjectInstance(windowFieldName.Text) {
                                Id = int.Parse(windowFieldId.Text),
                                Position = new Vector3(
                                    float.Parse(positionSplit[0].Trim()),
                                    float.Parse(positionSplit[1].Trim()),
                                    float.Parse(positionSplit[2].Trim())
                                ),
                                Rotation = new Quaternion(
                                    float.Parse(rotationSplit[0].Trim()),
                                    float.Parse(rotationSplit[1].Trim()),
                                    float.Parse(rotationSplit[2].Trim()),
                                    float.Parse(rotationSplit[3].Trim())
                                ),
                                Scale = new Vector3(
                                    float.Parse(scaleSplit[0].Trim()),
                                    float.Parse(scaleSplit[1].Trim()),
                                    float.Parse(scaleSplit[2].Trim())
                                )
                            };
                            ao.ActorSettings = new ArtObjectActorSettings() {
                                RotationCenter = new Vector3(
                                    float.Parse(centerSplit[0].Trim()),
                                    float.Parse(centerSplit[1].Trim()),
                                    float.Parse(centerSplit[2].Trim())
                                )
                            };
                            ao.ArtObject = CMProvider.CurrentLevel.Load<ArtObject>("Art objects/"+ao.ArtObjectName);
                            ao.Initialize();
                            LevelManager.ArtObjects[ao.Id] = ao;
                            LevelMaterializer.RegisterSatellites();

                            windowAddHeader.CloseButtonWidget.Action();
                            window.Refresh();
                        }) {
                            Size = new Vector2(windowAdd.Size.X, 24f),
                            UpdateBounds = false,
                            LabelCentered = true,
                            Position = new Vector2(0f, windowAdd.Size.Y - 24f)
                        });

                        windowAdd.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (windowAdd.Size.X / 2);
                        windowAdd.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (windowAdd.Size.Y / 2);
                    }) {
                        Background = new Color(0f, 0.125f, 0f, 1f),
                        Size = new Vector2(window.Size.X, 24f),
                        UpdateBounds = false,
                        LabelCentered = true,
                        Position = new Vector2(0f, window.Size.Y - 24f)
                    });

                    return null;
                };

                window.Refresh();

                window.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (window.Size.X / 2);
                window.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (window.Size.Y / 2);
            }));
            button.Widgets.Add(new ButtonWidget(Game, "Background Planes", delegate() {
                ContainerWidget window;
                Widgets.Add(window = new ContainerWidget(Game) {
                    UpdateBounds = true,
                    Size = new Vector2(512f, 24f),
                    Label = "Background Planes"
                });

                window.RefreshValue = delegate() {
                    window.Widgets.Clear();

                    window.Widgets.Add(new WindowHeaderWidget(Game));

                    int i = 0;
                    foreach (BackgroundPlane bp in LevelManager.BackgroundPlanes.Values) {
                        window.Widgets.Add(new ContainerWidget(Game, new GuiWidget[] {
                            new ButtonWidget(Game, "["+bp.Id+"] "+bp.TextureName+": "+EditorUtils.ToString(bp.Position)) {
                                Size = new Vector2(window.Size.X - 24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = false,
                                Position = new Vector2(0f, 0f)
                            },
                            new ButtonWidget(Game, "X", delegate() {
                                LevelManager.RemovePlane(bp);
                                window.Refresh();
                            }) {
                                Background = new Color(0.5f, 0f, 0f, 1f),
                                Size = new Vector2(24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = true,
                                Position = new Vector2(window.Size.X - 24f, 0f)
                            }
                        }) {
                            Size = new Vector2(window.Size.X, 24f),
                            Background = new Color(DefaultBackground, 0f)
                        });

                        i++;
                    }

                    window.Size.Y = (i+1) * 24f;
                    window.Size.Y = Math.Min(512f, window.Size.Y);

                    window.Widgets.Add(new ButtonWidget(Game, "+", delegate() {
                        ContainerWidget windowAdd;
                        Widgets.Add(windowAdd = new ContainerWidget(Game) {
                            Size = new Vector2(256f, 240f),
                            Label = "Add Background Plane"
                        });
                        WindowHeaderWidget windowAddHeader;
                        windowAdd.Widgets.Add(windowAddHeader = new WindowHeaderWidget(Game));

                        int maxID = 0;
                        foreach (int id in LevelManager.BackgroundPlanes.Keys) {
                            if (id >= maxID) {
                                maxID = id + 1;
                            }
                        }

                        ButtonWidget windowLabelId;
                        windowAdd.Widgets.Add(windowLabelId = new ButtonWidget(Game, "ID:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 0f)
                        });
                        TextFieldWidget windowFieldId;
                        windowAdd.Widgets.Add(windowFieldId = new TextFieldWidget(Game, maxID.ToString()) {
                            Size = new Vector2(windowAdd.Size.X - windowLabelId.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelId.Size.X, windowLabelId.Position.Y)
                        });

                        ButtonWidget windowLabelName;
                        windowAdd.Widgets.Add(windowLabelName = new ButtonWidget(Game, "Name:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 24f)
                        });
                        TextFieldWidget windowFieldName;
                        windowAdd.Widgets.Add(windowFieldName = new TextFieldWidget(Game, "", ContentPaths.BackgroundPlanes) {
                            Size = new Vector2(windowAdd.Size.X - windowLabelName.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelName.Size.X, windowLabelName.Position.Y)
                        });

                        ButtonWidget windowLabelPosition;
                        windowAdd.Widgets.Add(windowLabelPosition = new ButtonWidget(Game, "Position:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 48f)
                        });
                        TextFieldWidget windowFieldPosition;
                        windowAdd.Widgets.Add(windowFieldPosition = new TextFieldWidget(Game, "0; 0; 0") {
                            Size = new Vector2(windowAdd.Size.X - windowLabelPosition.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelPosition.Size.X, windowLabelPosition.Position.Y)
                        });

                        ButtonWidget windowLabelRotation;
                        windowAdd.Widgets.Add(windowLabelRotation = new ButtonWidget(Game, "Rotation:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 72f)
                        });
                        TextFieldWidget windowFieldRotation;
                        windowAdd.Widgets.Add(windowFieldRotation = new TextFieldWidget(Game, "0; 0; 0; 1") {
                            Size = new Vector2(windowAdd.Size.X - windowLabelRotation.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelRotation.Size.X, windowLabelRotation.Position.Y)
                        });

                        ButtonWidget windowLabelScale;
                        windowAdd.Widgets.Add(windowLabelScale = new ButtonWidget(Game, "Scale:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 96f)
                        });
                        TextFieldWidget windowFieldScale;
                        windowAdd.Widgets.Add(windowFieldScale = new TextFieldWidget(Game, "1; 1; 1") {
                            Size = new Vector2(windowAdd.Size.X - windowLabelScale.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelScale.Size.X, windowLabelScale.Position.Y)
                        });

                        ButtonWidget windowLabelFilter;
                        windowAdd.Widgets.Add(windowLabelFilter = new ButtonWidget(Game, "Filter:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 120f)
                        });
                        TextFieldWidget windowFieldFilter;
                        windowAdd.Widgets.Add(windowFieldFilter = new TextFieldWidget(Game, "#FFFFFFFF") {
                            Size = new Vector2(windowAdd.Size.X - windowLabelFilter.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelFilter.Size.X, windowLabelFilter.Position.Y)
                        });

                        CheckboxWidget windowCheckboxBillboard;
                        windowAdd.Widgets.Add(windowCheckboxBillboard = new CheckboxWidget(Game, "Billboard") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 144f)
                        });

                        CheckboxWidget windowCheckboxLightMap;
                        windowAdd.Widgets.Add(windowCheckboxLightMap = new CheckboxWidget(Game, "Lightmap") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 168f)
                        });

                        CheckboxWidget windowCheckboxOverbright;
                        windowAdd.Widgets.Add(windowCheckboxOverbright = new CheckboxWidget(Game, "Overbright") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 192f)
                        });

                        windowAdd.Widgets.Add(new ButtonWidget(Game, "ADD", delegate() {
                            string[] positionSplit = windowFieldPosition.Text.Split(new char[] {';'});
                            string[] rotationSplit = windowFieldRotation.Text.Split(new char[] {';'});
                            string[] scaleSplit = windowFieldScale.Text.Split(new char[] {';'});
                            BackgroundPlane plane = new BackgroundPlane() {
                                Id = int.Parse(windowFieldId.Text),
                                TextureName = windowFieldName.Text,
                                Position = new Vector3(
                                    float.Parse(positionSplit[0].Trim()),
                                    float.Parse(positionSplit[1].Trim()),
                                    float.Parse(positionSplit[2].Trim())
                                ),
                                Rotation = new Quaternion(
                                    float.Parse(rotationSplit[0].Trim()),
                                    float.Parse(rotationSplit[1].Trim()),
                                    float.Parse(rotationSplit[2].Trim()),
                                    float.Parse(rotationSplit[3].Trim())
                                ),
                                Scale = new Vector3(
                                    float.Parse(scaleSplit[0].Trim()),
                                    float.Parse(scaleSplit[1].Trim()),
                                    float.Parse(scaleSplit[2].Trim())
                                ),
                                Billboard = windowCheckboxBillboard.Checked,
                                LightMap = windowCheckboxLightMap.Checked,
                                AllowOverbrightness = windowCheckboxOverbright.Checked
                            };
                            Color filter = new Color();
                            filter.PackedValue = Convert.ToUInt32(windowFieldFilter.Text.Substring(1), 16);
                            plane.Filter = filter;
                            plane.Animated = CMProvider.CurrentLevel.Load<object>("Background Planes/" + plane.TextureName) is AnimatedTexture;
                            plane.HostMesh = ((!plane.Animated) ? LevelMaterializer.StaticPlanesMesh : LevelMaterializer.AnimatedPlanesMesh);
                            plane.Initialize();
                            LevelManager.AddPlane(plane);

                            windowAddHeader.CloseButtonWidget.Action();
                            window.Refresh();
                        }) {
                            Size = new Vector2(windowAdd.Size.X, 24f),
                            UpdateBounds = false,
                            LabelCentered = true,
                            Position = new Vector2(0f, windowAdd.Size.Y - 24f)
                        });

                        windowAdd.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (windowAdd.Size.X / 2);
                        windowAdd.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (windowAdd.Size.Y / 2);
                    }) {
                        Background = new Color(0f, 0.125f, 0f, 1f),
                        Size = new Vector2(window.Size.X, 24f),
                        UpdateBounds = false,
                        LabelCentered = true,
                        Position = new Vector2(0f, window.Size.Y - 24f)
                    });

                    return null;
                };

                window.Refresh();

                window.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (window.Size.X / 2);
                window.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (window.Size.Y / 2);
            }));
            button.Widgets.Add(new ButtonWidget(Game, "Groups", delegate() {
                ContainerWidget window;
                Widgets.Add(window = new ContainerWidget(Game) {
                    UpdateBounds = true,
                    Size = new Vector2(256f, 24f),
                    Label = "Groups"
                });

                window.RefreshValue = delegate() {
                    window.Widgets.Clear();

                    window.Widgets.Add(new WindowHeaderWidget(Game));

                    int i = 0;
                    foreach (TrileGroup group_ in LevelManager.Groups.Values) {
                        window.Widgets.Add(new ContainerWidget(Game, new GuiWidget[] {
                            new ButtonWidget(Game, "["+group_.Id+"] "+group_.Name) {
                                Size = new Vector2(window.Size.X - 24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = false,
                                Position = new Vector2(0f, 0f)
                            },
                            new ButtonWidget(Game, "X", delegate() {
                                while (group_.Triles.Count > 0) {
                                    LevelManager.ClearTrile(group_.Triles[0]);
                                }
                                LevelManager.Groups.Remove(group_.Id);
                                window.Refresh();
                            }) {
                                Background = new Color(0.5f, 0f, 0f, 1f),
                                Size = new Vector2(24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = true,
                                Position = new Vector2(window.Size.X - 24f, 0f)
                            }
                        }) {
                            Size = new Vector2(window.Size.X, 24f),
                            Background = new Color(DefaultBackground, 0f)
                        });

                        i++;
                    }

                    window.Size.Y = (i+1) * 24f;
                    window.Size.Y = Math.Min(512f, window.Size.Y);

                    window.Widgets.Add(new ButtonWidget(Game, "+", delegate() {
                    }) {
                        Background = new Color(0f, 0.125f, 0f, 1f),
                        Size = new Vector2(window.Size.X, 24f),
                        UpdateBounds = false,
                        LabelCentered = true,
                        Position = new Vector2(0f, window.Size.Y - 24f)
                    });

                    return null;
                };

                window.Refresh();

                window.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (window.Size.X / 2);
                window.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (window.Size.Y / 2);
            }));
            button.Widgets.Add(new ButtonWidget(Game, "NPCs", delegate() {
                ContainerWidget window;
                Widgets.Add(window = new ContainerWidget(Game) {
                    UpdateBounds = true,
                    Size = new Vector2(256f, 24f),
                    Label = "NPCs"
                });

                window.RefreshValue = delegate() {
                    window.Widgets.Clear();

                    window.Widgets.Add(new WindowHeaderWidget(Game));

                    int i = 0;
                    foreach (NpcInstance npc in LevelManager.NonPlayerCharacters.Values) {
                        window.Widgets.Add(new ContainerWidget(Game, new GuiWidget[] {
                            new ButtonWidget(Game, "["+npc.Id+"] "+npc.Name) {
                                Size = new Vector2(window.Size.X - 24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = false,
                                Position = new Vector2(0f, 0f)
                            },
                            new ButtonWidget(Game, "X", delegate() {
                                LevelManager.NonPlayerCharacters.Remove(npc.Id);
                                ServiceHelper.RemoveComponent(npc.State);
                                window.Refresh();
                            }) {
                                Background = new Color(0.5f, 0f, 0f, 1f),
                                Size = new Vector2(24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = true,
                                Position = new Vector2(window.Size.X - 24f, 0f)
                            }
                        }) {
                            Size = new Vector2(window.Size.X, 24f),
                            Background = new Color(DefaultBackground, 0f)
                        });

                        i++;
                    }

                    window.Size.Y = (i+1) * 24f;
                    window.Size.Y = Math.Min(512f, window.Size.Y);

                    window.Widgets.Add(new ButtonWidget(Game, "+", delegate() {
                        ContainerWidget windowAdd;
                        Widgets.Add(windowAdd = new ContainerWidget(Game) {
                            Size = new Vector2(256f * 2f, 240f),
                            Label = "Add NPC",
                            UpdateBounds = false
                        });
                        WindowHeaderWidget windowAddHeader;
                        windowAdd.Widgets.Add(windowAddHeader = new WindowHeaderWidget(Game));

                        int maxID = 0;
                        foreach (int id in LevelManager.NonPlayerCharacters.Keys) {
                            if (id >= maxID) {
                                maxID = id + 1;
                            }
                        }

                        float columnWidth = 256f;
                        ContainerWidget[] columns = new ContainerWidget[2];
                        for (int ci = columns.Length - 1; ci >= 0; ci--) {
                            columns[ci] = new ContainerWidget(Game) {
                                Position = new Vector2(ci * columnWidth, 0),
                                Size = new Vector2(columnWidth, windowAdd.Size.Y),
                                UpdateBounds = ci != 0,
                                Background = new Color(DefaultBackground, 0f)
                            };
                            windowAdd.Widgets.Add(columns[ci]);
                        }

                        ButtonWidget windowLabelId;
                        columns[0].Widgets.Add(windowLabelId = new ButtonWidget(Game, "ID:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 0f)
                        });
                        TextFieldWidget windowFieldId;
                        columns[0].Widgets.Add(windowFieldId = new TextFieldWidget(Game, maxID.ToString()) {
                            Size = new Vector2(columnWidth - windowLabelId.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelId.Size.X, windowLabelId.Position.Y)
                        });

                        ButtonWidget windowLabelName;
                        columns[0].Widgets.Add(windowLabelName = new ButtonWidget(Game, "Name:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 24f)
                        });
                        TextFieldWidget windowFieldName;
                        columns[0].Widgets.Add(windowFieldName = new TextFieldWidget(Game, "", ContentPaths.CharacterAnimations) {
                            Size = new Vector2(columnWidth - windowLabelName.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelName.Size.X, windowLabelName.Position.Y)
                        });

                        ButtonWidget windowLabelPosition;
                        columns[0].Widgets.Add(windowLabelPosition = new ButtonWidget(Game, "Position:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 48f)
                        });
                        TextFieldWidget windowFieldPosition;
                        columns[0].Widgets.Add(windowFieldPosition = new TextFieldWidget(Game, "0; 0; 0") {
                            Size = new Vector2(columnWidth - windowLabelPosition.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelPosition.Size.X, windowLabelPosition.Position.Y)
                        });

                        ButtonWidget windowLabelDestination;
                        columns[0].Widgets.Add(windowLabelDestination = new ButtonWidget(Game, "Destination:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 72f)
                        });
                        TextFieldWidget windowFieldDestination;
                        columns[0].Widgets.Add(windowFieldDestination = new TextFieldWidget(Game, "0; 0; 0") {
                            Size = new Vector2(columnWidth - windowLabelDestination.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelDestination.Size.X, windowLabelDestination.Position.Y)
                        });

                        ButtonWidget windowLabelWalkSpeed;
                        columns[0].Widgets.Add(windowLabelWalkSpeed = new ButtonWidget(Game, "Walk speed:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 96f)
                        });
                        TextFieldWidget windowFieldWalkSpeed;
                        columns[0].Widgets.Add(windowFieldWalkSpeed = new TextFieldWidget(Game, "1") {
                            Size = new Vector2(columnWidth - windowLabelWalkSpeed.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelWalkSpeed.Size.X, windowLabelWalkSpeed.Position.Y)
                        });

                        CheckboxWidget windowCheckboxAvoidsGomez;
                        columns[0].Widgets.Add(windowCheckboxAvoidsGomez = new CheckboxWidget(Game, "Avoids Gomez") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(columnWidth, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 120f)
                        });

                        CheckboxWidget windowCheckboxOverrideTalk;
                        columns[1].Widgets.Add(windowCheckboxOverrideTalk = new CheckboxWidget(Game, "Override talk") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(columnWidth, 24f),
                            UpdateBounds = false,
                            LabelCentered = false
                        });

                        Dictionary<string, string>.KeyCollection speechLines = typeof(GameText).GetPrivateStatic<Dictionary<string, string>>("Fallback").Keys;
                        columns[1].Widgets.Add(new ButtonWidget(Game, "+ SPEECH", delegate() {
                            ContainerWidget widgetSpeech = null;
                            TextFieldWidget widgetFieldSpeech = null;
                            columns[1].Widgets.Insert(columns[1].Widgets.Count - 2, widgetSpeech = new ContainerWidget(Game, new GuiWidget[] {
                                widgetFieldSpeech = new TextFieldWidget(Game) {
                                    Size = new Vector2(columnWidth - 24f, 24f),
                                    UpdateBounds = false,
                                    Position = new Vector2(0f, 0f)
                                },
                                new ButtonWidget(Game, "X", delegate() {
                                    columns[1].Widgets.Remove(widgetSpeech);
                                }) {
                                    Background = new Color(0.5f, 0f, 0f, 1f),
                                    Size = new Vector2(24f, 24f),
                                    UpdateBounds = false,
                                    LabelCentered = true,
                                    Position = new Vector2(columnWidth - 24f, 0f)
                                }
                            }) {
                                Size = new Vector2(columnWidth, 24f),
                                Background = new Color(DefaultBackground, 0f)
                            });
                            widgetFieldSpeech.Fill(speechLines);
                        }) {
                            Background = new Color(0f, 0.125f, 0f, 1f),
                            Size = new Vector2(columnWidth, 24f),
                            UpdateBounds = false,
                            LabelCentered = true
                        });

                        columns[0].Widgets.Add(new ButtonWidget(Game, "ADD NPC", delegate() {
                            string[] positionSplit = windowFieldPosition.Text.Split(new char[] {';'});
                            string[] destinationSplit = windowFieldDestination.Text.Split(new char[] {';'});
                            NpcInstance npc = new NpcInstance() {
                                Id = int.Parse(windowFieldId.Text),
                                Name = windowFieldName.Text,
                                Position = new Vector3(
                                    float.Parse(positionSplit[0].Trim()),
                                    float.Parse(positionSplit[1].Trim()),
                                    float.Parse(positionSplit[2].Trim())
                                ),
                                DestinationOffset = new Vector3(
                                    float.Parse(destinationSplit[0].Trim()),
                                    float.Parse(destinationSplit[1].Trim()),
                                    float.Parse(destinationSplit[2].Trim())
                                ),
                                WalkSpeed = float.Parse(windowFieldWalkSpeed.Text),
                                AvoidsGomez = windowCheckboxAvoidsGomez.Checked
                            };

                            for (int ri = 0; ri < columns[1].Widgets.Count; ri++) {
                                GuiWidget rowWidget = columns[1].Widgets[ri];
                                if (!(rowWidget is ContainerWidget) || rowWidget.Widgets.Count != 2) {
                                    continue;
                                }
                                TextFieldWidget lineWidget = (TextFieldWidget) rowWidget.Widgets[0];
                                SpeechLine line = new SpeechLine() {
                                    Text = lineWidget.Text
                                };
                                if (ri == 0 && windowCheckboxOverrideTalk.Checked) {
                                    line.OverrideContent = new NpcActionContent() {
                                        AnimationName = "Talk"
                                    };
                                }
                                npc.Speech.Add(line);
                            }
                                

                            string root = ContentPaths.CharacterAnimations + "/" + npc.Name;
                            IEnumerable<string> list = CMProvider.GetAllIn(root);
                            foreach (string item_ in list) {
                                string item = item_.Substring(root.Length + 1).ToUpper();
                                NpcAction key;
                                if (!Enum.TryParse<NpcAction>(item, true, out key)) {
                                    continue;
                                }
                                npc.Actions[key] = new NpcActionContent() {
                                    AnimationName = key.ToString()
                                };
                            }

                            LevelManager.NonPlayerCharacters[npc.Id] = npc;
                            npc.State = new GameNpcState(Game, npc);
                            ServiceHelper.AddComponent(npc.State);
                            npc.State.Initialize();
                            ServiceHelper.Get<NpcHost>().GetPrivate<List<NpcState>>("NpcStates").Add(npc.State);

                            windowAddHeader.CloseButtonWidget.Action();
                            window.Refresh();
                        }) {
                            Size = new Vector2(columnWidth, 24f),
                            UpdateBounds = false,
                            LabelCentered = true,
                            Position = new Vector2(0f, columns[0].Size.Y - 24f)
                        });

                        windowAdd.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (windowAdd.Size.X / 2);
                        windowAdd.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (windowAdd.Size.Y / 2);
                    }) {
                        Background = new Color(0f, 0.125f, 0f, 1f),
                        Size = new Vector2(window.Size.X, 24f),
                        UpdateBounds = false,
                        LabelCentered = true,
                        Position = new Vector2(0f, window.Size.Y - 24f)
                    });

                    return null;
                };

                window.Refresh();

                window.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (window.Size.X / 2);
                window.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (window.Size.Y / 2);
            }));
            button.Widgets.Add(new ButtonWidget(Game, "Paths", delegate() {
                ContainerWidget window;
                Widgets.Add(window = new ContainerWidget(Game) {
                    UpdateBounds = true
                });
                window.Size.X = 128f;
                window.Size.Y = 24f;
                window.Label = "Paths";
                window.Widgets.Add(new WindowHeaderWidget(Game));

                int i = 0;
                foreach (MovementPath path in LevelManager.Paths.Values) {
                    window.Widgets.Add(new ContainerWidget(Game, new GuiWidget[] {
                        new ButtonWidget(Game, path.Id.ToString()) {
                            Size = new Vector2(window.Size.X - 48f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 0f)
                        },
                        new ButtonWidget(Game, "C") {
                            Background = new Color(0f, 0f, 0.125f, 1f),
                            Size = new Vector2(24f, 24f),
                            UpdateBounds = false,
                            LabelCentered = true,
                            Position = new Vector2(window.Size.X - 48f, 0f)
                        },
                        new ButtonWidget(Game, "X") {
                            Background = new Color(0.5f, 0f, 0f, 1f),
                            Size = new Vector2(24f, 24f),
                            UpdateBounds = false,
                            LabelCentered = true,
                            Position = new Vector2(window.Size.X - 24f, 0f)
                        }
                    }) {
                        Size = new Vector2(window.Size.X, 24f),
                        Background = new Color(DefaultBackground, 0f)
                    });

                    i++;
                }

                window.Size.Y += i * 24f;
                window.Size.Y = Math.Min(512f, window.Size.Y);

                window.Widgets.Add(new ButtonWidget(Game, "+", delegate() {
                }) {
                    Background = new Color(0f, 0.125f, 0f, 1f),
                    Size = new Vector2(window.Size.X, 24f),
                    UpdateBounds = false,
                    LabelCentered = true,
                    Position = new Vector2(0f, window.Size.Y - 24f)
                });

                window.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (window.Size.X / 2);
                window.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (window.Size.Y / 2);
            }));
            button.Widgets.Add(new ButtonWidget(Game, "Muted Loops", delegate() {
                ContainerWidget window;
                Widgets.Add(window = new ContainerWidget(Game) {
                    UpdateBounds = true,
                    Size = new Vector2(512f, 24f),
                    Label = "Muted Loops"
                });

                window.RefreshValue = delegate() {
                    window.Widgets.Clear();
                    window.Widgets.Add(new WindowHeaderWidget(Game));

                    int i = 0;
                    foreach (string loop in LevelManager.MutedLoops) {
                        window.Widgets.Add(new ContainerWidget(Game, new GuiWidget[] {
                            new ButtonWidget(Game, loop) {
                                Size = new Vector2(window.Size.X - 24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = false,
                                Position = new Vector2(0f, 0f)
                            },
                            new ButtonWidget(Game, "X", delegate() {
                                LevelManager.MutedLoops.Remove(loop);
                                SoundManager.UpdateSongActiveTracks();
                                window.Refresh();
                            }) {
                                Background = new Color(0.5f, 0f, 0f, 1f),
                                Size = new Vector2(24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = true,
                                Position = new Vector2(window.Size.X - 24f, 0f)
                            }
                        }) {
                            Size = new Vector2(window.Size.X, 24f),
                            Background = new Color(DefaultBackground, 0f)
                        });

                        i++;
                    }

                    window.Size.Y = (i+1) * 24f;
                    window.Size.Y = Math.Min(512f, window.Size.Y);

                    window.Widgets.Add(new ButtonWidget(Game, "+", delegate() {
                        ContainerWidget windowAdd;
                        Widgets.Add(windowAdd = new ContainerWidget(Game) {
                            Size = new Vector2(256f, 48f),
                            Label = "Add Muted Loop"
                        });
                        WindowHeaderWidget windowAddHeader;
                        windowAdd.Widgets.Add(windowAddHeader = new WindowHeaderWidget(Game));

                        ButtonWidget windowLabelName;
                        windowAdd.Widgets.Add(windowLabelName = new ButtonWidget(Game, "Name:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 0f)
                        });
                        TextFieldWidget windowFieldName;
                        windowAdd.Widgets.Add(windowFieldName = new TextFieldWidget(Game) {
                            Size = new Vector2(windowAdd.Size.X - windowLabelName.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelName.Size.X, windowLabelName.Position.Y)
                        });
                        List<Loop> keysOrig = SoundManager.CurrentlyPlayingSong.Loops;
                        List<string> keys = new List<string>();
                        foreach (Loop keyOrig in keysOrig) {
                            keys.Add(keyOrig.Name);
                        }
                        windowFieldName.Fill(keys);

                        windowAdd.Widgets.Add(new ButtonWidget(Game, "ADD", delegate() {
                            LevelManager.MutedLoops.Add(windowFieldName.Text);
                            SoundManager.UpdateSongActiveTracks();
                            windowAddHeader.CloseButtonWidget.Action();
                            window.Refresh();
                        }) {
                            Size = new Vector2(windowAdd.Size.X, 24f),
                            UpdateBounds = false,
                            LabelCentered = true,
                            Position = new Vector2(0f, windowAdd.Size.Y - 24f)
                        });

                        windowAdd.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (windowAdd.Size.X / 2);
                        windowAdd.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (windowAdd.Size.Y / 2);
                    }) {
                        Background = new Color(0f, 0.125f, 0f, 1f),
                        Size = new Vector2(window.Size.X, 24f),
                        UpdateBounds = false,
                        LabelCentered = true,
                        Position = new Vector2(0f, window.Size.Y - 24f)
                    });

                    return null;
                };
                window.Refresh();

                window.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (window.Size.X / 2);
                window.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (window.Size.Y / 2);
            }));
            button.Widgets.Add(new ButtonWidget(Game, "Ambience Tracks", delegate() {
                ContainerWidget window;
                Widgets.Add(window = new ContainerWidget(Game) {
                    UpdateBounds = true,
                    Size = new Vector2(256f, 24f),
                    Label = "Ambience Tracks"
                });

                window.RefreshValue = delegate() {
                    window.Widgets.Clear();
                    window.Widgets.Add(new WindowHeaderWidget(Game));

                    int i = 0;
                    foreach (AmbienceTrack track in LevelManager.AmbienceTracks) {
                        window.Widgets.Add(new ContainerWidget(Game, new GuiWidget[] {
                            new ButtonWidget(Game, track.Name) {
                                Size = new Vector2(window.Size.X - 24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = false,
                                Position = new Vector2(0f, 0f)
                            },
                            new ButtonWidget(Game, "X", delegate() {
                                LevelManager.AmbienceTracks.Remove(track);
                                SoundManager.PlayNewAmbience();
                                window.Refresh();
                            }) {
                                Background = new Color(0.5f, 0f, 0f, 1f),
                                Size = new Vector2(24f, 24f),
                                UpdateBounds = false,
                                LabelCentered = true,
                                Position = new Vector2(window.Size.X - 24f, 0f)
                            }
                        }) {
                            Size = new Vector2(window.Size.X, 24f),
                            Background = new Color(DefaultBackground, 0f)
                        });

                        i++;
                    }

                    window.Size.Y = (i+1) * 24f;
                    window.Size.Y = Math.Min(512f, window.Size.Y);

                    window.Widgets.Add(new ButtonWidget(Game, "+", delegate() {
                        ContainerWidget windowAdd;
                        Widgets.Add(windowAdd = new ContainerWidget(Game) {
                            Size = new Vector2(256f, 144f),
                            Label = "Add Ambience Track"
                        });
                        WindowHeaderWidget windowAddHeader;
                        windowAdd.Widgets.Add(windowAddHeader = new WindowHeaderWidget(Game));

                        ButtonWidget windowLabelName;
                        windowAdd.Widgets.Add(windowLabelName = new ButtonWidget(Game, "Name:") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(96f, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 0f)
                        });
                        TextFieldWidget windowFieldName;
                        windowAdd.Widgets.Add(windowFieldName = new TextFieldWidget(Game) {
                            Size = new Vector2(windowAdd.Size.X - windowLabelName.Size.X, 24f),
                            UpdateBounds = false,
                            Position = new Vector2(windowLabelName.Size.X, windowLabelName.Position.Y)
                        });
                        Dictionary<string, string>.KeyCollection keysOrig = SoundManager.GetPrivate<Dictionary<string, string>>("MusicAliases").Keys;
                        List<string> keys = new List<string>();
                        foreach (string keyOrig in keysOrig) {
                            if (!keyOrig.StartsWith("ambience")) {
                                continue;
                            }
                            string key = keyOrig.Replace("\\", " ^ ").Replace("ambience", "Ambience");
                            keys.Add(key);
                        }
                        windowFieldName.Fill(keys);

                        CheckboxWidget windowCheckDawn;
                        windowAdd.Widgets.Add(windowCheckDawn = new CheckboxWidget(Game, "Dawn") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(windowAdd.Size.X, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 24f)
                        });

                        CheckboxWidget windowCheckDay;
                        windowAdd.Widgets.Add(windowCheckDay = new CheckboxWidget(Game, "Day") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(windowAdd.Size.X, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 48f)
                        });

                        CheckboxWidget windowCheckDusk;
                        windowAdd.Widgets.Add(windowCheckDusk = new CheckboxWidget(Game, "Dusk") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(windowAdd.Size.X, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 72f)
                        });

                        CheckboxWidget windowCheckNight;
                        windowAdd.Widgets.Add(windowCheckNight = new CheckboxWidget(Game, "Night") {
                            Background = new Color(DefaultBackground, 0f),
                            Size = new Vector2(windowAdd.Size.X, 24f),
                            UpdateBounds = false,
                            LabelCentered = false,
                            Position = new Vector2(0f, 96f)
                        });

                        windowAdd.Widgets.Add(new ButtonWidget(Game, "ADD", delegate() {
                            LevelManager.AmbienceTracks.Add(new AmbienceTrack() {
                                Name = windowFieldName.Text,
                                Dawn = windowCheckDawn.Checked,
                                Day = windowCheckDay.Checked,
                                Dusk = windowCheckDusk.Checked,
                                Night = windowCheckNight.Checked
                            });
                            SoundManager.PlayNewAmbience();
                            windowAddHeader.CloseButtonWidget.Action();
                            window.Refresh();
                        }) {
                            Size = new Vector2(windowAdd.Size.X, 24f),
                            UpdateBounds = false,
                            LabelCentered = true,
                            Position = new Vector2(0f, windowAdd.Size.Y - 24f)
                        });

                        windowAdd.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (windowAdd.Size.X / 2);
                        windowAdd.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (windowAdd.Size.Y / 2);
                    }) {
                        Background = new Color(0f, 0.125f, 0f, 1f),
                        Size = new Vector2(window.Size.X, 24f),
                        UpdateBounds = false,
                        LabelCentered = true,
                        Position = new Vector2(0f, window.Size.Y - 24f)
                    });

                    return null;
                };
                window.Refresh();

                window.Position.X = GraphicsDevice.Viewport.Width / 2 - (int) (window.Size.X / 2);
                window.Position.Y = GraphicsDevice.Viewport.Height / 2 - (int) (window.Size.Y / 2);
            }));

            TopBarWidget.Widgets.Add(button = new ButtonWidget(Game, "Settings"));
            button.Background.A = 0;
            button.Widgets.Add(new ButtonWidget(Game, "Invert theme", delegate() {
                LevelEditorOptions.Instance.DefaultBackground.R = (byte) (255 - LevelEditorOptions.Instance.DefaultBackground.R);
                LevelEditorOptions.Instance.DefaultBackground.G = (byte) (255 - LevelEditorOptions.Instance.DefaultBackground.G);
                LevelEditorOptions.Instance.DefaultBackground.B = (byte) (255 - LevelEditorOptions.Instance.DefaultBackground.B);

                LevelEditorOptions.Instance.DefaultForeground.R = (byte) (255 - LevelEditorOptions.Instance.DefaultForeground.R);
                LevelEditorOptions.Instance.DefaultForeground.G = (byte) (255 - LevelEditorOptions.Instance.DefaultForeground.G);
                LevelEditorOptions.Instance.DefaultForeground.B = (byte) (255 - LevelEditorOptions.Instance.DefaultForeground.B);

                foreach (GuiWidget widget in Widgets) {
                    widget.UpdateTheme();
                }
            }));
            CheckboxWidget checkboxShowAOTooltips;
            button.Widgets.Add(checkboxShowAOTooltips = new CheckboxWidget(Game, "ArtObject tooltips") {
                RefreshValue = () => LevelEditorOptions.Instance.TooltipArtObjectInfo
            });
            TextFieldWidget fieldBackupHistory;
            button.Widgets.Add(new ContainerWidget(Game, new GuiWidget[] {
                new ButtonWidget(Game, "Backup Depth:") {
                    Background = new Color(DefaultBackground, 0f),
                    LabelCentered = false,
                    Position = new Vector2(0f, 0f)
                },
                fieldBackupHistory = new TextFieldWidget(Game) {
                    RefreshValue = () => LevelEditorOptions.Instance.BackupHistory.ToString(),
                    Size = new Vector2(48f, 24f),
                    Position = new Vector2(144f, 0f)
                }
            }) {
                Size = new Vector2(192f, 24f)
            });
            button.Widgets.Add(new ButtonWidget(Game, "Save", delegate() {
                LevelEditorOptions.Instance.TooltipArtObjectInfo = checkboxShowAOTooltips.Checked;
                LevelEditorOptions.Instance.BackupHistory = int.Parse(fieldBackupHistory.Text);
                LevelEditorOptions.Instance.Save();
            }));

            //INFO
            Widgets.Add(InfoWidget = new EditorInfoWidget(Game));

            //TRILE PICKER
            Widgets.Add(TrilePickerWidget = new TrilePickerWidget(Game));

            //TOOLTIP
            TooltipWidget = new ButtonWidget(Game);

        }
Exemplo n.º 28
0
 private void CreateArtifactsFace()
 {
   foreach (ActorType type in this.GameState.SaveData.Artifacts)
   {
     if (type == ActorType.Tome)
     {
       ArtObject artObject1 = this.CMProvider.Global.Load<ArtObject>("Art Objects/TOME_BAO");
       int key1 = IdentifierPool.FirstAvailable<ArtObjectInstance>(this.LevelManager.ArtObjects);
       this.TomeBackAo = new ArtObjectInstance(artObject1)
       {
         Id = key1,
         Position = this.PlayerManager.Center
       };
       this.TomeBackAo.Initialize();
       this.TomeBackAo.Material = this.AoInstance.Material;
       this.TomeBackAo.Hidden = true;
       this.LevelManager.ArtObjects.Add(key1, this.TomeBackAo);
       this.ArtifactAOs.Add(this.TomeBackAo);
       ArtObject artObject2 = this.CMProvider.Global.Load<ArtObject>("Art Objects/TOME_COVERAO");
       int key2 = IdentifierPool.FirstAvailable<ArtObjectInstance>(this.LevelManager.ArtObjects);
       this.TomeCoverAo = new ArtObjectInstance(artObject2)
       {
         Id = key2,
         Position = this.PlayerManager.Center
       };
       this.TomeCoverAo.Initialize();
       this.TomeCoverAo.Material = this.AoInstance.Material;
       this.TomeCoverAo.Hidden = true;
       this.LevelManager.ArtObjects.Add(key2, this.TomeCoverAo);
       this.ArtifactAOs.Add(this.TomeCoverAo);
     }
     else
     {
       ArtObject artObject = this.CMProvider.Global.Load<ArtObject>("Art Objects/" + ActorTypeExtensions.GetArtObjectName(type));
       int key = IdentifierPool.FirstAvailable<ArtObjectInstance>(this.LevelManager.ArtObjects);
       ArtObjectInstance artObjectInstance = new ArtObjectInstance(artObject)
       {
         Id = key,
         Position = this.PlayerManager.Center
       };
       artObjectInstance.Initialize();
       artObjectInstance.Material = this.AoInstance.Material;
       artObjectInstance.Hidden = true;
       this.LevelManager.ArtObjects.Add(key, artObjectInstance);
       this.ArtifactAOs.Add(artObjectInstance);
     }
   }
 }
Exemplo n.º 29
0
 public override void Initialize()
 {
   base.Initialize();
   this.GameState.MenuCubeIsZoomed = false;
   this.PlayerManager.CanControl = false;
   ArtObject artObject = this.CMProvider.Global.Load<ArtObject>("Art Objects/MENU_CUBEAO");
   bool flag = true;
   if (this.LevelManager.WaterType == LiquidType.Sewer)
   {
     this.oldTextureCache = artObject.Cubemap;
     artObject.Cubemap = this.CMProvider.Global.Load<Texture2D>("Art Objects/MENU_CUBE_GB");
   }
   else if (this.LevelManager.WaterType == LiquidType.Lava)
   {
     this.oldTextureCache = artObject.Cubemap;
     artObject.Cubemap = this.CMProvider.Global.Load<Texture2D>("Art Objects/MENU_CUBE_VIRTUAL");
   }
   else if (this.LevelManager.BlinkingAlpha)
   {
     this.oldTextureCache = artObject.Cubemap;
     artObject.Cubemap = this.CMProvider.Global.Load<Texture2D>("Art Objects/MENU_CUBE_CMY");
   }
   else
     flag = false;
   if (flag)
     new ArtObjectMaterializer(artObject).RecomputeTexCoords(false);
   int key = IdentifierPool.FirstAvailable<ArtObjectInstance>(this.LevelManager.ArtObjects);
   this.AoInstance = new ArtObjectInstance(artObject)
   {
     Id = key,
     Position = this.PlayerManager.Center
   };
   this.AoInstance.Initialize();
   this.AoInstance.Material = new Material();
   this.LevelManager.ArtObjects.Add(key, this.AoInstance);
   this.AoInstance.Scale = new Vector3(0.0f);
   this.OriginalViewpoint = this.CameraManager.Viewpoint;
   this.OriginalCenter = this.CameraManager.Center;
   this.OriginalPixPerTrix = this.CameraManager.PixelsPerTrixel;
   this.OriginalRotation = FezMath.QuaternionFromPhi(FezMath.ToPhi(this.CameraManager.Viewpoint));
   RenderTarget2D renderTarget = this.GraphicsDevice.GetRenderTargets().Length == 0 ? (RenderTarget2D) null : this.GraphicsDevice.GetRenderTargets()[0].RenderTarget as RenderTarget2D;
   this.FillInPlanes();
   this.CreateGoldenCubeFace();
   this.CreateMapsFace();
   this.CreateArtifactsFace();
   this.CreateAntiCubeFace();
   this.CreateHighlights();
   this.CreateTomePages();
   this.GraphicsDevice.SetRenderTarget(renderTarget);
   this.AntiCubes.Position = this.Maps.Position = this.HidingPlanes.Position = this.GoldenCubes.Position = this.AoInstance.Position;
   this.AntiCubes.Scale = this.Maps.Scale = this.HidingPlanes.Scale = this.GoldenCubes.Scale = this.AoInstance.Scale = new Vector3(0.0f);
   this.TransformArtifacts();
   this.BlurEffect = new FastBlurEffect();
   this.enterSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/EnterMenucubeOrMap");
   this.exitSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/ExitMenucubeOrMap");
   this.zoomInSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/ZoomIn");
   this.zoomOutSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/ZoomOut");
   this.rotateLeftSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/RotateLeft");
   this.rotateRightSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/RotateRight");
   this.cursorSound = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/MoveCursorMenucube");
   this.sBackground = this.CMProvider.Global.Load<SoundEffect>("Sounds/Ui/MenuCubeBackground");
   this.eBackground = SoundEffectExtensions.Emit(this.sBackground, true);
   SoundEffectExtensions.Emit(this.enterSound);
   this.AoVisibility = new List<bool>();
   this.AoInstance.Hidden = true;
   this.AoInstance.Visible = false;
   this.GameService.CloseScroll((string) null);
   this.GameState.ShowScroll(MenuCubeFaceExtensions.GetTitle(this.Face), 0.0f, true);
   this.wasLowPass = this.SoundManager.IsLowPass;
   if (!this.wasLowPass)
     this.SoundManager.FadeFrequencies(true);
   this.InRtHandle = this.TargetRenderingManager.TakeTarget();
   this.OutRtHandle = this.TargetRenderingManager.TakeTarget();
   this.TargetRenderingManager.ScheduleHook(this.DrawOrder, this.InRtHandle.Target);
 }
Exemplo n.º 30
0
 protected override void Begin()
 {
   bool flag = this.PlayerManager.Action == ActionType.OpeningTreasure;
   this.sinceActive = flag ? TimeSpan.FromSeconds(-1.0) : TimeSpan.Zero;
   if (flag)
   {
     this.oldDepth = FezMath.Dot(this.PlayerManager.Position, FezMath.DepthMask(this.CameraManager.Viewpoint));
     this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + this.chestAO.Position * FezMath.DepthMask(this.CameraManager.Viewpoint) + FezMath.ForwardVector(this.CameraManager.Viewpoint) * -1.5f;
     this.PlayerManager.LookingDirection = HorizontalDirection.Right;
     this.aoOrigin = this.chestAO.Position;
     this.chestAO.ActorSettings.Inactive = true;
   }
   else
   {
     if (this.PlayerManager.ForcedTreasure != null)
     {
       this.treasureIsMap = false;
       this.treasureInstance = this.PlayerManager.ForcedTreasure;
       this.treasureIsAo = false;
       this.chestAO = (ArtObjectInstance) null;
       this.treasureTrile = this.treasureInstance.Trile;
       this.treasureActorType = this.treasureTrile.ActorSettings.Type;
       this.PlayerManager.Action = ActionType.FindingTreasure;
       this.sinceCollect = TimeSpan.Zero;
       this.oldDepth = FezMath.Dot(this.PlayerManager.Position, FezMath.DepthMask(this.CameraManager.Viewpoint));
       this.PlayerManager.Position = this.PlayerManager.Position * FezMath.ScreenSpaceMask(this.CameraManager.Viewpoint) + this.treasureInstance.Position * FezMath.DepthMask(this.CameraManager.Viewpoint) + 2f * -FezMath.ForwardVector(this.CameraManager.Viewpoint);
     }
     this.aoOrigin = this.treasureIsMap ? this.treasureAoInstance.Position : this.treasureInstance.Position;
     this.sinceActive = TimeSpan.FromSeconds(OpenTreasure.OpeningDuration.TotalSeconds * 0.600000023841858);
     SoundEffectExtensions.Emit(this.assembleSound);
   }
   if (!flag)
     this.PlayerManager.Velocity = new Vector3(0.0f, 0.05f, 0.0f);
   this.WasConstrained = this.CameraManager.Constrained;
   if (this.WasConstrained)
   {
     this.OldCenter = this.CameraManager.Center;
     this.OldPixPerTrix = this.CameraManager.PixelsPerTrixel;
   }
   this.OldPan = this.CameraManager.PanningConstraints;
   this.CameraManager.Constrained = true;
   this.CameraManager.PanningConstraints = new Vector2?();
   this.CameraManager.Center = this.aoOrigin;
   if (!flag)
   {
     this.lastZoom = this.CameraManager.PixelsPerTrixel;
     this.CameraManager.PixelsPerTrixel = 4f;
   }
   if (flag)
     this.aoInitialRotation = this.lightBox.Rotation = this.solidStar.Rotation = this.fadedStar.Rotation = this.flare.Rotation = this.chestAO.Rotation;
   else
     this.solidStar.Rotation = this.fadedStar.Rotation = this.flare.Rotation = Quaternion.Inverse(this.CameraManager.Rotation);
   this.lightBox.Position = this.aoOrigin - Vector3.UnitY / 2f;
   this.reculled = this.restored = false;
   if (flag)
   {
     this.treasureAo = (ArtObject) null;
     this.treasureTrile = (Trile) null;
     this.treasureIsMap = this.treasureIsAo = false;
     this.treasureActorType = this.chestAO.ActorSettings.ContainedTrile;
     if (this.chestAO.ActorSettings.ContainedTrile == ActorType.TreasureMap)
       this.treasureIsMap = true;
     else if (this.chestAO.ActorSettings.ContainedTrile == ActorType.Mail)
       this.treasureIsMail = true;
     else if (ActorTypeExtensions.SupportsArtObjects(this.chestAO.ActorSettings.ContainedTrile))
     {
       this.treasureAo = this.CMProvider.Global.Load<ArtObject>("Art Objects/" + ActorTypeExtensions.GetArtObjectName(this.chestAO.ActorSettings.ContainedTrile));
       this.treasureIsAo = true;
     }
     else
       this.treasureTrile = Enumerable.LastOrDefault<Trile>(this.LevelManager.ActorTriles(this.chestAO.ActorSettings.ContainedTrile));
     Waiters.Wait(1.0, (Action) (() => SoundEffectExtensions.Emit(this.treasureGetSound)));
   }
   if (!flag && this.treasureIsMap)
   {
     this.treasureOrigin = this.aoOrigin - new Vector3(0.0f, 0.125f, 0.0f);
     string treasureMapName = this.treasureAoInstance.ActorSettings.TreasureMapName;
     Texture2D texture2D1 = this.CMProvider.Global.Load<Texture2D>("Other Textures/maps/" + treasureMapName + "_1");
     Texture2D texture2D2 = this.CMProvider.Global.Load<Texture2D>("Other Textures/maps/" + treasureMapName + "_2");
     for (int index = 0; index < this.map.Groups.Count; ++index)
       this.map.Groups[index].Texture = index % 2 == 0 ? (Texture) texture2D1 : (Texture) texture2D2;
     Mesh mesh = Enumerable.First<Mesh>((IEnumerable<Mesh>) this.FloatingMaps, (Func<Mesh, bool>) (x => ((OpenTreasure.TreasureActorSettings) x.CustomData).AoInstance == this.treasureAoInstance));
     this.map.Position = mesh.Position - FezMath.ForwardVector(this.CameraManager.Viewpoint) * 0.5f;
     this.map.Rotation = mesh.Rotation;
     this.FloatingMaps.Remove(mesh);
   }
   this.oldGround = (TrileInstance) null;
   if (this.PlayerManager.Grounded)
   {
     this.oldGround = this.PlayerManager.Ground.First;
     this.oldGroundHeight = this.PlayerManager.Ground.First.Center.Y;
   }
   this.SoundManager.FadeVolume(1f, 0.125f, 2f);
 }