Ejemplo n.º 1
0
        public BackgroundPlane Clone()
        {
            BackgroundPlane backgroundPlane = new BackgroundPlane()
            {
                HostMesh            = this.HostMesh,
                Animated            = this.Animated,
                TextureName         = this.TextureName,
                Texture             = this.Texture,
                Timing              = this.Timing == null ? (AnimationTiming)null : this.Timing.Clone(),
                Position            = this.position,
                Rotation            = this.rotation,
                Scale               = this.scale,
                LightMap            = this.lightMap,
                AllowOverbrightness = this.allowOverbrightness,
                Filter              = this.filter,
                Doublesided         = this.doublesided,
                Opacity             = this.opacity,
                Crosshatch          = this.crosshatch,
                SyncWithSamples     = this.SyncWithSamples,
                AlwaysOnTop         = this.alwaysOnTop,
                Fullbright          = this.fullbright,
                Loop           = this.Loop,
                Billboard      = this.billboard,
                AttachedGroup  = this.AttachedGroup,
                YTextureRepeat = this.YTextureRepeat,
                XTextureRepeat = this.XTextureRepeat,
                ClampTexture   = this.ClampTexture,
                AttachedPlane  = this.AttachedPlane,
                ActorType      = this.ActorType,
                ParallaxFactor = this.ParallaxFactor
            };

            backgroundPlane.Initialize();
            return(backgroundPlane);
        }
Ejemplo n.º 2
0
        private void InitializeGroup()
        {
            if (this.Group != null)
            {
                this.DestroyInstancedGroup();
            }
            BackgroundPlane backgroundPlane = Enumerable.FirstOrDefault <BackgroundPlane>((IEnumerable <BackgroundPlane>) this.LevelManager.BackgroundPlanes.Values, (Func <BackgroundPlane, bool>)(x =>
            {
                if (x != this && x.Animated == this.Animated && (x.doublesided == this.doublesided && x.crosshatch == this.crosshatch) && (this.Texture != null && x.Texture == this.Texture || this.TextureName != null && x.TextureName == this.TextureName) && (x.Group != null && x.clampTexture == this.clampTexture && (x.lightMap == this.lightMap && x.allowOverbrightness == this.allowOverbrightness)))
                {
                    return(x.pixelatedLightmap == this.pixelatedLightmap);
                }
                else
                {
                    return(false);
                }
            }));

            if (backgroundPlane == null)
            {
                this.Group             = this.HostMesh.AddFace(this.Size, Vector3.Zero, FaceOrientation.Front, true, this.doublesided, this.crosshatch);
                this.Geometry          = new ShaderInstancedIndexedPrimitives <VertexPositionNormalTextureInstance, Matrix>(PrimitiveType.TriangleList, 58);
                this.Geometry.Vertices = Enumerable.ToArray <VertexPositionNormalTextureInstance>(Enumerable.Select <FezVertexPositionNormalTexture, VertexPositionNormalTextureInstance>((IEnumerable <FezVertexPositionNormalTexture>)(this.Group.Geometry as IndexedUserPrimitives <FezVertexPositionNormalTexture>).Vertices, (Func <FezVertexPositionNormalTexture, VertexPositionNormalTextureInstance>)(x => new VertexPositionNormalTextureInstance()
                {
                    Position          = x.Position,
                    Normal            = x.Normal,
                    TextureCoordinate = x.TextureCoordinate
                })));
                this.Geometry.Indices             = Enumerable.ToArray <int>((IEnumerable <int>)(this.Group.Geometry as IndexedUserPrimitives <FezVertexPositionNormalTexture>).Indices);
                this.Geometry.PredictiveBatchSize = 1;
                this.Group.Geometry     = (IIndexedPrimitiveCollection)this.Geometry;
                this.Group.Texture      = this.Texture;
                this.Geometry.Instances = new Matrix[4];
            }
            else
            {
                this.Group    = backgroundPlane.Group;
                this.Geometry = backgroundPlane.Geometry;
            }
            if (this.Animated)
            {
                this.Group.CustomData = (object)new Vector2((float)this.animation.Offsets[0].Width / (float)this.animation.Texture.Width, (float)this.animation.Offsets[0].Height / (float)this.animation.Texture.Height);
            }
            this.InstanceIndex = this.Geometry.InstanceCount++;
            this.UpdateGroupSetings();
        }
