////////////////

        public static bool IsValidTile(int tileX, int tileY)
        {
            if (!WorldGen.InWorld(tileX, tileY, 0))
            {
                return(false);
            }
            Tile tile = Framing.GetTileSafely(tileX, tileY);

            if (TileHelpers.IsAir(tile))
            {
                return(false);
            }
            if (!tile.active())
            {
                return(false);
            }
            if (!Main.tileSolid[(int)tile.type])
            {
                return(false);
            }
            if (Main.tileSolidTop[(int)tile.type])
            {
                return(false);
            }

            return(true);
        }
示例#2
0
 public void FindRandomTile(out int tile_x, out int tile_y)
 {
     do
     {
         tile_x = WorldGen.genRand.Next(0, Main.maxTilesX);
         tile_y = WorldGen.genRand.Next(0, Main.maxTilesY);
     } while(TileHelpers.IsAir(Framing.GetTileSafely(tile_x, tile_y)));
 }
示例#3
0
        public virtual void ColorTile(PaintedHillsMod mymod, int tile_x, int tile_y)
        {
            if (TileHelpers.IsAir(Framing.GetTileSafely(tile_x, tile_y)))
            {
                return;
            }

            this.HueMap.AddHue(tile_x, tile_y, this.Hue);
        }
示例#4
0
        public bool ApplyDowseIfTileIsTarget(int tile_x, int tile_y, int tile_type)
        {
            Tile tile = Framing.GetTileSafely(tile_x, tile_y);

            if (tile.type != tile_type || TileHelpers.IsAir(tile))
            {
                return(false);
            }

            if (!this.DowsedTiles.ContainsKey(tile_type))
            {
                this.DowsedTiles[tile_type] = new DowsedTiles();
            }
            this.DowsedTiles[tile_type].AddDowseAt(tile_x, tile_y);

            return(true);
        }
示例#5
0
        public void AddHue(int tile_x, int tile_y, Paints hue)
        {
            Tile tile = Framing.GetTileSafely(tile_x, tile_y);

            if (TileHelpers.IsAir(tile))
            {
                return;
            }

            tile.color((byte)hue);

            if (!this.ContainsKey(tile_x))
            {
                this.Add(tile_x, new Dictionary <int, Paints>());
            }
            this[tile_x][tile_y] = hue;
        }
        ////////////////

        public static void HitTilesInRadius(int tileX, int tileY, int radius, int damage)
        {
            int radiusTiles        = (int)Math.Round((double)(radius / 16));
            int radiusTilesSquared = radiusTiles * radiusTiles;

            int left   = tileX - (radiusTiles + 1);
            int right  = tileX + (radiusTiles + 1);
            int top    = tileY - (radiusTiles + 1);
            int bottom = tileY + (radiusTiles + 1);

            for (int i = left; i < right; i++)
            {
                if (i < 0 || i >= Main.maxTilesX - 1)
                {
                    continue;
                }

                for (int j = top; j < bottom; j++)
                {
                    if (j < 0 || j >= Main.maxTilesY - 1)
                    {
                        continue;
                    }
                    if (TileHelpers.IsAir(Framing.GetTileSafely(i, j)))
                    {
                        continue;
                    }

                    int xOff = i - tileX;
                    int yOff = j - tileY;

                    int currTileDistSquared = (xOff * xOff) + (yOff * yOff);
                    if (currTileDistSquared > radiusTilesSquared)
                    {
                        continue;
                    }

                    float percentToCenter = 1f - ((float)currTileDistSquared / (float)radiusTilesSquared);

                    DestructibleTilesProjectile.HitTile(damage, i, j, 1, percentToCenter);
                }
            }
        }
