Skip to content

Commit

Permalink
add SpriteBatch to tile draw parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
blushiemagic committed Jul 31, 2015
1 parent 0f9fdc6 commit 53bf0da
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Terraria.ModLoader/GlobalTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public virtual void ModifyLight(int i, int j, int type, ref float r, ref float g

public virtual void SetSpriteEffects(int i, int j, int type, ref SpriteEffects spriteEffects) { }

public virtual bool PreDraw(int i, int j, int type)
public virtual bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch)
{
return true;
}

public virtual void PostDraw(int i, int j, int type) { }
public virtual void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) { }
}}
4 changes: 2 additions & 2 deletions Terraria.ModLoader/ModTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public virtual void SetSpriteEffects(int i, int j, ref SpriteEffects spriteEffec

public virtual void AnimateTile(ref int frame, ref int frameCounter) { }

public virtual bool PreDraw(int i, int j)
public virtual bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
return true;
}

public virtual void PostDraw(int i, int j) { }
public virtual void PostDraw(int i, int j, SpriteBatch spriteBatch) { }
}}
18 changes: 10 additions & 8 deletions Terraria.ModLoader/TileLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,37 +576,39 @@ internal static void SetAnimationFrame(int type, ref int frameY)
}

//in Terraria.Main.Draw after calling SetAnimationFrame call
// if(!TileLoader.PreDraw(j, i, type)) { TileLoader.PostDraw(j, i, type); continue; }
internal static bool PreDraw(int i, int j, int type)
// if(!TileLoader.PreDraw(j, i, type, Main.spriteBatch))
// { TileLoader.PostDraw(j, i, type, Main.spriteBatch); continue; }
internal static bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch)
{
foreach(Mod mod in ModLoader.mods.Values)
{
if(mod.globalTile != null && !mod.globalTile.PreDraw(i, j, type))
if(mod.globalTile != null && !mod.globalTile.PreDraw(i, j, type, spriteBatch))
{
return false;
}
}
ModTile modTile = GetTile(type);
if(modTile != null && !modTile.PreDraw(i, j))
if(modTile != null && !modTile.PreDraw(i, j, spriteBatch))
{
return false;
}
return true;
}

//in Terraria.Main.Draw after if statement checking whether texture2D is null call TileLoader.PostDraw(j, i, type);
internal static void PostDraw(int i, int j, int type)
//in Terraria.Main.Draw after if statement checking whether texture2D is null call
// TileLoader.PostDraw(j, i, type, Main.spriteBatch);
internal static void PostDraw(int i, int j, int type, SpriteBatch spriteBatch)
{
ModTile modTile = GetTile(type);
if(modTile != null)
{
modTile.PostDraw(i, j);
modTile.PostDraw(i, j, spriteBatch);
}
foreach(Mod mod in ModLoader.mods.Values)
{
if(mod.globalTile != null)
{
mod.globalTile.PostDraw(i, j, type);
mod.globalTile.PostDraw(i, j, type, spriteBatch);
}
}
}
Expand Down

0 comments on commit 53bf0da

Please sign in to comment.