Ejemplo n.º 3
0
 public override void Initialize()
 {
   base.Initialize();
   this.LevelManager.AddPlane(this.Plane = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, (Texture) this.CMProvider.CurrentLevel.Load<Texture2D>("Other Textures/CAPSULE"))
   {
     Rotation = this.CameraManager.Rotation,
     Loop = false
   });
   if (this.NpcId.HasValue)
   {
     this.Npc = this.LevelManager.NonPlayerCharacters[this.NpcId.Value];
     this.OldPosition = this.Npc.Position;
     this.Npc.Position = new Vector3(487.0 / 16.0, 49f, 10f);
     this.OldDestinationOffset = this.Npc.DestinationOffset;
     this.Npc.DestinationOffset = new Vector3(-63.0 / 16.0, 0.0f, 0.0f);
     this.Npc.State.Scripted = true;
     this.Npc.State.LookingDirection = HorizontalDirection.Left;
     this.Npc.State.WalkStep = 0.0f;
     this.Npc.State.CurrentAction = NpcAction.Idle;
     this.Npc.State.UpdateAction();
     this.Npc.State.SyncTextureMatrix();
     this.Npc.Group.Position = this.LevelManager.NonPlayerCharacters[this.NpcId.Value].Position;
     this.CameraManager.Constrained = true;
     this.CameraManager.Center = new Vector3(32.5f, 50.5f, 16.5f);
     this.CameraManager.SnapInterpolation();
     this.Plane.Position = this.Npc.Group.Position + new Vector3((float) (FezMath.Sign(this.Npc.State.LookingDirection) * 4) / 16f, 0.375f, 0.0f);
     this.sLetterInsert = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/LetterTubeInsert");
   }
   else
   {
     this.Plane.Position = new Vector3(20.5f, 20.75f, 23.5f);
     this.Enabled = false;
     this.GomezService.ReadMail += new Action(this.Destroy);
   }
   this.LevelManager.LevelChanged += new Action(this.TryDestroy);
 }
Ejemplo n.º 4
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);

        }
Ejemplo n.º 5
0
 private void ShootStars()
 {
   if (this.LevelManager.Sky == null || !FezMath.IsOrthographic(this.CameraManager.Viewpoint) || (this.LevelManager.Rainy || (double) this.TimeManager.TimeFactor <= 0.0) || (this.LevelManager.Sky.Stars == null || (double) this.TimeManager.NightContribution != 1.0 || (!RandomHelper.Probability(5E-05) || this.LevelManager.Name == "TELESCOPE")) || this.LevelManager.Sky.Name == "TREE")
     return;
   Vector3 position = this.CameraManager.Center + this.LevelManager.Size / 2f * FezMath.ForwardVector(this.CameraManager.Viewpoint) + new Vector3(RandomHelper.Centered((double) this.CameraManager.Radius / 2.0 - (double) this.shootingStar.FrameWidth / 32.0)) * FezMath.SideMask(this.CameraManager.Viewpoint) + RandomHelper.Between(-(double) this.CameraManager.Radius / (double) this.CameraManager.AspectRatio / 6.0, (double) this.CameraManager.Radius / (double) this.CameraManager.AspectRatio / 2.0 - (double) this.shootingStar.FrameHeight / 32.0) * Vector3.UnitY;
   BackgroundPlane plane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.shootingStar)
   {
     Position = position,
     Rotation = this.CameraManager.Rotation,
     Doublesided = true,
     Loop = false,
     Fullbright = true,
     Opacity = this.TimeManager.NightContribution,
     Timing = {
       Step = 0.0f
     }
   };
   SoundEffectExtensions.EmitAt(this.sShootingStar, position);
   this.LevelManager.AddPlane(plane);
 }
