Exemple #1
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;
                    }
                }
            }
        }
Exemple #2
0
        public int WallType(string name)
        {
            ModWall wall = GetWall(name);

            if (wall == null)
            {
                return(0);
            }
            return((int)wall.Type);
        }
Exemple #3
0
 //in Terraria.Main.Update after vanilla wall animations call WallLoader.AnimateWalls();
 public static void AnimateWalls()
 {
     if (loaded)
     {
         for (int i = 0; i < walls.Count; i++)
         {
             ModWall modWall = walls[i];
             modWall.AnimateWall(ref Main.wallFrame[modWall.Type], ref Main.wallFrameCounter[modWall.Type]);
         }
     }
 }
Exemple #4
0
        public void AddWall(string name, ModWall wall, string texture)
        {
            int id = WallLoader.ReserveWallID();

            wall.Name            = name;
            wall.Type            = (ushort)id;
            walls[name]          = wall;
            WallLoader.walls[id] = wall;
            wall.texture         = texture;
            wall.mod             = this;
        }
Exemple #5
0
        //in Terraria.WorldGen.KillWall after if statement setting num to 3 add
        //  WallLoader.NumDust(i, j, tile.wall, fail, ref num);
        internal static void NumDust(int i, int j, int type, bool fail, ref int numDust)
        {
            ModWall modWall = GetWall(type);

            if (modWall != null)
            {
                modWall.NumDust(i, j, fail, ref numDust);
            }
            foreach (GlobalWall globalWall in globalWalls)
            {
                globalWall.NumDust(i, j, type, fail, ref numDust);
            }
        }
Exemple #6
0
        //in Terraria.WorldGen.KillWall after if statements setting fail to true call
        //  WallLoader.KillWall(i, j, tile.wall, ref fail);
        internal static void KillWall(int i, int j, int type, ref bool fail)
        {
            ModWall modWall = GetWall(type);

            if (modWall != null)
            {
                modWall.KillWall(i, j, ref fail);
            }
            foreach (GlobalWall globalWall in globalWalls)
            {
                globalWall.KillWall(i, j, type, ref fail);
            }
        }
Exemple #7
0
        private void AutoloadWall(Type type)
        {
            ModWall wall = (ModWall)Activator.CreateInstance(type);

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

            if (wall.Autoload(ref name, ref texture))
            {
                AddWall(name, wall, texture);
            }
        }
Exemple #8
0
        //in Terraria.Lighting.PreRenderPhase after wall modifies light call
        //  WallLoader.ModifyLight(n, num17, wall, ref num18, ref num19, ref num20);
        internal static void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b)
        {
            ModWall modWall = GetWall(type);

            if (modWall != null)
            {
                modWall.ModifyLight(i, j, ref r, ref g, ref b);
            }
            foreach (GlobalWall globalWall in globalWalls)
            {
                globalWall.ModifyLight(i, j, type, ref r, ref g, ref b);
            }
        }
Exemple #9
0
        //in Terraria.WorldGen.UpdateWorld after each call to TileLoader.RandomUpdate call
        //  WallLoader.RandomUpdate(num7, num8, Main.tile[num7, num8].wall);
        //  WallLoader.RandomUpdate(num64, num65, Main.tile[num64, num65].wall);
        internal static void RandomUpdate(int i, int j, int type)
        {
            ModWall modWall = GetWall(type);

            if (modWall != null)
            {
                modWall.RandomUpdate(i, j);
            }
            foreach (GlobalWall globalWall in globalWalls)
            {
                globalWall.RandomUpdate(i, j, type);
            }
        }
Exemple #10
0
        //in Terraria.Main.DrawWalls after wall outlines are drawn call
        //  WallLoader.PostDraw(j, i, wall, Main.spriteBatch);
        internal static void PostDraw(int i, int j, int type, SpriteBatch spriteBatch)
        {
            ModWall modWall = GetWall(type);

            if (modWall != null)
            {
                modWall.PostDraw(i, j, spriteBatch);
            }
            foreach (GlobalWall globalWall in globalWalls)
            {
                globalWall.PostDraw(i, j, type, spriteBatch);
            }
        }
