Skip to content

Commit

Permalink
massive overhaul thing
Browse files Browse the repository at this point in the history
  • Loading branch information
gamrguy committed Apr 22, 2018
1 parent 4e4b3fd commit 99923c3
Show file tree
Hide file tree
Showing 21 changed files with 873 additions and 4,753 deletions.
46 changes: 46 additions & 0 deletions BaseHooks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.Graphics.Shaders;
using Terraria.ModLoader;
using Terraria.ID;
using ShaderLib.Dyes;

namespace ShaderLib
{
public class BaseHooks : GlobalShader
{
// Pet/grapple dye fix
public override int ProjectileShader(Projectile projectile, SpriteBatch spriteBatch, Color lightColor) {
if(Main.player[projectile.owner] == null) return 0;

int shaderID = 0;
bool hook, pet, lightPet;
hook = Main.projHook[projectile.type];
pet = Main.projPet[projectile.type] && !projectile.minion && projectile.damage == 0 && !ProjectileID.Sets.LightPet[projectile.type];
pet = pet || (projectile.type == ProjectileID.StardustGuardian);
lightPet = !projectile.minion && projectile.damage == 0 && ProjectileID.Sets.LightPet[projectile.type];

if(hook || pet || lightPet) {
Player owner = Main.player[projectile.owner];

//Return the proper shader; if it's 0, return the current shader ID (do nothing)
if(hook) shaderID = owner.cGrapple != 0 ? owner.cGrapple : shaderID;
else if(pet) shaderID = owner.cPet != 0 ? owner.cPet : shaderID;
else if(lightPet) shaderID = owner.cLight != 0 ? owner.cLight : shaderID;
}

return shaderID;
}

// Enable armor shaders on familiar wig
public override void PlayerShader(ref PlayerShaderData data, PlayerDrawInfo drawInfo) {
Player player = drawInfo.drawPlayer;
if(player.head == 0 && player.dye[0] != null) {
Item dye = drawInfo.drawPlayer.dye[0];
if(dye.modItem != null && dye.modItem as IDye != null) data.hairShader = (dye.modItem as IDye).DyeID;
else data.hairShader = GameShaders.Armor.GetShaderIdFromItemId(drawInfo.drawPlayer.dye[0].type);
}
}
}
}
8 changes: 8 additions & 0 deletions Dyes/IDye.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

namespace ShaderLib.Dyes
{
public interface IDye
{
int DyeID { get; }
}
}
Loading

0 comments on commit 99923c3

Please sign in to comment.