示例#1
0
        ////////////////

        private void AddCustomTooltips(Item item, List <TooltipLine> tooltips)
        {
            ErgophobiaConfig config  = ErgophobiaConfig.Instance;
            string           modName = "[c/FFFF88:" + ErgophobiaMod.Instance.DisplayName + "] - ";

            //

            void addTip(string ctx, string desc)
            {
                TooltipLine tip = new TooltipLine(this.mod, "Ergophobia" + ctx, modName + desc);

                ItemInformationAttributeLibraries.ApplyTooltipAt(tooltips, tip);
            }

            //

            switch (item.type)
            {
            case ItemID.Wood:
                addTip("Wood", "May be used to craft framing planks");
                break;

            case ItemID.WoodPlatform:
                if (config.Get <int>(nameof(config.MaxPlatformBridgeLength)) > 0)
                {
                    addTip("Platform", "Only placeable in short ledges attached to something solid");
                }
                break;

            case ItemID.Rope:
            case ItemID.SilkRope:
            case ItemID.VineRope:
            case ItemID.WebRope:
            case ItemID.Chain:
                addTip("Rope", "Can only be lowered, unless placed against walls");
                break;

            case ItemID.MinecartTrack:
                addTip("Track1", "Can only bridge gaps or be placed downwards");
                addTip("Track2", "May be used to craft track deployment kits");
                break;
            }

            //

            if (item.createTile > -1)
            {
                if (!TileLogic.CanPlace(item.createTile))
                {
                    addTip("Placeable", "This tile is not allowed to be placed");
                }
            }
        }
        public override bool CanPlace(int i, int j, int type)
        {
            if (Main.netMode != NetmodeID.Server && !Main.dedServ)
            {
                // World gen?
                if (Main.gameMenu || !LoadLibraries.IsCurrentPlayerInGame())
                {
                    return(true);
                }
            }

            if (!TileLogic.CanPlace(type))
            {
                return(false);
            }

            switch (type)
            {
            case TileID.Platforms:
                return(TileLogic.CanPlacePlatform(i, j));

            case TileID.Rope:
            case TileID.SilkRope:
            case TileID.VineRope:
            case TileID.WebRope:
                return(TileLogic.CanPlaceRope(i, j));

            case TileID.MinecartTrack:
                return(TileLogic.CanPlaceTrack(i, j));

            default:
                if (type == ModContent.TileType <FramingPlankTile>())
                {
                    return(TileLogic.CanPlaceFramingPlank(i, j));
                }
                return(true);
            }
        }