Ejemplo n.º 6
0
 private void SpawnDust(TrileInstance instance, float opacity, AnimatedTexture animation, bool onRight, bool onLeft)
 {
   float num1 = (float) ((double) instance.Center.Y - (double) instance.TransformedSize.Y / 2.0 * (double) Math.Sign(this.CollisionManager.GravityFactor) + (double) animation.FrameHeight / 32.0 * (double) Math.Sign(this.CollisionManager.GravityFactor));
   float num2 = (float) ((double) FezMath.Dot(instance.TransformedSize, FezMath.SideMask(this.CameraManager.Viewpoint)) / 2.0 + (double) animation.FrameWidth / 32.0 * 2.0 / 3.0);
   if (ActorTypeExtensions.IsBomb(instance.Trile.ActorSettings.Type))
     num2 -= 0.25f;
   opacity = 1f;
   Vector3 vector3_1 = FezMath.RightVector(this.CameraManager.Viewpoint);
   Vector3 vector3_2 = FezMath.ForwardVector(this.CameraManager.Viewpoint);
   bool b = (double) this.CollisionManager.GravityFactor < 0.0;
   if (onRight)
   {
     BackgroundPlane backgroundPlane;
     this.LevelManager.AddPlane(backgroundPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, animation)
     {
       OriginalRotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float) FezMath.AsNumeric(b) * 3.141593f),
       Doublesided = true,
       Loop = false,
       Opacity = opacity,
       Timing = {
         Step = 0.0f
       }
     });
     backgroundPlane.Position = instance.Center * FezMath.XZMask + vector3_1 * num2 + num1 * Vector3.UnitY - vector3_2;
     backgroundPlane.Billboard = true;
   }
   if (!onLeft)
     return;
   BackgroundPlane backgroundPlane1;
   this.LevelManager.AddPlane(backgroundPlane1 = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, animation)
   {
     OriginalRotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 3.141593f) * Quaternion.CreateFromAxisAngle(Vector3.UnitX, (float) FezMath.AsNumeric(b) * 3.141593f),
     Doublesided = true,
     Loop = false,
     Opacity = opacity,
     Timing = {
       Step = 0.0f
     }
   });
   backgroundPlane1.Position = instance.Center * FezMath.XZMask - vector3_1 * num2 + num1 * Vector3.UnitY - vector3_2;
   backgroundPlane1.Billboard = true;
 }
Ejemplo n.º 7
0
 private void InitBitPlanes()
 {
   if (this.lastBits == this.GameState.SaveData.CubeShards + this.GameState.SaveData.SecretCubes)
     return;
   foreach (BackgroundPlane plane in this.BitPlanes)
     this.LevelManager.RemovePlane(plane);
   this.BitPlanes.Clear();
   if (this.AoInstance.Rotation == new Quaternion(0.0f, 0.0f, 0.0f, -1f))
     this.AoInstance.Rotation = Quaternion.Identity;
   int bitCount = ActorTypeExtensions.GetBitCount(this.AoInstance.ArtObject.ActorType);
   for (int index = 0; index < bitCount; ++index)
   {
     BackgroundPlane plane = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, index < this.GameState.SaveData.CubeShards ? (Texture) this.BitTexture : (Texture) this.AntiBitTexture)
     {
       Rotation = this.AoInstance.Rotation,
       Opacity = 0.0f,
       Fullbright = true
     };
     this.BitPlanes.Add(plane);
     this.LevelManager.AddPlane(plane);
   }
   this.lastBits = this.GameState.SaveData.CubeShards + this.GameState.SaveData.SecretCubes;
 }
