示例#1
0
        //in Terraria.WorldGen.KillTile before if statements checking num49 and num50
        //  add bool vanillaDrop = TileLoader.Drop(i, j, tile.type);
        //  add "vanillaDrop && " to beginning of these if statements
        public static bool Drop(int i, int j, int type)
        {
            foreach (var hook in HookDrop)
            {
                if (!hook(i, j, type))
                {
                    return(false);
                }
            }
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                if (!modTile.Drop(i, j))
                {
                    return(false);
                }
                if (modTile.drop > 0)
                {
                    Item.NewItem(i * 16, j * 16, 16, 16, modTile.drop, 1, false, -1);
                }
                return(false);
            }
            return(true);
        }
示例#2
0
        //in Terraria.Map.MapHelper.GetMapTileXnaColor after result is initialized call
        //  TileLoader.MapColor(tile, ref result);
        internal static void MapColor(MapTile mapTile, ref Color color)
        {
            Tile tile = Main.tile[mapTile.x, mapTile.y];

            if (tile.active())
            {
                ModTile modTile = GetTile(tile.type);
                if (modTile != null)
                {
                    Color?modColor = modTile.MapColor(mapTile.x, mapTile.y);
                    if (modColor.HasValue)
                    {
                        color = modColor.Value;
                    }
                }
            }
            else
            {
                ModWall modWall = WallLoader.GetWall(tile.wall);
                if (modWall != null)
                {
                    Color?modColor = modWall.MapColor(mapTile.x, mapTile.y);
                    if (modColor.HasValue)
                    {
                        color = modColor.Value;
                    }
                }
            }
        }
示例#3
0
        //in Terraria.WorldGen.KillTile before if statements checking num49 and num50
        //  add bool vanillaDrop = TileLoader.Drop(i, j, tile.type);
        //  add "vanillaDrop && " to beginning of these if statements
        public static bool Drop(int i, int j, int type)
        {
            foreach (GlobalTile globalTile in globalTiles)
            {
                if (!globalTile.Drop(i, j, type))
                {
                    return(false);
                }
            }
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                if (!modTile.Drop(i, j))
                {
                    return(false);
                }
                if (modTile.drop > 0)
                {
                    Item.NewItem(i * 16, j * 16, 16, 16, modTile.drop, 1, false, -1, false, false);
                }
                return(false);
            }
            return(true);
        }
示例#4
0
        //in Terraria.Player.ItemCheck in if statements for mining
        //  replace num222 += item.hammer; with TileLoader.MineDamage(item.hammer, ref num222);
        //  replace num222 += item.axe; with TileLoader.MineDamage(item.axe, ref num222);
        //in Terraria.Player.PickTile replace num += pickPower; with TileLoader.MineDamage(pickPower, ref num);
        public static void MineDamage(int minePower, ref int damage)
        {
            Tile    target  = Main.tile[Player.tileTargetX, Player.tileTargetY];
            ModTile modTile = GetTile(target.type);

            damage += modTile != null ? (int)(minePower / modTile.mineResist) : minePower;
        }
示例#5
0
        public static int AutoSelect(int i, int j, Player player)
        {
            if (!Main.tile[i, j].active())
            {
                return(-1);
            }
            int     type    = Main.tile[i, j].type;
            ModTile modTile = GetTile(type);

            for (int k = 0; k < 50; k++)
            {
                Item item = player.inventory[k];
                if (item.type == 0 || item.stack == 0)
                {
                    continue;
                }
                if (modTile != null && modTile.AutoSelect(i, j, item))
                {
                    return(k);
                }
                foreach (var hook in HookAutoSelect)
                {
                    if (hook(i, j, type, item))
                    {
                        return(k);
                    }
                }
            }
            return(-1);
        }
示例#6
0
        public static void WalkDust(int type, ref int dustType, ref bool makeDust, ref Color color)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                modTile.WalkDust(ref dustType, ref makeDust, ref color);
            }
        }
示例#7
0
        //in Terraria.Main.Draw after small if statements setting num15 call
        //  TileLoader.SetAnimationFrame(type, ref num15);
        public static void SetAnimationFrame(int type, ref int frameY)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                frameY = modTile.animationFrameHeight * Main.tileFrame[type];
            }
        }
示例#8
0
        public static void KillMultiTile(int i, int j, int frameX, int frameY, int type)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                modTile.KillMultiTile(i, j, frameX, frameY);
            }
        }
