////

        public static float ComputeHitDamage(Tile tile, int baseDamage, int totalHits)
        {
            var    config   = DestructibleTilesConfig.Instance;
            float  dmg      = (float)baseDamage / (float)totalHits;
            float  scale    = 1f;
            string tileName = TileID.GetUniqueKey(tile.type);

            float armor = config.TileArmor.ContainsKey(tileName)
                                ? (float)config.TileArmor[tileName].Amount : 0f;

            if (armor >= dmg)
            {
                return(0);
            }

            if (config.SpecificTileDamageScales.ContainsKey(tileName))
            {
                scale = config.SpecificTileDamageScales[tileName].Amount;
            }

            if (config.UseVanillaTileDamageScalesUnlessOverridden)
            {
                bool isAbsolute;
                scale *= TileHelpers.GetDamageScale(tile, dmg, out isAbsolute);

                if (isAbsolute)
                {
                    return(100f);                       // max
                }
            }

            return((dmg - armor) * scale);
        }
        public static bool IsTileNormallyGrappleable(Tile tile)
        {
            if (!tile.active())
            {
                return(false);
            }
            if (!Main.tileSolid[tile.type] && tile.type != TileID.MinecartTrack)
            {
                return(false);
            }
            if (tile.inActive())                // actuated
            {
                return(false);
            }

            var config = GrappletechConfig.Instance;

            if (config.Get <bool>(nameof(config.GrappleableWoodAndPlatforms)))
            {
                switch (tile.type)
                {
                case TileID.Platforms:
                case TileID.MinecartTrack:
                case TileID.WoodBlock:
                case TileID.BorealWood:
                case TileID.DynastyWood:
                case TileID.LivingWood:
                case TileID.LeafBlock:
                case TileID.PalmWood:
                case TileID.SpookyWood:
                case TileID.LivingMahogany:
                case TileID.RichMahogany:
                case TileID.LivingMahoganyLeaves:
                case TileID.PlanterBox:
                    return(true);
                }
            }

            var    whitelist = config.Get <HashSet <string> >(nameof(config.GrappleableTileWhitelist));
            string tileUid   = TileID.GetUniqueKey(tile.type);

            return(whitelist.Contains(tileUid));
        }
Ejemplo n.º 3
0
        public static bool CanPlace(int type)
        {
            var config = ErgophobiaConfig.Instance;
            var wl     = config.Get <List <string> >(nameof(config.TilePlaceWhitelist));

            if (wl.Contains(TileID.GetUniqueKey(type)))
            {
                return(true);
            }

            if (type == ModContent.TileType <FramingPlankTile>())
            {
                return(config.Get <bool>(nameof(config.IsFramingPlankWhitelisted)));
            }
            if (type == ModContent.TileType <TrackDeploymentTile>())
            {
                return(config.Get <bool>(nameof(config.IsTrackDeploymentWhitelisted)));
            }

            return(false);
        }