Ejemplo n.º 8
0
 private void TryInitialize()
 {
   this.OpenSplash = this.OpeningSplash = this.OpenWaterfall = this.OpeningWaterfall = (AnimatedTexture) null;
   this.sWaterfallOpening = (SoundEffect) null;
   this.eWaterfallClosed = (SoundEmitter) null;
   this.eWaterfallOpen = (SoundEmitter) null;
   this.WaterfallPlane = Enumerable.FirstOrDefault<BackgroundPlane>((IEnumerable<BackgroundPlane>) this.LevelManager.BackgroundPlanes.Values, (Func<BackgroundPlane, bool>) (x => x.ActorType == ActorType.BigWaterfall));
   this.Enabled = this.WaterfallPlane != null;
   if (!this.Enabled)
     return;
   this.MoriaPlane = Enumerable.FirstOrDefault<BackgroundPlane>((IEnumerable<BackgroundPlane>) this.LevelManager.BackgroundPlanes.Values, (Func<BackgroundPlane, bool>) (x => x.TextureName == "MORIA_GLOW"));
   if (this.GameState.SaveData.ThisLevel.InactiveGroups.Contains(1) || this.GameState.SaveData.ThisLevel.InactiveVolumes.Contains(19))
     this.MoriaPlane.Opacity = 0.0f;
   this.MoriaPlane.Position -= Vector3.UnitX * (1.0 / 1000.0);
   Comparison<Group> oldGo = this.LevelMaterializer.StaticPlanesMesh.GroupOrder;
   this.LevelMaterializer.StaticPlanesMesh.GroupOrder = (Comparison<Group>) ((x, y) =>
   {
     if (x == this.MoriaPlane.Group)
       return 1;
     if (y != this.MoriaPlane.Group)
       return oldGo(x, y);
     else
       return -1;
   });
   bool flag = this.GameState.SaveData.ThisLevel.ScriptingState == "WATERFALL_OPEN";
   if (flag)
   {
     this.OpenSplash = this.CMProvider.CurrentLevel.Load<AnimatedTexture>("Background Planes/water_giant_splash_open");
     this.OpenWaterfall = this.CMProvider.CurrentLevel.Load<AnimatedTexture>("Background Planes/water_giant_open");
     Waiters.Wait((Func<bool>) (() => !this.GameState.Loading), (Action) (() => this.LevelManager.Volumes[7].Enabled = true));
   }
   else
     this.ForkLoad(false);
   this.SplashPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, flag ? this.OpenSplash : this.CMProvider.CurrentLevel.Load<AnimatedTexture>("Background Planes/water_giant_splash"))
   {
     Doublesided = true
   };
   this.LevelManager.AddPlane(this.SplashPlane);
   this.Top = FezMath.Dot(this.WaterfallPlane.Position + this.WaterfallPlane.Scale * this.WaterfallPlane.Size / 2f, Vector3.UnitY);
   this.TerminalPosition = this.WaterfallPlane.Position - this.WaterfallPlane.Scale * this.WaterfallPlane.Size / 2f * Vector3.UnitY + Vector3.Transform(Vector3.UnitZ, this.WaterfallPlane.Rotation) / 16f;
   this.sinceAlive = 0.0f;
   if (flag)
   {
     this.SwapOpened();
     this.eWaterfallOpen = SoundEffectExtensions.EmitAt(this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/BigWaterfallOpen"), this.WaterfallPlane.Position, true, 0.0f, 0.0f);
   }
   else
     this.eWaterfallClosed = SoundEffectExtensions.EmitAt(this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/BigWaterfallClosed"), this.WaterfallPlane.Position, true, 0.0f, 0.0f);
 }
Ejemplo n.º 9
0
 private void SwapOpened()
 {
   this.LevelManager.RemovePlane(this.WaterfallPlane);
   this.LevelManager.RemovePlane(this.SplashPlane);
   Vector3 position1 = this.SplashPlane.Position;
   Vector3 scale1 = this.SplashPlane.Scale;
   Quaternion rotation1 = this.SplashPlane.Rotation;
   this.SplashPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.OpenSplash)
   {
     Doublesided = true
   };
   this.LevelManager.AddPlane(this.SplashPlane);
   this.SplashPlane.Timing.Restart();
   this.WaterfallPlane.Timing.Loop = true;
   this.SplashPlane.Position = position1;
   this.SplashPlane.Scale = scale1;
   this.SplashPlane.Rotation = rotation1;
   Vector3 position2 = this.WaterfallPlane.Position;
   Vector3 scale2 = this.WaterfallPlane.Scale;
   Quaternion rotation2 = this.WaterfallPlane.Rotation;
   this.WaterfallPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.OpenWaterfall)
   {
     Doublesided = true
   };
   this.LevelManager.AddPlane(this.WaterfallPlane);
   this.WaterfallPlane.Timing.Restart();
   this.WaterfallPlane.Timing.Loop = true;
   this.WaterfallPlane.YTextureRepeat = true;
   this.WaterfallPlane.Position = position2;
   this.WaterfallPlane.Scale = scale2;
   this.WaterfallPlane.Rotation = rotation2;
 }