示例#7
0
        public override void ChooseDowsingTypeAtMouse(Player player)
        {
            var       item_info    = this.item.GetGlobalItem <RodItemInfo>();
            Rectangle screen_frame = UIHelpers.GetWorldFrameOfScreen();
            Vector2   screen_mouse = UIHelpers.ConvertToScreenPosition(new Vector2(Main.mouseX, Main.mouseY) + Main.screenPosition);
            Vector2   world_mouse  = screen_mouse + new Vector2(screen_frame.X, screen_frame.Y);
            int       tile_x       = (int)(world_mouse.X / 16);
            int       tile_y       = (int)(world_mouse.Y / 16);
            Tile      tile         = Framing.GetTileSafely(tile_x, tile_y);

            if (!TileHelpers.IsAir(tile))
            {
                if (TileIdentityHelpers.IsObject(tile.type))
                {
                    string text = Lang.GetMapObjectName(Main.Map[tile_x, tile_y].Type);

                    text = TileIdentityHelpers.GetVanillaTileName(item_info.TargetTileType);

                    if (text == "")
                    {
                        Main.NewText("Vining Rod now attuned to some kind of material...", RodItem.AttunedColor);
                    }
                    else
                    {
                        Main.NewText("Vining Rod now attuned to any " + text, RodItem.AttunedColor);
                    }

                    item_info.TargetTileType = tile.type;

                    RodItem.RenderDowseEffect(new Vector2(tile_x * 16, tile_y * 16), 5, Color.GreenYellow);
                }
                else
                {
                    Main.NewText("Vining Rod may only attune to objects.", Color.Yellow);
                }
            }
        }
 public static bool CanPaintBackground(Tile tile)
 {
     return(!TileHelpers.IsAir(tile) && tile.wall != 0);
 }