示例#9
0
        //in Terraria.Player.ItemCheck at end of else if chain setting num to 0 add
        //  else { TileLoader.PickPowerCheck(tile, pickPower, ref num); }
        public static void PickPowerCheck(Tile target, int pickPower, ref int damage)
        {
            ModTile modTile = GetTile(target.type);

            if (modTile != null && pickPower < modTile.minPick)
            {
                damage = 0;
            }
        }
示例#10
0
        public static string ModDresserName(int type)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                return(modTile.dresser);
            }
            return("");
        }
示例#11
0
        //in Terraria.Main.Draw after small if statements setting num15 call
        //  TileLoader.SetAnimationFrame(type, ref num15);
        /// <summary>
        /// Sets the animation frame. Sets frameYOffset = modTile.animationFrameHeight * Main.tileFrame[type]; and then calls ModTile.AnimateIndividualTile
        /// </summary>
        /// <param name="type">The tile type.</param>
        /// <param name="i">The x position in tile coordinates.</param>
        /// <param name="j">The y position in tile coordinates.</param>
        /// <param name="frameXOffset">The offset to frameX.</param>
        /// <param name="frameYOffset">The offset to frameY.</param>
        public static void SetAnimationFrame(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                frameYOffset = modTile.AnimationFrameHeight * Main.tileFrame[type];
                modTile.AnimateIndividualTile(type, i, j, ref frameXOffset, ref frameYOffset);
            }
        }
示例#12
0
        //in Terraria.Player.CheckSpawn add this to bed type check
        public static bool IsModBed(int type)
        {
            ModTile modTile = GetTile(type);

            if (modTile == null)
            {
                return(false);
            }
            return(modTile.bed);
        }
示例#13
0
        public static bool HasWalkDust(int type)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                return(modTile.HasWalkDust());
            }
            return(false);
        }
示例#14
0
        public static bool IsTorch(int type)
        {
            ModTile modTile = GetTile(type);

            if (modTile == null)
            {
                return(type == TileID.Torches);
            }
            return(modTile.torch);
        }
示例#15
0
        public static bool IsSapling(int type)
        {
            ModTile modTile = GetTile(type);

            if (modTile == null)
            {
                return(type == TileID.Saplings);
            }
            return(modTile.sapling);
        }
示例#16
0
        //replace tile type checks for 19 in Terraria.Player, some places in Terraria.WorldGen,
        //  Terraria.Main.DrawTiles, and Terraria.Collision
        public static bool IsPlatform(int type)
        {
            ModTile modTile = GetTile(type);

            if (modTile == null)
            {
                return(type == TileID.Platforms);
            }
            return(modTile.platform);
        }
示例#17
0
        //in Terraria.UI.ChestUI add this to Lang lookups
        public static string ModChestName(int type)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                return(modTile.chest);
            }
            return("");
        }
示例#18
0
        public int TileType(string name)
        {
            ModTile tile = GetTile(name);

            if (tile == null)
            {
                return(0);
            }
            return((int)tile.Type);
        }
示例#19
0
 public static void DisableSmartCursor(Tile tile, ref bool disable)
 {
     if (tile.active())
     {
         ModTile modTile = GetTile(tile.type);
         if (modTile != null)
         {
             disable = modTile.disableSmartCursor;
         }
     }
 }
示例#20
0
        public void AddTile(string name, ModTile tile, string texture)
        {
            int id = TileLoader.ReserveTileID();

            tile.Name            = name;
            tile.Type            = (ushort)id;
            tiles[name]          = tile;
            TileLoader.tiles[id] = tile;
            tile.texture         = texture;
            tile.mod             = this;
        }
示例#21
0
        public static bool IsClosedDoor(Tile tile)
        {
            ModTile modTile = GetTile(tile.type);

            if (modTile != null)
            {
                return(modTile.OpenDoorID > -1);
            }

            return(tile.type == TileID.ClosedDoor);
        }
示例#22
0
 //in Terraria.ObjectData.TileObject data make the following public:
 //  newTile, newSubTile, newAlternate, addTile, addSubTile, addAlternate
 internal static void SetDefaults(ModTile tile)
 {
     tile.SetDefaults();
     if (Main.tileLavaDeath[tile.Type])
     {
         Main.tileObsidianKill[tile.Type] = true;
     }
     if (Main.tileSolid[tile.Type])
     {
         Main.tileNoSunLight[tile.Type] = true;
     }
 }
