Esempio n. 1
0
 public void SendAmmoShaderPacket()
 {
     if (Main.netMode == NetmodeID.MultiplayerClient)
     {
         ModPacket pak = GetPacket();
         pak.Write((byte)PacketType.AMMO);
         ShaderID.Write(pak, ammoShaders[Main.myPlayer]);
         pak.Send();
     }
 }
Esempio n. 2
0
 public void SendNPCShaderPacket(NPC npc, CustomizerNPCInfo npcInfo)
 {
     if (Main.netMode == NetmodeID.MultiplayerClient)
     {
         ModPacket pak = GetPacket();
         pak.Write((byte)PacketType.NPC);
         ShaderID.Write(pak, new ShaderID(npcInfo.shaderID));
         pak.Write(npc.whoAmI);
         pak.Send();
     }
 }
Esempio n. 3
0
        public override void HandlePacket(BinaryReader reader, int whoAmI)
        {
            var type = (PacketType)reader.ReadByte();

            if (Main.netMode == NetmodeID.Server)
            {
                ModPacket pak = GetPacket();
                pak.Write((byte)type);
                ShaderID.Write(pak, ShaderID.Read(reader));
                if (type == PacketType.NPC)
                {
                    pak.Write(reader.ReadInt32());
                }
                else if (type == PacketType.PROJ)
                {
                    pak.Write(reader.ReadInt32());
                    pak.Write(reader.ReadByte());
                }
                else
                {
                    pak.Write(whoAmI);
                }
                pak.Send(ignoreClient: whoAmI);
            }
            else
            {
                ShaderID shader = ShaderID.Read(reader);
                switch (type)
                {
                case PacketType.AMMO:
                    ammoShaders[reader.ReadInt32()] = shader;
                    break;

                case PacketType.NPC:
                    Main.npc[reader.ReadInt32()].Customizer().shaderID = shader.ID;
                    break;

                case PacketType.PROJ:
                    // read in reverse order because why ???
                    // none of this actually works anyway
                    // if GlobalItem had a net sync function that'd be great
                    int  identity = reader.ReadInt32();
                    byte owner    = reader.ReadByte();
                    //int idx = Projectile.GetByUUID(owner, identity);
                    int num84 = 1000;
                    for (int num85 = 0; num85 < 1000; num85++)
                    {
                        if (Main.projectile[num85].owner == owner && Main.projectile[num85].identity == identity && Main.projectile[num85].active)
                        {
                            num84 = num85;
                            break;
                        }
                    }

                    if (num84 == 1000)
                    {
                        for (int num86 = 0; num86 < 1000; num86++)
                        {
                            if (!Main.projectile[num86].active)
                            {
                                num84 = num86;
                                break;
                            }
                        }
                    }
                    Main.NewText("Received projectile packet: " + owner + " " + identity + " " + num84 + " " + shader.ID);
                    if (num84 != -1 && num84 != Main.maxProjectiles)
                    {
                        var proj = Main.projectile[num84];
                        //if(proj.Customizer() is CustomizerProjInfo customizer)
                        //customizer.shaderID = shader.ID;
                        proj.Customizer().shaderID = shader.ID;
                    }
                    else
                    {
                        Main.NewText("Invalid projectile identity");
                    }
                    break;
                }
            }
        }
Esempio n. 4
0
 //Stops items from losing their noice data when dropped in multiplayer
 public override void NetSend(Item item, BinaryWriter writer)
 {
     writer.Write(itemName);
     ShaderID.Write(writer, shaderID);
 }