Exemple #1
0
        protected override void SelectEntry(GumpButton button, CoreModuleInfo entry)
        {
            base.SelectEntry(button, entry);

            if (button == null || entry == null)
            {
                return;
            }

            var list = new MenuGumpOptions();

            list.AppendEntry(
                new ListGumpEntry(
                    "Properties",
                    b =>
            {
                Refresh(true);
                User.SendGump(new PropertiesGump(User, entry));
            },
                    HighlightHue));

            if (entry.Enabled)
            {
                list.Replace(
                    "Enable",
                    new ListGumpEntry(
                        "Disable",
                        b =>
                        Send(
                            new ConfirmDialogGump(
                                User,
                                this,
                                title: "Disable Module?",
                                html: "Disable Module: " + entry.Name + "\nDo you want to continue?",
                                onAccept: a =>
                {
                    entry.Enabled = false;
                    Refresh(true);
                },
                                onCancel: Refresh)),
                        HighlightHue));
            }
            else
            {
                list.Replace(
                    "Disable",
                    new ListGumpEntry(
                        "Enable",
                        b =>
                        Send(
                            new ConfirmDialogGump(
                                User,
                                this,
                                title: "Enable Module?",
                                html: "Enable Module: '" + entry.Name + "'\nDo you want to continue?",
                                onAccept: a =>
                {
                    entry.Enabled = true;
                    Refresh(true);
                },
                                onCancel: Refresh)),
                        HighlightHue));
            }

            if (entry.Enabled)
            {
                if (entry.Debug)
                {
                    list.Replace(
                        "Enable Debug",
                        new ListGumpEntry(
                            "Debug Disable",
                            b =>
                            Send(
                                new ConfirmDialogGump(
                                    User,
                                    this,
                                    title: "Disable Module Debugging?",
                                    html: "Disable Module Debugging: " + entry.Name + "\nDo you want to continue?",
                                    onAccept: a =>
                    {
                        entry.Debug = false;
                        Refresh(true);
                    },
                                    onCancel: Refresh)),
                            HighlightHue));
                }
                else
                {
                    list.Replace(
                        "Disable Debug",
                        new ListGumpEntry(
                            "Enable Debug",
                            b =>
                            Send(
                                new ConfirmDialogGump(
                                    User,
                                    this,
                                    title: "Enable Module Debugging?",
                                    html: "Enable Module Debugging: '" + entry.Name + "'\nDo you want to continue?",
                                    onAccept: a =>
                    {
                        entry.Debug = true;
                        Refresh(true);
                    },
                                    onCancel: Refresh)),
                            HighlightHue));
                }

                if (entry.SaveSupported)
                {
                    list.AppendEntry(
                        new ListGumpEntry(
                            "Save",
                            b =>
                    {
                        VitaNexCore.SaveModule(entry);
                        Refresh(true);
                    },
                            HighlightHue));
                }
                else
                {
                    list.RemoveEntry("Save");
                }

                if (entry.LoadSupported)
                {
                    list.AppendEntry(
                        new ListGumpEntry(
                            "Load",
                            b =>
                            Send(
                                new ConfirmDialogGump(
                                    User,
                                    this,
                                    title: "Load Module Data?",
                                    html:
                                    "Loading a modules' saved data after it has been started may yield unexpected results.\nDo you want to continue?",
                                    onAccept: a =>
                    {
                        VitaNexCore.LoadModule(entry);
                        Refresh(true);
                    },
                                    onCancel: Refresh)),
                            HighlightHue));
                }
                else
                {
                    list.RemoveEntry("Load");
                }
            }
            else
            {
                list.RemoveEntry("Save");
                list.RemoveEntry("Load");
                list.RemoveEntry("Enable Debug");
                list.RemoveEntry("Disable Debug");
            }

            Send(new MenuGump(User, Refresh(), list, button));
        }
Exemple #2
0
        private void Compute(Rectangle3D area, ParallelLoopState state)
        {
            if (IsDisposed)
            {
                VitaNexCore.TryCatch(state.Stop);
                return;
            }

            // Check all corners to skip large bodies of water.
            if (Filters.Contains(TileFlag.Wet))
            {
                var land1 = Facet.Tiles.GetLandTile(area.Start.X, area.Start.Y);             // TL
                var land2 = Facet.Tiles.GetLandTile(area.End.X, area.Start.Y);               // TR
                var land3 = Facet.Tiles.GetLandTile(area.Start.X, area.End.Y);               // BL
                var land4 = Facet.Tiles.GetLandTile(area.End.X, area.End.Y);                 // BR

                if ((land1.Ignored || TileData.LandTable[land1.ID].Flags.HasFlag(TileFlag.Wet)) &&
                    (land2.Ignored || TileData.LandTable[land2.ID].Flags.HasFlag(TileFlag.Wet)) &&
                    (land3.Ignored || TileData.LandTable[land3.ID].Flags.HasFlag(TileFlag.Wet)) &&
                    (land4.Ignored || TileData.LandTable[land4.ID].Flags.HasFlag(TileFlag.Wet)))
                {
                    return;
                }
            }

            int x, y, z, h;

            LandTile land;
            TileFlag flags;
            bool     valid;

            for (x = area.Start.X; !IsDisposed && x < area.End.X; x++)
            {
                for (y = area.Start.Y; !IsDisposed && y < area.End.Y; y++)
                {
                    h = GetHashCode(x, y);

                    if (_Points.ContainsKey(h))
                    {
                        continue;
                    }

                    land = Facet.Tiles.GetLandTile(x, y);

                    if (land.Ignored)
                    {
                        continue;
                    }

                    z = land.Z;

                    if (!CanSpawn(x, y, z))
                    {
                        continue;
                    }

                    if (Filters.Length > 0)
                    {
                        flags = TileData.LandTable[land.ID].Flags;

                        if (Filters.Any(f => flags.HasFlag(f)))
                        {
                            continue;
                        }

                        valid = true;

                        foreach (var tile in Facet.Tiles.GetStaticTiles(x, y))
                        {
                            flags = TileData.ItemTable[tile.ID].Flags;

                            if (Filters.Any(f => flags.HasFlag(f)))
                            {
                                valid = false;
                                break;
                            }
                        }

                        if (!valid)
                        {
                            continue;
                        }
                    }

                    if (Validator != null)
                    {
                        lock (Validator)
                        {
                            if (!Validator(Facet, x, y, z))
                            {
                                continue;
                            }
                        }
                    }

                    if (IsDisposed)
                    {
                        break;
                    }

                    lock (_Points)
                    {
                        _Points[h] = new Point3D(x, y, z);
                    }
                }
            }
        }