示例#9
0
 public override bool CanPaintAt(Tile tile)
 {
     return(!TileHelpers.IsAir(tile) && tile.wall != 0);
 }
        public static void PeekAdjacentClearTiles(HueTileMap huemap, IDictionary <int, ISet <int> > peek, int tile_x, int tile_y)
        {
            if (TileHelpers.IsAir(Framing.GetTileSafely(tile_x, tile_y)))
            {
                return;
            }

            int min_x = Math.Max(tile_x - 1, 0);
            int max_x = Math.Min(tile_x + 1, Main.mapMaxX - 1);
            int min_y = Math.Max(tile_y - 1, 0);
            int max_y = Math.Min(tile_y + 1, Main.mapMaxY - 1);

            int x = tile_x;
            int y = tile_y - 1;

            if (y >= 0)
            {
                if (!huemap.HasHue(x, y) && !TileHelpers.IsAir(Framing.GetTileSafely(x, y)))
                {
                    if (!peek.ContainsKey(x))
                    {
                        peek[x] = new HashSet <int>();
                    }
                    peek[x].Add(y);
                }
            }

            x -= 1;
            y += 1;
            if (x >= 0)
            {
                if (!huemap.HasHue(x, y) && !TileHelpers.IsAir(Framing.GetTileSafely(x, y)))
                {
                    if (!peek.ContainsKey(x))
                    {
                        peek[x] = new HashSet <int>();
                    }
                    peek[x].Add(y);
                }
            }

            x += 2;
            if (x < Main.mapMaxX)
            {
                if (!huemap.HasHue(x, y) && !TileHelpers.IsAir(Framing.GetTileSafely(x, y)))
                {
                    peek[x].Add(y);
                }
            }

            x -= 1;
            y += 1;
            if (y < Main.mapMaxY)
            {
                if (!huemap.HasHue(x, y) && !TileHelpers.IsAir(Framing.GetTileSafely(x, y)))
                {
                    if (!peek.ContainsKey(x))
                    {
                        peek[x] = new HashSet <int>();
                    }
                    peek[x].Add(y);
                }
            }
        }
        public bool CanDrawTileOverlay(int tileX, int tileY)
        {
            /*if( !Main.SettingsEnabled_MinersWobble ) {
             *      return;
             * }*/

            Tile     tile = Framing.GetTileSafely(tileX, tileY);
            TileData data = this.Data[tileX][tileY];

            if (data.AnimationTimeDuration > 0)
            {
                data.AnimationTimeDuration--;
            }

            if (TileHelpers.IsAir(tile))
            {
                return(false);
            }
            if (!TileDataManager.IsValidTile(tileX, tileY))
            {
                return(false);
            }
            if (tile.slope() > 0)
            {
                return(false);
            }
            if (tile.halfBrick())
            {
                return(false);
            }
            if (TileLoader.IsClosedDoor(tile))
            {
                return(false);
            }

            if (tile.type == 5)
            {
                int frameX = (int)(tile.frameX / 22);
                int frameY = (int)(tile.frameY / 22);

                if (frameY < 9)
                {
                    if (!
                        ((frameX != 1 && frameX != 2) || frameY < 6 || frameY > 8) &&
                        (frameX != 3 || frameY > 2) &&
                        (frameX != 4 || frameY < 3 || frameY > 5) &&
                        (frameX != 5 || frameY < 6 || frameY > 8)
                        )
                    {
                        return(false);
                    }
                }
            }
            else if (tile.type == 72)
            {
                if (tile.frameX > 34)
                {
                    return(false);
                }
            }

            return(true);
        }
        ////////////////

        private void InitializeComponents()
        {
            var mymod = ModHelpersMod.Instance;
            UIModControlPanelTab self  = this;
            ModControlPanelLogic logic = this.Logic;
            float top = 0;

            this.Theme.ApplyPanel(this);


            ////////

            var tip = new UIText("To enable issue reports for your mod, ");

            this.Append((UIElement)tip);

            this.TipUrl = new UIWebUrl(this.Theme, "read this.",
                                       "https://forums.terraria.org/index.php?threads/mod-helpers.63670/#modders",
                                       false, 1f);
            this.TipUrl.Left.Set(tip.GetInnerDimensions().Width, 0f);
            this.TipUrl.Top.Set(-2f, 0f);
            this.Append((UIElement)this.TipUrl);

            this.OpenConfigList = new UITextPanelButton(this.Theme, "Edit Configs");
            this.OpenConfigList.Top.Set(top - 8f, 0f);
            this.OpenConfigList.Left.Set(-188f, 1f);
            this.OpenConfigList.Width.Set(160f, 0f);
            this.OpenConfigList.OnClick += (_, __) => {
                MainMenuHelpers.OpenModConfigListUI();
            };
            this.Append(this.OpenConfigList);

            top += 24f;

            ////

            var modListPanel = new UIPanel();

            {
                modListPanel.Top.Set(top, 0f);
                modListPanel.Width.Set(0f, 1f);
                modListPanel.Height.Set(UIModControlPanelTab.ModListHeight, 0f);
                modListPanel.HAlign = 0f;
                modListPanel.SetPadding(4f);
                modListPanel.PaddingTop      = 0.0f;
                modListPanel.BackgroundColor = this.Theme.ListBgColor;
                modListPanel.BorderColor     = this.Theme.ListEdgeColor;
                this.Append((UIElement)modListPanel);

                this.ModListElem = new UIList();
                {
                    this.ModListElem.Width.Set(-25, 1f);
                    this.ModListElem.Height.Set(0f, 1f);
                    this.ModListElem.HAlign      = 0f;
                    this.ModListElem.ListPadding = 4f;
                    this.ModListElem.SetPadding(0f);
                    modListPanel.Append((UIElement)this.ModListElem);

                    top += UIModControlPanelTab.ModListHeight + this.PaddingTop - 8;

                    UIScrollbar scrollbar = new UIScrollbar();
                    {
                        scrollbar.Top.Set(8f, 0f);
                        scrollbar.Height.Set(-16f, 1f);
                        scrollbar.SetView(100f, 1000f);
                        scrollbar.HAlign = 1f;
                        modListPanel.Append((UIElement)scrollbar);
                        this.ModListElem.SetScrollbar(scrollbar);
                    }
                }
            }

            ////

            this.IssueTitleInput = new UITextInputAreaPanel(this.Theme, "Enter title of mod issue", 128);
            this.IssueTitleInput.Top.Set(top, 0f);
            this.IssueTitleInput.Width.Set(0f, 1f);
            this.IssueTitleInput.Height.Pixels = 36f;
            this.IssueTitleInput.HAlign        = 0f;
            this.IssueTitleInput.SetPadding(8f);
            this.IssueTitleInput.Disable();
            this.IssueTitleInput.OnPreTextChange += (_) => {
                self.RefreshIssueSubmitButton();
                return(true);
            };
            this.Append((UIElement)this.IssueTitleInput);

            top += 36f;

            this.IssueBodyInput = new UITextInputAreaPanel(this.Theme, "Describe mod issue");
            this.IssueBodyInput.Top.Set(top, 0f);
            this.IssueBodyInput.Width.Set(0f, 1f);
            this.IssueBodyInput.Height.Pixels = 36f;
            this.IssueBodyInput.HAlign        = 0f;
            this.IssueBodyInput.SetPadding(8f);
            this.IssueBodyInput.Disable();
            this.IssueBodyInput.OnPreTextChange += (_) => {
                self.RefreshIssueSubmitButton();
                return(true);
            };
            this.Append((UIElement)this.IssueBodyInput);

            top += 36f;

            ////

            this.IssueSubmitButton = new UITextPanelButton(this.Theme, "Submit Issue");
            this.IssueSubmitButton.Top.Set(top, 0f);
            this.IssueSubmitButton.Left.Set(0f, 0f);
            this.IssueSubmitButton.Width.Set(200f, 0f);
            this.IssueSubmitButton.Disable();
            this.IssueSubmitButton.OnClick += (_, __) => {
                if (self.AwaitingReport || !self.IssueSubmitButton.IsEnabled)
                {
                    return;
                }
                self.SubmitIssue();
            };
            this.Append(this.IssueSubmitButton);

            top += 26f;

            this.ModLockButton = new UITextPanelButton(this.Theme, UIModControlPanelTab.ModLockTitle);
            this.ModLockButton.Top.Set(top, 0f);
            this.ModLockButton.Left.Set(0f, 0f);
            this.ModLockButton.Width.Set(0f, 1f);
            if (Main.netMode != 0 || !ModHelpersMod.Config.WorldModLockEnable)
            {
                this.ModLockButton.Disable();
            }
            this.ModLockButton.OnClick += (_, __) => {
                if (!self.ModLockButton.IsEnabled)
                {
                    return;
                }
                self.ToggleModLock();
                Main.PlaySound(SoundID.Unlock);
            };
            this.Append(this.ModLockButton);

            this.RefreshModLockButton();

            top += 26f;

            this.CleanupModTiles = new UITextPanelButton(this.Theme, "Cleanup unused mod tiles");
            this.CleanupModTiles.Top.Set(top, 0f);
            this.CleanupModTiles.Left.Set(0f, 0f);
            this.CleanupModTiles.Width.Set(0f, 1f);
            if (Main.netMode != 0)
            {
                this.CleanupModTiles.Disable();
            }
            this.CleanupModTiles.OnClick += (_, __) => {
                if (!self.CleanupModTiles.IsEnabled)
                {
                    return;
                }

                int cleaned = 0;

                for (int i = 0; i < Main.maxTilesX; i++)
                {
                    for (int j = 0; j < Main.maxTilesY; j++)
                    {
                        Tile tile = Framing.GetTileSafely(i, j);
                        if (TileHelpers.IsAir(tile))
                        {
                            continue;
                        }
                        ModTile modTile = ModContent.GetModTile(tile.type);
                        if (modTile == null)
                        {
                            continue;
                        }

                        if (modTile.mod == null || modTile is MysteryTile)
                        {
                            TileHelpers.KillTile(i, j, false, false);
                            cleaned++;
                        }
                    }
                }

                Main.NewText(cleaned + " modded tiles cleaned up.", Color.Lime);
            };
            this.Append(this.CleanupModTiles);

            top += 32f;

            ////

            /*var modrec_url = new UIWebUrl( this.Theme, "Need mods?", "https://sites.google.com/site/terrariamodsuggestions/" );
             * modrecUrl.Top.Set( top, 0f );
             * modrecUrl.Left.Set( 0f, 0f );
             * this.InnerContainer.Append( modrecUrl );
             *
             * var serverbrowser_url = new UIWebUrl( this.Theme, "Lonely?", "https://forums.terraria.org/index.php?threads/server-browser-early-beta.68346/" );
             * serverbrowser_url.Top.Set( top, 0f );
             * this.InnerContainer.Append( serverbrowser_url );
             * serverbrowser_url.Left.Set( -serverbrowser_url.GetDimensions().Width * 0.5f, 0.5f );*/

            string supportMsg = UIModControlPanelTab.SupportMessages[this.RandomSupportTextIdx];

            this.SupportUrl = new UIWebUrl(this.Theme, supportMsg, "https://www.patreon.com/hamstar0", false);
            this.SupportUrl.Top.Set(top, 0f);
            this.Append(this.SupportUrl);
            //this.SupportUrl.Left.Set( -this.SupportUrl.GetDimensions().Width, 1f );
            this.SupportUrl.Left.Set(-this.SupportUrl.GetDimensions().Width * 0.5f, 0.5f);
        }