示例#1
0
        public override void PostDrawInterface(SpriteBatch spriteBatch)
        {
            //MagicalPlayer mpp = Main.player[Main.myPlayer].GetModPlayer<MagicalPlayer>();
            MagicalPlayer mpp = Main.LocalPlayer.GetModPlayer <MagicalPlayer>();

            mpp.Draw(spriteBatch);
        }
示例#2
0
        public override void HandlePacket(BinaryReader reader, int whoAmI)
        {
            PacketMessageType message = (PacketMessageType)reader.ReadByte();
            byte          player      = reader.ReadByte();
            MagicalPlayer modPlayer   = Main.player[player].GetModPlayer <MagicalPlayer>();

            switch (message)
            {
            case PacketMessageType.All:
                modPlayer.EquipShoeSlot.Item  = ItemIO.Receive(reader);
                modPlayer.VanityShoeSlot.Item = ItemIO.Receive(reader);
                modPlayer.ShoeDyeSlot.Item    = ItemIO.Receive(reader);
                if (Main.netMode == NetmodeID.Server)
                {
                    ModPacket packet = GetPacket();
                    packet.Write((byte)PacketMessageType.All);
                    packet.Write(player);
                    ItemIO.Send(modPlayer.EquipShoeSlot.Item, packet);
                    ItemIO.Send(modPlayer.VanityShoeSlot.Item, packet);
                    ItemIO.Send(modPlayer.ShoeDyeSlot.Item, packet);
                    packet.Send(-1, whoAmI);
                }
                break;

            case PacketMessageType.EquipShoeSlot:
                modPlayer.EquipShoeSlot.Item = ItemIO.Receive(reader);
                if (Main.netMode == NetmodeID.Server)
                {
                    modPlayer.SendSingleItemPacket(PacketMessageType.EquipShoeSlot, modPlayer.EquipShoeSlot.Item, -1, whoAmI);
                }
                break;

            case PacketMessageType.VanityShoeSlot:
                modPlayer.VanityShoeSlot.Item = ItemIO.Receive(reader);
                if (Main.netMode == NetmodeID.Server)
                {
                    modPlayer.SendSingleItemPacket(PacketMessageType.VanityShoeSlot, modPlayer.VanityShoeSlot.Item, -1, whoAmI);
                }
                break;

            case PacketMessageType.ShoeDyeSlot:
                modPlayer.ShoeDyeSlot.Item = ItemIO.Receive(reader);
                if (Main.netMode == NetmodeID.Server)
                {
                    modPlayer.SendSingleItemPacket(PacketMessageType.ShoeDyeSlot, modPlayer.ShoeDyeSlot.Item, -1, whoAmI);
                }
                break;

            default:
                Logger.InfoFormat("Magical Things: Unknown message type: ", DisplayName);
                //ErrorLogger.Log("Magical Things: Unknown message type: " + message);
                break;
            }
        }
示例#3
0
        public override void RightClick(Item item, Player player)
        {
            if (!CanRightClick(item))
            {
                return;
            }

            MagicalPlayer mp = player.GetModPlayer <MagicalPlayer>();

            mp.EquipShoes(KeyboardUtils.HeldDown(Keys.LeftShift), item);
        }
示例#4
0
        public override void clientClone(ModPlayer clientClone)
        {
            MagicalPlayer clone = clientClone as MagicalPlayer;

            if (clone == null)
            {
                return;
            }

            clone.EquipShoeSlot.Item  = EquipShoeSlot.Item.Clone();
            clone.VanityShoeSlot.Item = VanityShoeSlot.Item.Clone();
            clone.ShoeDyeSlot.Item    = ShoeDyeSlot.Item.Clone();
        }
示例#5
0
        public override void SendClientChanges(ModPlayer clientPlayer)
        {
            MagicalPlayer oldClone = clientPlayer as MagicalPlayer;

            if (oldClone == null)
            {
                return;
            }

            if (oldClone.EquipShoeSlot.Item.IsNotTheSameAs(EquipShoeSlot.Item))
            {
                SendSingleItemPacket(PacketMessageType.EquipShoeSlot, EquipShoeSlot.Item, -1, player.whoAmI);
            }

            if (oldClone.VanityShoeSlot.Item.IsNotTheSameAs(VanityShoeSlot.Item))
            {
                SendSingleItemPacket(PacketMessageType.VanityShoeSlot, VanityShoeSlot.Item, -1, player.whoAmI);
            }

            if (oldClone.ShoeDyeSlot.Item.IsNotTheSameAs(ShoeDyeSlot.Item))
            {
                SendSingleItemPacket(PacketMessageType.ShoeDyeSlot, ShoeDyeSlot.Item, -1, player.whoAmI);
            }
        }
示例#6
0
        public override object Call(params object[] args)
        {
            try
            {
                string keyword = args[0] as string;

                if (string.IsNullOrEmpty(keyword))
                {
                    return(null);
                }

                switch (keyword)
                {
                case "add":
                case "remove":
                    // shoeSlot.Call(/* "add" or "remove" */, /* func<bool> returns true to cancel/false to continue */);
                    // These two should be called in PostSetupContent
                    Func <bool> func = args[1] as Func <bool>;

                    if (func == null)
                    {
                        return(null);
                    }

                    if (keyword == "add")
                    {
                        RightClickOverrides.Add(func);
                    }
                    else if (keyword == "remove")
                    {
                        RightClickOverrides.Remove(func);
                    }
                    break;

                case "getEquip":
                case "getVanity":
                case "getVisible":
                    /* Can't use these three in PostSetupContent because EquipShoeSlot is a field in MagicalPlayer, but
                     * that's not initialized yet, hence why I couldn't make some sort of delegate as an argument
                     * that assigned it */

                    // Item shoeItem = (Item)shoeSlot.Call(/* "getEquip"/"getVanity"/"getVisible" */, player.whoAmI);
                    // These three should be called on demand
                    int           whoAmI = Convert.ToInt32(args[1]);
                    MagicalPlayer mmp    = Main.player[whoAmI].GetModPlayer <MagicalPlayer>();

                    if (keyword == "getEquip")
                    {
                        return(mmp.EquipShoeSlot.Item);
                    }
                    else if (keyword == "getVanity")
                    {
                        return(mmp.VanityShoeSlot.Item);
                    }
                    // Returns the item that is responsible for the shoes to display on the player (at all times or during flight)
                    else if (keyword == "getVisible")
                    {
                        if (mmp.VanityShoeSlot.Item.shoeSlot > 0)
                        {
                            return(mmp.VanityShoeSlot.Item);
                        }
                        else
                        {
                            return(mmp.EquipShoeSlot.Item);
                        }
                    }
                    break;
                }
            }
            catch
            {
                return(null);
            }
            return(null);

            #region Old
            //string keyword = args[0] as string;
            //Func<bool> func = args[1] as Func<bool>;
            //if (string.IsNullOrEmpty(keyword) || func == null)
            //{
            //    return null;
            //}

            //keyword = keyword.ToLower();
            //if (keyword == "add")
            //{
            //    RightClickOverrides.Add(func);
            //}
            //else if (keyword == "remove")
            //{
            //    RightClickOverrides.Remove(func);
            //}

            //return null;
            #endregion
        }