Ejemplo n.º 10
0
 public LongRunningAction Open(int id)
 {
   if (id != this.WaterfallPlane.Id)
     return (LongRunningAction) null;
   this.GameState.SaveData.ThisLevel.ScriptingState = "WATERFALL_OPEN";
   this.GameState.Save();
   SoundEmitter eWaterfallOpen = SoundEffectExtensions.EmitAt(this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/BigWaterfallOpen"), this.WaterfallPlane.Position, true, true);
   eWaterfallOpen.VolumeFactor = 0.0f;
   eWaterfallOpen.Cue.Play();
   this.opening = true;
   Waiters.Interpolate(6.0, (Action<float>) (s =>
   {
     if (this.eWaterfallClosed == null || this.eWaterfallClosed.Dead)
       return;
     this.eWaterfallClosed.VolumeFactor = (1f - s) * this.sinceAlive;
     if (eWaterfallOpen.Dead)
       return;
     eWaterfallOpen.VolumeFactor = s * this.sinceAlive;
   })).AutoPause = true;
   SoundEffectExtensions.EmitAt(this.sWaterfallOpening, this.WaterfallPlane.Position);
   this.ScriptId = this.ScriptingManager.EvaluatedScript.Script.Id;
   this.LevelManager.RemovePlane(this.WaterfallPlane);
   this.LevelManager.RemovePlane(this.SplashPlane);
   Vector3 position1 = this.SplashPlane.Position;
   Vector3 scale1 = this.SplashPlane.Scale;
   Quaternion rotation1 = this.SplashPlane.Rotation;
   this.SplashPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.OpeningSplash)
   {
     Doublesided = true
   };
   this.LevelManager.AddPlane(this.SplashPlane);
   this.SplashPlane.Timing.Restart();
   this.WaterfallPlane.Timing.Loop = false;
   this.SplashPlane.Position = position1;
   this.SplashPlane.Scale = scale1;
   this.SplashPlane.Rotation = rotation1;
   Vector3 position2 = this.WaterfallPlane.Position;
   Vector3 scale2 = this.WaterfallPlane.Scale;
   Quaternion rotation2 = this.WaterfallPlane.Rotation;
   this.WaterfallPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.OpeningWaterfall)
   {
     Doublesided = true
   };
   this.LevelManager.AddPlane(this.WaterfallPlane);
   this.WaterfallPlane.Timing.Restart();
   this.WaterfallPlane.Timing.Loop = false;
   this.WaterfallPlane.YTextureRepeat = true;
   this.WaterfallPlane.Position = position2;
   this.WaterfallPlane.Scale = scale2;
   this.WaterfallPlane.Rotation = rotation2;
   return new LongRunningAction((Func<float, float, bool>) ((_, __) =>
   {
     if (!this.WaterfallPlane.Timing.Ended)
       return false;
     this.opening = false;
     this.SwapOpened();
     return true;
   }));
 }