Exemple #11
0
        //in Terraria.WorldGen.KillWall replace if (num4 > 0) with
        //  if (WallLoader.Drop(i, j, tile.wall, ref num4) && num4 > 0)
        internal static bool Drop(int i, int j, int type, ref int dropType)
        {
            foreach (GlobalWall globalWall in globalWalls)
            {
                if (!globalWall.Drop(i, j, type, ref dropType))
                {
                    return(false);
                }
            }
            ModWall modWall = GetWall(type);

            if (modWall != null)
            {
                return(modWall.Drop(i, j, ref dropType));
            }
            return(true);
        }
        //in Terraria.WorldGen.KillWall before if statements creating dust add
        //  if(!WallLoader.CreateDust(i, j, tile.wall, ref int num2)) { continue; }
        public static bool CreateDust(int i, int j, int type, ref int dustType)
        {
            foreach (GlobalWall globalWall in globalWalls)
            {
                if (!globalWall.CreateDust(i, j, type, ref dustType))
                {
                    return(false);
                }
            }
            ModWall modWall = GetWall(type);

            if (modWall != null)
            {
                return(modWall.CreateDust(i, j, ref dustType));
            }
            return(true);
        }
Exemple #13
0
        //in Terraria.Main.DrawWalls before if statements that do the drawing add
        //  if(!WallLoader.PreDraw(j, i, wall, Main.spriteBatch))
        //  { WallLoader.PostDraw(j, i, wall, Main.spriteBatch); continue; }
        internal static bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch)
        {
            foreach (GlobalWall globalWall in globalWalls)
            {
                if (!globalWall.PreDraw(i, j, type, spriteBatch))
                {
                    return(false);
                }
            }
            ModWall modWall = GetWall(type);

            if (modWall != null)
            {
                return(modWall.PreDraw(i, j, spriteBatch));
            }
            return(true);
        }
Exemple #14
0
        //in Terraria.WorldGen.KillWall add if(!WallLoader.KillSound(i, j, tile.wall)) { } to beginning of
        //  if/else chain for playing sounds, and turn first if into else if
        public static bool KillSound(int i, int j, int type)
        {
            foreach (var hook in HookKillSound)
            {
                if (!hook(i, j, type))
                {
                    return(false);
                }
            }
            ModWall modWall = GetWall(type);

            if (modWall != null)
            {
                if (!modWall.KillSound(i, j))
                {
                    return(false);
                }
                Main.PlaySound(modWall.soundType, i * 16, j * 16, modWall.soundStyle);
                return(false);
            }
            return(true);
        }
Exemple #15
0
        //in Terraria.WorldGen.KillWall add if(!WallLoader.KillSound(i, j, tile.wall)) { } to beginning of
        //  if/else chain for playing sounds, and turn first if into else if
        internal static bool KillSound(int i, int j, int type)
        {
            foreach (GlobalWall globalWall in globalWalls)
            {
                if (!globalWall.KillSound(i, j, type))
                {
                    return(false);
                }
            }
            ModWall modWall = GetWall(type);

            if (modWall != null)
            {
                if (!modWall.KillSound(i, j))
                {
                    return(false);
                }
                Main.PlaySound(modWall.soundType, i * 16, j * 16, modWall.soundStyle);
                return(false);
            }
            return(true);
        }
Exemple #16
0
 //at end of Terraria.Map.MapHelper.CreateMapTile before returning call
 //  MapLoader.ModMapOption(ref num16, i, j);
 internal static void ModMapOption(ref ushort mapType, int i, int j)
 {
     if (entryToTile.ContainsKey(mapType))
     {
         ModTile tile   = TileLoader.GetTile(entryToTile[mapType]);
         ushort  option = tile.GetMapOption(i, j);
         if (option < 0 || option >= modTileOptions(tile.Type))
         {
             throw new ArgumentOutOfRangeException("Bad map option for tile " + tile.Name + " from mod " + tile.mod.Name);
         }
         mapType += option;
     }
     else if (entryToWall.ContainsKey(mapType))
     {
         ModWall wall   = WallLoader.GetWall(entryToWall[mapType]);
         ushort  option = wall.GetMapOption(i, j);
         if (option < 0 || option >= modWallOptions(wall.Type))
         {
             throw new ArgumentOutOfRangeException("Bad map option for wall " + wall.Name + " from mod " + wall.mod.Name);
         }
         mapType += option;
     }
 }
Exemple #17
0
 public void AddWall(string name, ModWall wall, string texture)
 {
     int id = WallLoader.ReserveWallID();
     wall.Name = name;
     wall.Type = (ushort)id;
     walls[name] = wall;
     WallLoader.walls[id] = wall;
     wall.texture = texture;
     wall.mod = this;
 }