public static void Begin(int player)
 {
     if (instance == null && !Main.dedServ)
     {
         instance = new WorldReaverData(player);
         Overlays.Scene.Activate("Bluemagic:WorldReaver");
         Filters.Scene.Activate("Bluemagic:WorldReaver");
     }
 }
 public static void Update()
 {
     if (instance != null && !Main.dedServ)
     {
         instance.UpdateInstance();
         if (instance.timer >= 300)
         {
             Main.PlaySound(SoundID.Item107);
             Overlays.Scene.Deactivate("Bluemagic:WorldReaver");
             Filters.Scene.Deactivate("Bluemagic:WorldReaver");
             Filters.Scene["Bluemagic:WorldReaver"].Opacity = 0f;
             instance = null;
         }
     }
 }
 public override void PostUpdate()
 {
     Bluemagic.UpdatePureColor();
     WorldReaver.UpdateGlitchText();
     WorldReaverData.Update();
     if (Main.eclipse)
     {
         eclipsePassed = true;
     }
     if (Main.pumpkinMoon && NPC.waveNumber >= 15)
     {
         pumpkinMoonPassed = true;
     }
     if (Main.snowMoon && NPC.waveNumber >= 15)
     {
         snowMoonPassed = true;
     }
     BlushieBoss.BlushieBoss.Update();
 }
        public override void HandlePacket(BinaryReader reader, int whoAmI)
        {
            MessageType type = (MessageType)reader.ReadByte();

            if (type == MessageType.PuritySpirit)
            {
                PuritySpirit.PuritySpirit spirit = Main.npc[reader.ReadInt32()].modNPC as PuritySpirit.PuritySpirit;
                if (spirit != null && spirit.npc.active)
                {
                    spirit.HandlePacket(reader);
                }
            }
            else if (type == MessageType.HeroLives)
            {
                Player player = Main.player[reader.ReadInt32()];
                int    lives  = reader.ReadInt32();
                player.GetModPlayer <BluemagicPlayer>().heroLives = lives;
                if (lives > 0)
                {
                    NetworkText text;
                    if (lives == 1)
                    {
                        text = NetworkText.FromKey("Mods.Bluemagic.LifeLeft", player.name);
                    }
                    else
                    {
                        text = NetworkText.FromKey("Mods.Bluemagic.LivesLeft", player.name, lives);
                    }
                    NetMessage.BroadcastChatMessage(text, new Color(255, 25, 25));
                }
            }
            else if (type == MessageType.ChaosSpirit)
            {
                NPC npc = Main.npc[reader.ReadInt32()];
                if (npc.active)
                {
                    ChaosSpirit.ChaosSpirit spirit = npc.modNPC as ChaosSpirit.ChaosSpirit;
                    if (spirit != null)
                    {
                        spirit.HandlePacket(reader);
                    }
                    ChaosSpirit2 spirit2 = npc.modNPC as ChaosSpirit2;
                    if (spirit2 != null)
                    {
                        spirit2.HandlePacket(reader);
                    }
                    ChaosSpirit3 spirit3 = npc.modNPC as ChaosSpirit3;
                    if (spirit3 != null)
                    {
                        spirit3.HandlePacket(reader);
                    }
                }
            }
            else if (type == MessageType.PushChaosArm)
            {
                NPC     npc  = Main.npc[reader.ReadInt32()];
                Vector2 push = new Vector2(reader.ReadSingle(), reader.ReadSingle());
                if (npc.active)
                {
                    ChaosSpiritArm arm = npc.modNPC as ChaosSpiritArm;
                    if (arm != null)
                    {
                        arm.offset += push;
                        if (Main.netMode == 2)
                        {
                            ModPacket packet = GetPacket();
                            packet.Write((byte)MessageType.PushChaosArm);
                            packet.Write(push.X);
                            packet.Write(push.Y);
                            packet.Send(-1, whoAmI);
                        }
                    }
                }
            }
            else if (type == MessageType.TerraSpirit)
            {
                NPC npc = Main.npc[reader.ReadInt32()];
                if (npc.active)
                {
                    TerraSpirit.TerraSpirit spirit = npc.modNPC as TerraSpirit.TerraSpirit;
                    if (spirit != null)
                    {
                        spirit.HandlePacket(reader);
                    }
                }
            }
            else if (type == MessageType.TerraLives)
            {
                Player player = Main.player[reader.ReadInt32()];
                int    lives  = reader.ReadInt32();
                player.GetModPlayer <BluemagicPlayer>().terraLives = lives;
                if (lives > 0)
                {
                    NetworkText text;
                    if (lives == 1)
                    {
                        text = NetworkText.FromKey("Mods.Bluemagic.LifeLeft", player.name);
                    }
                    else
                    {
                        text = NetworkText.FromKey("Mods.Bluemagic.LivesLeft", player.name, lives);
                    }
                    NetMessage.BroadcastChatMessage(text, new Color(255, 25, 25));
                }
            }
            else if (type == MessageType.GoldBlob)
            {
                NPC   npc   = Main.npc[reader.ReadByte()];
                float value = reader.ReadByte();
                if (npc.active && npc.type == NPCType("GoldBlob"))
                {
                    npc.localAI[0] = value;
                }
            }
            else if (type == MessageType.ExtraLives)
            {
                BluemagicPlayer player = Main.player[Main.myPlayer].GetModPlayer <BluemagicPlayer>();
                if (player.terraLives > 0)
                {
                    player.terraLives += 3;
                }
            }
            else if (type == MessageType.BulletNegative)
            {
                NPC npc = Main.npc[reader.ReadByte()];
                if (npc.active && npc.type == NPCType("TerraSpirit2") && npc.modNPC is TerraSpirit2)
                {
                    var bullets = ((TerraSpirit2)npc.modNPC).bullets;
                    int count   = reader.ReadByte();
                    for (int k = 0; k < count; k++)
                    {
                        bullets.Add(new BulletNegative(reader.ReadVector2(), reader.ReadVector2()));
                    }
                }
            }
            else if (type == MessageType.CustomStats)
            {
                byte            byte1     = reader.ReadByte();
                byte            byte2     = reader.ReadByte();
                Player          player    = Main.player[byte1];
                BluemagicPlayer modPlayer = player.GetModPlayer <BluemagicPlayer>();
                CustomStats     stats     = byte2 == 0 ? modPlayer.chaosStats : modPlayer.cataclysmStats;
                stats.NetReceive(reader);
                if (Main.netMode == 2)
                {
                    ModPacket packet = GetPacket(512);
                    packet.Write(byte1);
                    packet.Write(byte2);
                    stats.NetSend(packet);
                    packet.Send(-1, whoAmI);
                }
            }
            else if (type == MessageType.WorldReaver)
            {
                WorldReaverData.Begin(reader.ReadInt32());
            }
        }