示例#23
0
        //in Terraria.WorldGen.KillTile before if statement checking num43 call
        //  TileLoader.DropCritterChance(i, j, tile.type, ref num43, ref num44, ref num45);
        public static void DropCritterChance(int i, int j, int type, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                modTile.DropCritterChance(i, j, ref wormChance, ref grassHopperChance, ref jungleGrubChance);
            }
            foreach (GlobalTile globalTile in globalTiles)
            {
                globalTile.DropCritterChance(i, j, type, ref wormChance, ref grassHopperChance, ref jungleGrubChance);
            }
        }
示例#24
0
        //in Terraria.WorldGen.KillTile before if (!effectOnly && !WorldGen.stopDrops) add
        //  TileLoader.KillTile(i, j, tile.type, ref fail, ref effectOnly, ref noItem);
        public static void KillTile(int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                modTile.KillTile(i, j, ref fail, ref effectOnly, ref noItem);
            }
            foreach (GlobalTile globalTile in globalTiles)
            {
                globalTile.KillTile(i, j, type, ref fail, ref effectOnly, ref noItem);
            }
        }
示例#25
0
        //in Terraria.Lighting.PreRenderPhase add local closer variable and after setting music box
        //  call TileLoader.NearbyEffects(n, num17, type, closer);
        public static void NearbyEffects(int i, int j, int type, bool closer)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                modTile.NearbyEffects(i, j, closer);
            }
            foreach (GlobalTile globalTile in globalTiles)
            {
                globalTile.NearbyEffects(i, j, type, closer);
            }
        }
示例#26
0
        //in Terraria.Main.DrawTiles after if statement setting effects call
        //  TileLoader.SetSpriteEffects(j, i, type, ref effects);
        public static void SetSpriteEffects(int i, int j, int type, ref SpriteEffects spriteEffects)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                modTile.SetSpriteEffects(i, j, ref spriteEffects);
            }
            foreach (GlobalTile globalTile in globalTiles)
            {
                globalTile.SetSpriteEffects(i, j, type, ref spriteEffects);
            }
        }
示例#27
0
        //in Terraria.Main.Draw after if statement checking whether texture2D is null call
        //  TileLoader.PostDraw(j, i, type, Main.spriteBatch);
        public static void PostDraw(int i, int j, int type, SpriteBatch spriteBatch)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                modTile.PostDraw(i, j, spriteBatch);
            }
            foreach (GlobalTile globalTile in globalTiles)
            {
                globalTile.PostDraw(i, j, type, spriteBatch);
            }
        }
示例#28
0
        //in Terraria.Wiring make the following public:
        //  _wireList, _toProcess, _teleport, _inPumpX, _inPumpY, _numInPump, _outPumpX, _outPumpY, _numOutPump CheckMech, TripWire
        //at end of Terraria.Wiring.HitWireSingle inside if statement checking for tile active add
        //  TileLoader.HitWire(i, j, type);
        public static void HitWire(int i, int j, int type)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                modTile.HitWire(i, j);
            }
            foreach (GlobalTile globalTile in globalTiles)
            {
                globalTile.HitWire(i, j, type);
            }
        }
示例#29
0
        private void AutoloadTile(Type type)
        {
            ModTile tile = (ModTile)Activator.CreateInstance(type);

            tile.mod = this;
            string name    = type.Name;
            string texture = (type.Namespace + "." + type.Name).Replace('.', '/');

            if (tile.Autoload(ref name, ref texture))
            {
                AddTile(name, tile, texture);
            }
        }
示例#30
0
        //in Terraria.WorldGen.KillTile before num14 (num dust iteration) is declared, add
        //  TileLoader.NumDust(i, j, tile.type, ref num13);
        public static void NumDust(int i, int j, int type, bool fail, ref int numDust)
        {
            ModTile modTile = GetTile(type);

            if (modTile != null)
            {
                modTile.NumDust(i, j, fail, ref numDust);
            }
            foreach (GlobalTile globalTile in globalTiles)
            {
                globalTile.NumDust(i, j, type, fail, ref numDust);
            }
        }
示例#31
0
文件: Mod.cs 项目: popovn/tModLoader
 public void AddTile(string name, ModTile tile, string texture)
 {
     int id = TileLoader.ReserveTileID();
     tile.Name = name;
     tile.Type = (ushort)id;
     tiles[name] = tile;
     TileLoader.tiles[id] = tile;
     tile.texture = texture;
     tile.mod = this;
 }
示例#32
0
		public void AddTile(ModTile tile)
		{
			this.AddTile(tile.Type);
		}