Ejemplo n.º 11
0
 private void TryInitialize()
 {
   this.CodeMachineAO = (ArtObjectInstance) null;
   this.BitPlanes = (BackgroundPlane[]) null;
   this.BitStates = (CodeMachineHost.BitState[]) null;
   this.Enabled = false;
   this.Input.Clear();
   CodeMachineHost codeMachineHost1 = this;
   CodeMachineHost codeMachineHost2 = this;
   ICollection<ArtObjectInstance> values = this.LevelManager.ArtObjects.Values;
   Func<ArtObjectInstance, bool> predicate = (Func<ArtObjectInstance, bool>) (x => x.ArtObject.ActorType == ActorType.CodeMachine);
   ArtObjectInstance artObjectInstance1;
   ArtObjectInstance artObjectInstance2 = artObjectInstance1 = Enumerable.FirstOrDefault<ArtObjectInstance>((IEnumerable<ArtObjectInstance>) values, predicate);
   codeMachineHost2.CodeMachineAO = artObjectInstance1;
   int num1 = artObjectInstance2 != null ? 1 : 0;
   codeMachineHost1.Enabled = num1 != 0;
   if (!this.Enabled)
     return;
   this.BitPlanes = new BackgroundPlane[144];
   this.BitStates = new CodeMachineHost.BitState[144];
   Texture2D texture2D = this.CMProvider.CurrentLevel.Load<Texture2D>("Other Textures/glow/code_machine_glowbit");
   for (int index1 = 0; index1 < 36; ++index1)
   {
     BackgroundPlane backgroundPlane1 = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, (Texture) texture2D)
     {
       Fullbright = true,
       Opacity = 0.0f,
       Rotation = Quaternion.Identity
     };
     this.BitPlanes[index1 * 4] = backgroundPlane1;
     BackgroundPlane backgroundPlane2 = backgroundPlane1.Clone();
     backgroundPlane2.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 1.570796f);
     this.BitPlanes[index1 * 4 + 1] = backgroundPlane2;
     BackgroundPlane backgroundPlane3 = backgroundPlane1.Clone();
     backgroundPlane3.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 3.141593f);
     this.BitPlanes[index1 * 4 + 2] = backgroundPlane3;
     BackgroundPlane backgroundPlane4 = backgroundPlane1.Clone();
     backgroundPlane4.Rotation = Quaternion.CreateFromAxisAngle(Vector3.Up, 4.712389f);
     this.BitPlanes[index1 * 4 + 3] = backgroundPlane4;
     int num2 = index1 % 6;
     int num3 = index1 / 6;
     for (int index2 = 0; index2 < 4; ++index2)
     {
       BackgroundPlane plane = this.BitPlanes[index1 * 4 + index2];
       this.BitStates[index1 * 4 + index2] = new CodeMachineHost.BitState();
       Vector3 vector3_1 = Vector3.Transform(Vector3.UnitZ, plane.Rotation);
       Vector3 vector3_2 = Vector3.Transform(Vector3.Right, plane.Rotation);
       plane.Position = this.CodeMachineAO.Position + vector3_1 * 1.5f + vector3_2 * (float) (num2 * 8 - 20) / 16f + Vector3.Up * (float) (35 - num3 * 8) / 16f;
       this.LevelManager.AddPlane(plane);
     }
   }
 }
Ejemplo n.º 12
0
 public GeyserState(TrileGroup group, GeysersHost host)
 {
   ServiceHelper.InjectServices((object) this);
   this.Host = host;
   this.Group = group;
   this.SinceStateChange = TimeSpan.FromSeconds(-(double) group.GeyserOffset);
   Vector3 position = Enumerable.Aggregate<TrileInstance, Vector3>((IEnumerable<TrileInstance>) this.Group.Triles, Vector3.Zero, (Func<Vector3, TrileInstance, Vector3>) ((a, b) => a + b.Center)) / (float) group.Triles.Count;
   int key1 = IdentifierPool.FirstAvailable<BackgroundPlane>(this.LevelManager.BackgroundPlanes);
   this.TopPlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, "sewer/sewer_geyser_top", true)
   {
     Id = key1,
     Position = position,
     YTextureRepeat = true,
     Crosshatch = true,
     Doublesided = true
   };
   this.LevelManager.BackgroundPlanes.Add(key1, this.TopPlane);
   int key2 = IdentifierPool.FirstAvailable<BackgroundPlane>(this.LevelManager.BackgroundPlanes);
   this.TilePlane = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, "sewer/sewer_geyser_tile", true)
   {
     Id = key2,
     Position = position,
     YTextureRepeat = true,
     Billboard = true
   };
   this.LevelManager.BackgroundPlanes.Add(key2, this.TilePlane);
   this.TopPlane.Timing.Step = this.TilePlane.Timing.Step;
   this.loopEmitter = SoundEffectExtensions.EmitAt(this.Host.LoopSound, position, true, 0.0f, 0.0f);
   foreach (TrileInstance trileInstance in group.Triles)
   {
     trileInstance.PhysicsState.IgnoreCollision = true;
     trileInstance.PhysicsState.IgnoreClampToWater = true;
   }
 }
