Example #1
0
 public override void PostItemCheck()
 {
     NetExclude(NetmodeID.Server, () => {
         if (player.HeldItem != null && !player.HeldItem.IsAir && player.HeldItem.Customizer() is CustomizerItem && (player.HeldItem.Customizer().shaderID.ID > 0 || (CustomizerMod.mod.ammoShaders[player.whoAmI] != null && CustomizerMod.mod.ammoShaders[player.whoAmI].ID > 0)))
         {
             foreach (Projectile proj in CustomizerProjectile.newProjectiles)
             {
                 CustomizerProjInfo shotInfo = proj.Customizer();
                 if (shotInfo.shaderID > 0)
                 {
                     continue;                                               //If this SOMEHOW has a shader already, don't bother
                 }
                 //Yes, there's a specific thing for the Vortex Beater. It's the only ammo-using weapon I know that displays as a projectile.
                 if (player.HeldItem.useAmmo == AmmoID.None || proj.type == ProjectileID.VortexBeater)
                 {
                     shotInfo.UpdateShaderID(proj, player.HeldItem.Customizer().shaderID.ID);
                 }
                 else
                 {
                     shotInfo.UpdateShaderID(proj, CustomizerMod.mod.ammoShaders[player.whoAmI].ID);
                 }
             }
             CustomizerProjectile.newProjectiles = new List <Projectile>();
         }
     });
 }
Example #2
0
 public void SendProjShaderPacket(Projectile projectile, CustomizerProjInfo projInfo)
 {
     /*if(Main.netMode == NetmodeID.MultiplayerClient) {
      *      ModPacket pak = GetPacket();
      *      pak.Write((byte)PacketType.PROJ);
      *      ShaderID.Write(pak, new ShaderID(projInfo.shaderID));
      *      pak.Write(projectile.owner);
      *      pak.Write(projectile.identity);
      *      pak.Send();
      * }*/
 }
        public void ShadeDusts(Projectile projectile)
        {
            CustomizerProjInfo info = projectile.GetGlobalProjectile <CustomizerProjInfo>();

            if (info.shaderID > 0)
            {
                foreach (int dust in newDusts)
                {
                    Main.dust[dust].shader = GameShaders.Armor.GetSecondaryShader(info.shaderID, Main.player[projectile.owner]);
                }

                newDusts = new List <int>();
            }
        }
        public void ShadeChildren(Projectile projectile)
        {
            CustomizerProjInfo info = projectile.GetGlobalProjectile <CustomizerProjInfo>();

            if (info.shaderID > 0)
            {
                foreach (Projectile proj in childProjectiles)
                {
                    CustomizerProjInfo childInfo = proj.GetGlobalProjectile <CustomizerProjInfo>();

                    var player = Main.player[projectile.owner];
                    childInfo.UpdateShaderID(projectile, projectile.type == ProjectileID.VortexBeater && !player.HeldItem.IsAir ? CustomizerMod.mod.ammoShaders[projectile.owner].ID : info.shaderID);
                    childInfo.parent = false;
                }

                childProjectiles = new List <Projectile>();
            }
        }
Example #5
0
        private void Proj_Update(On.Terraria.Projectile.orig_Update orig, Projectile self, int i)
        {
            CustomizerProjectile.newDusts = new List <int>();

            orig(self, i);

            if (self.active)
            {
                CustomizerProjInfo info = self.GetGlobalProjectile <CustomizerProjInfo>();

                if (info.shaderID > 0)
                {
                    foreach (int dust in CustomizerProjectile.newDusts)
                    {
                        Main.dust[dust].shader = GameShaders.Armor.GetSecondaryShader(info.shaderID, Main.player[self.owner]);
                    }
                }
            }
            CustomizerProjectile.newDusts = new List <int>();
        }
        public override bool PreAI(Projectile projectile)
        {
            NetExclude(NetmodeID.Server, () => {
                CustomizerProjInfo projInfo = projectile.GetGlobalProjectile <CustomizerProjInfo>();

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

                //Apply shader of the player's held item provided it meets all this criteria to make absolute certain a player fired it
                //As of 1.1.3 this now only applies to OTHER PLAYER's projectiles! Until I can get the better system working with multiplayer, that is.
                if (projInfo.parent && !(hook || pet || lightPet) && !projectile.npcProj && !projectile.trap && projectile.owner != 255 && projectile.owner != Main.myPlayer && Main.player[projectile.owner].itemAnimation > 0 && ((projectile.friendly || !projectile.hostile) || projectile.minion) && projInfo.shaderID < 0)
                {
                    //Main.NewText("Ammo shader for projectile: " + CustomizerMod.mod.ammoShaders[projectile.owner]);
                    var player = Main.player[projectile.owner];
                    if (!player.HeldItem.IsAir)
                    {
                        if (player.HeldItem.useAmmo == AmmoID.None || projectile.type == ProjectileID.VortexBeater)
                        {
                            projInfo.shaderID = player.HeldItem.Customizer().shaderID.ID;
                        }
                        else
                        {
                            projInfo.shaderID = CustomizerMod.mod.ammoShaders[projectile.owner].ID;
                        }
                    }
                }
                else if (projInfo.shaderID < 0)
                {
                    projInfo.shaderID = 0;
                }

                childProjectiles = new List <Projectile>();
                //newDusts = new List<int>();
            });
            return(true);
        }