public override void clientClone(ModPlayer clientClone) { WingSlotPlayer clone = clientClone as WingSlotPlayer; if (clone != null) { clone.EquipSlot.Item = EquipSlot.Item.Clone(); clone.VanitySlot.Item = VanitySlot.Item.Clone(); clone.DyeSlot.Item = DyeSlot.Item.Clone(); } }
public override void RightClick(Item item, Player player) { if (!CanRightClick(item)) { return; } WingSlotPlayer mp = player.GetModPlayer <WingSlotPlayer>(); mp.EquipWings(KeyboardUtils.HeldDown(Keys.LeftShift), item); }
public override void HandlePacket(BinaryReader reader, int whoAmI) { PacketMessageType message = (PacketMessageType)reader.ReadByte(); byte player = reader.ReadByte(); WingSlotPlayer modPlayer = Main.player[player].GetModPlayer <WingSlotPlayer>(); switch (message) { case PacketMessageType.All: modPlayer.EquipSlot.Item = ItemIO.Receive(reader); modPlayer.VanitySlot.Item = ItemIO.Receive(reader); modPlayer.DyeSlot.Item = ItemIO.Receive(reader); if (Main.netMode == 2) { ModPacket packet = GetPacket(); packet.Write((byte)PacketMessageType.All); packet.Write(player); ItemIO.Send(modPlayer.EquipSlot.Item, packet); ItemIO.Send(modPlayer.VanitySlot.Item, packet); ItemIO.Send(modPlayer.DyeSlot.Item, packet); packet.Send(-1, whoAmI); } break; case PacketMessageType.EquipSlot: modPlayer.EquipSlot.Item = ItemIO.Receive(reader); if (Main.netMode == 2) { modPlayer.SendSingleItemPacket(PacketMessageType.EquipSlot, modPlayer.EquipSlot.Item, -1, whoAmI); } break; case PacketMessageType.VanitySlot: modPlayer.VanitySlot.Item = ItemIO.Receive(reader); if (Main.netMode == 2) { modPlayer.SendSingleItemPacket(PacketMessageType.VanitySlot, modPlayer.VanitySlot.Item, -1, whoAmI); } break; case PacketMessageType.DyeSlot: modPlayer.DyeSlot.Item = ItemIO.Receive(reader); if (Main.netMode == 2) { modPlayer.SendSingleItemPacket(PacketMessageType.DyeSlot, modPlayer.DyeSlot.Item, -1, whoAmI); } break; default: Logger.InfoFormat("[Wing Slot] Unknown message type: {0}", message); break; } }
/// <summary> /// Initialize the ModPlayer. /// </summary> public override void Initialize() { EquipWingSlot = new UIItemSlot(Vector2.Zero, context: Contexts.EquipAccessory, hoverText: "Wings", conditions: Slot_Conditions, drawBackground: Slot_DrawBackground, scaleToInventory: true); VanityWingSlot = new UIItemSlot(Vector2.Zero, context: Contexts.EquipAccessoryVanity, hoverText: Language.GetTextValue("LegacyInterface.11") + " Wings", conditions: Slot_Conditions, drawBackground: Slot_DrawBackground, scaleToInventory: true); WingDyeSlot = new UIItemSlot(Vector2.Zero, context: Contexts.EquipDye, conditions: WingDyeSlot_Conditions, drawBackground: WingDyeSlot_DrawBackground, scaleToInventory: true); VanityWingSlot.Partner = EquipWingSlot; EquipWingSlot.BackOpacity = VanityWingSlot.BackOpacity = WingDyeSlot.BackOpacity = .8f; // Big thanks to thegamemaster1234 for the example code used to write this! wingsDye = new PlayerLayer(UIUtils.Mod.Name, WING_DYE_LAYER, delegate(PlayerDrawInfo drawInfo) { Player player = drawInfo.drawPlayer; WingSlotPlayer wsp = player.GetModPlayer <WingSlotPlayer>(UIUtils.Mod); Item wings = wsp.GetDyedWings(); Item dye = wsp.WingDyeSlot.Item; int index = Main.playerDrawData.Count - 1; if (dye.stack <= 0 || wings.stack <= 0 || !wings.active || wings.noUseGraphic || player.mount.Active || (wsp.VanityWingSlot.Item.stack <= 0 && !wsp.EquipWingSlot.ItemVisible && player.wingFrame == 0)) { return; } if (wings.flame) { index -= 1; } if (index < 0 || index > Main.playerDrawData.Count) { return; } DrawData data = Main.playerDrawData[index]; data.shader = GameShaders.Armor.GetShaderIdFromItemId(dye.type); Main.playerDrawData[index] = data; }); InitializeWings(); }
public override void SendClientChanges(ModPlayer clientPlayer) { WingSlotPlayer oldClone = clientPlayer as WingSlotPlayer; if (oldClone.EquipSlot.Item.IsNotTheSameAs(EquipSlot.Item)) { SendSingleItemPacket(PacketMessageType.EquipSlot, EquipSlot.Item, -1, player.whoAmI); } if (oldClone.VanitySlot.Item.IsNotTheSameAs(VanitySlot.Item)) { SendSingleItemPacket(PacketMessageType.VanitySlot, VanitySlot.Item, -1, player.whoAmI); } if (oldClone.DyeSlot.Item.IsNotTheSameAs(DyeSlot.Item)) { SendSingleItemPacket(PacketMessageType.DyeSlot, DyeSlot.Item, -1, player.whoAmI); } }
public override void RightClick(Item item, Player player) { if (item.wingSlot > 0) { WingSlotPlayer mp = player.GetModPlayer <WingSlotPlayer>(mod); if (KeyboardUtils.HeldDown(Keys.LeftShift)) { mp.EquipWings(true, item); } else { mp.EquipWings(false, item); } } else { base.RightClick(item, player); } }
public override void PostDrawInterface(SpriteBatch spriteBatch) { WingSlotPlayer wsp = Main.player[Main.myPlayer].GetModPlayer <WingSlotPlayer>(this); wsp.Draw(spriteBatch); }
public override object Call(params object[] args) { try { string keyword = args[0] as string; if (string.IsNullOrEmpty(keyword)) { return(null); } keyword = keyword.ToLower(); switch (keyword) { case "add": case "remove": //wingSlot.Call(/* "add" or "remove" */, /* func<bool> returns true to cancel/false to continue normal execution */); //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 "getequipslotitem": case "getvanityslotitem": case "getvisibleitem": //Can't use these three in PostSetupContent because EquipSlot is a field in WingSlotPlayer, but that's not initialized yet //Hence why I couldn't make some sort of delegate as an argument that assigned it //Item wingItem = (Item)wingSlot.Call(/* "getequipslotitem" or "getvanityslotitem" or "getdisplayeditem"*/, player.whoAmI); //These three should be called on demand int whoAmI = Convert.ToInt32(args[1]); WingSlotPlayer wsp = Main.player[whoAmI].GetModPlayer <WingSlotPlayer>(); if (keyword == "getequipslotitem") { return(wsp.EquipSlot.Item); } else if (keyword == "getvanityslotitem") { return(wsp.VanitySlot.Item); } //Returns the item that is responsible for the wings to display on the player (at all times or during flight) else if (keyword == "getvisibleitem") { if (wsp.VanitySlot.Item.wingSlot > 0) { return(wsp.VanitySlot.Item); } else { return(wsp.EquipSlot.Item); } } break; } } catch { return(null); } return(null); }
public override void PostDrawInterface(SpriteBatch spriteBatch) { WingSlotPlayer wsp = Main.LocalPlayer.GetModPlayer <WingSlotPlayer>(); wsp.Draw(spriteBatch); }