Ejemplo n.º 13
0
 public BackgroundPlane Clone()
 {
   BackgroundPlane backgroundPlane = new BackgroundPlane()
   {
     HostMesh = this.HostMesh,
     Animated = this.Animated,
     TextureName = this.TextureName,
     Texture = this.Texture,
     Timing = this.Timing == null ? (AnimationTiming) null : this.Timing.Clone(),
     Position = this.position,
     Rotation = this.rotation,
     Scale = this.scale,
     LightMap = this.lightMap,
     AllowOverbrightness = this.allowOverbrightness,
     Filter = this.filter,
     Doublesided = this.doublesided,
     Opacity = this.opacity,
     Crosshatch = this.crosshatch,
     SyncWithSamples = this.SyncWithSamples,
     AlwaysOnTop = this.alwaysOnTop,
     Fullbright = this.fullbright,
     Loop = this.Loop,
     Billboard = this.billboard,
     AttachedGroup = this.AttachedGroup,
     YTextureRepeat = this.YTextureRepeat,
     XTextureRepeat = this.XTextureRepeat,
     ClampTexture = this.ClampTexture,
     AttachedPlane = this.AttachedPlane,
     ActorType = this.ActorType,
     ParallaxFactor = this.ParallaxFactor
   };
   backgroundPlane.Initialize();
   return backgroundPlane;
 }
Ejemplo n.º 14
0
 private void TryInitialize()
 {
   this.DoorAo = (ArtObjectInstance) null;
   this.AttachedGroup = (TrileGroup) null;
   this.AssociatedVolume = (Volume) null;
   this.Enabled = false;
   this.sRumble = (SoundEffect) null;
   this.sLightUp = (SoundEffect) null;
   this.sFadeOut = (SoundEffect) null;
   if (this.eRumble != null && !this.eRumble.Dead)
     this.eRumble.Cue.Stop(false);
   this.eRumble = (SoundEmitter) null;
   foreach (ArtObjectInstance artObjectInstance in (IEnumerable<ArtObjectInstance>) this.LevelManager.ArtObjects.Values)
   {
     if (artObjectInstance.ArtObject.ActorType == ActorType.SecretPassage)
     {
       this.DoorAo = artObjectInstance;
       this.Enabled = true;
       break;
     }
   }
   if (!this.Enabled)
   {
     if (this.GlowPlane != null)
       this.GlowPlane.Dispose();
     this.GlowPlane = (BackgroundPlane) null;
   }
   if (!this.Enabled)
     return;
   this.AttachedGroup = this.LevelManager.Groups[this.DoorAo.ActorSettings.AttachedGroup.Value];
   this.AssociatedVolume = Enumerable.FirstOrDefault<Volume>((IEnumerable<Volume>) this.LevelManager.Volumes.Values, (Func<Volume, bool>) (x =>
   {
     if (x.ActorSettings != null)
       return x.ActorSettings.IsSecretPassage;
     else
       return false;
   }));
   string key = (string) null;
   foreach (Script script in (IEnumerable<Script>) this.LevelManager.Scripts.Values)
   {
     foreach (ScriptAction scriptAction in script.Actions)
     {
       if (scriptAction.Object.Type == "Level" && scriptAction.Operation.Contains("Level"))
       {
         foreach (ScriptTrigger scriptTrigger in script.Triggers)
         {
           if (scriptTrigger.Object.Type == "Volume" && scriptTrigger.Event == "Enter" && scriptTrigger.Object.Identifier.HasValue)
             key = scriptAction.Arguments[0];
         }
       }
     }
   }
   this.Accessible = this.GameState.SaveData.World.ContainsKey(key);
   this.sRumble = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/MiscActors/Rumble");
   this.sLightUp = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Zu/DoorBitLightUp");
   this.sFadeOut = this.CMProvider.CurrentLevel.Load<SoundEffect>("Sounds/Zu/DoorBitFadeOut");
   if (!this.Accessible)
   {
     this.Enabled = false;
   }
   else
   {
     this.GlowPlane = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, (Texture) this.CMProvider.CurrentLevel.Load<Texture2D>("Other Textures/glow/secret_passage"))
     {
       Fullbright = true,
       Opacity = 0.0f,
       Position = this.DoorAo.Position + FezMath.AsVector(Enumerable.First<FaceOrientation>((IEnumerable<FaceOrientation>) this.AssociatedVolume.Orientations)) / (65.0 / 32.0),
       Rotation = FezMath.QuaternionFromPhi(FezMath.ToPhi(Enumerable.First<FaceOrientation>((IEnumerable<FaceOrientation>) this.AssociatedVolume.Orientations))),
       AttachedGroup = new int?(this.AttachedGroup.Id)
     };
     this.LevelManager.AddPlane(this.GlowPlane);
     this.ExpectedViewpoint = FezMath.AsViewpoint(Enumerable.First<FaceOrientation>((IEnumerable<FaceOrientation>) this.AssociatedVolume.Orientations));
     if (!this.LevelManager.WentThroughSecretPassage)
       return;
     this.MoveUp = true;
     this.GlowPlane.Opacity = 1f;
     this.SinceStarted = TimeSpan.Zero;
     this.AoOrigin = this.DoorAo.Position;
     this.PlaneOrigin = this.GlowPlane.Position;
   }
 }
Ejemplo n.º 15
0
 public WaterfallState(BackgroundPlane plane, PlaneParticleSystem ps, WaterfallsHost host)
 {
   WaterfallsHost.WaterfallState waterfallState = this;
   ServiceHelper.InjectServices((object) this);
   this.Host = host;
   this.Plane = plane;
   this.ParticleSystem = ps;
   bool flag = plane.ActorType == ActorType.Trickle;
   this.Splash = new BackgroundPlane(this.LevelMaterializer.AnimatedPlanesMesh, this.LevelManager.WaterType != LiquidType.Sewer ? (this.LevelManager.WaterType != LiquidType.Purple ? this.CMProvider.CurrentLevel.Load<AnimatedTexture>("Background Planes/water/" + (flag ? "water_small_splash" : "water_large_splash")) : this.CMProvider.CurrentLevel.Load<AnimatedTexture>("Background Planes/waterPink/" + (flag ? "water_small_splash" : "water_large_splash"))) : this.CMProvider.CurrentLevel.Load<AnimatedTexture>("Background Planes/sewer/" + (flag ? "sewer_small_splash" : "sewer_large_splash")))
   {
     Doublesided = true,
     Crosshatch = true
   };
   this.LevelManager.AddPlane(this.Splash);
   this.Top = FezMath.Dot(this.Plane.Position + this.Plane.Scale * this.Plane.Size / 2f, Vector3.UnitY);
   this.TerminalPosition = this.Plane.Position - this.Plane.Scale * this.Plane.Size / 2f * Vector3.UnitY + Vector3.Transform(Vector3.UnitZ, plane.Rotation) / 16f;
   foreach (BackgroundPlane backgroundPlane in Enumerable.Where<BackgroundPlane>((IEnumerable<BackgroundPlane>) this.LevelManager.BackgroundPlanes.Values, (Func<BackgroundPlane, bool>) (x =>
   {
     int? local_0 = x.AttachedPlane;
     int local_1 = plane.Id;
     if ((local_0.GetValueOrDefault() != local_1 ? 0 : (local_0.HasValue ? 1 : 0)) != 0)
       return FezMath.AlmostEqual(Vector3.Transform(Vector3.UnitZ, plane.Rotation).Y, 0.0f);
     else
       return false;
   })))
     this.AttachedPlanes.Add(backgroundPlane);
   Vector3 position = this.LevelManager.WaterType == LiquidType.None ? this.Top * Vector3.UnitY + this.Plane.Position * FezMath.XZMask : this.TerminalPosition * FezMath.XZMask + this.LevelManager.WaterHeight * Vector3.UnitY;
   Waiters.Wait((double) RandomHelper.Between(0.0, 1.0), (Action) (() => waterfallState.BubblingEmitter = SoundEffectExtensions.EmitAt(waterfallState.Host.SewageFallSound, position, true, RandomHelper.Centered(0.025), 0.0f)));
 }
Ejemplo n.º 16
0
 private void RebuildFlare()
 {
   if (this.LevelManager.BackgroundPlanes.ContainsKey(-2))
     return;
   this.LevelManager.BackgroundPlanes.Add(-2, this.HaloPlane = new BackgroundPlane(this.LevelMaterializer.StaticPlanesMesh, this.LevelManager.GomezHaloName ?? "flare", false)
   {
     Id = -2,
     LightMap = true,
     AlwaysOnTop = true,
     Billboard = true,
     Hidden = false,
     Filter = this.LevelManager.HaloFiltering ? new Color(0.425f, 0.425f, 0.425f, 1f) : new Color(0.5f, 0.5f, 0.5f, 1f),
     PixelatedLightmap = !this.LevelManager.HaloFiltering
   });
 }