public static ItemPair ReadItemPair(this BinaryReader reader) { ItemPair pair = QSWorld.baseItemPair.Clone(); pair.Frequency = reader.ReadFrequency(); pair.Handler.Read(reader); return(pair); }
internal static void ReceiveItemFrequency(BinaryReader reader, int whoAmI) { Frequency frequency = reader.ReadFrequency(); ItemPair handler = QSWorld.baseItemPair.Clone(); handler.Frequency = frequency; ModContent.GetInstance <QSWorld>().QEItemHandlers.Add(handler); if (Main.netMode == NetmodeID.Server) { SendItemFrequency(frequency, whoAmI); } }
internal static void ReceiveItem(BinaryReader reader, int whoAmI) { Frequency frequency = reader.ReadFrequency(); int slot = reader.ReadInt32(); Item item = reader.ReadItem(true); ItemPair pair = ModContent.GetInstance <QSWorld>().QEItemHandlers.FirstOrDefault(itemPair => Equals(itemPair.Frequency, frequency)); pair?.Handler.SetItemInSlot(slot, item); if (Main.netMode == NetmodeID.Server) { SendItem(frequency, slot, whoAmI); } }
public QSWorld() { baseItemPair = new ItemPair { Handler = new ItemHandler(27) }; baseItemPair.OnContentsChanged += (frequency, slot) => Net.SendItem(frequency, slot); baseFluidPair = new FluidPair { Handler = new FluidHandler() }; baseFluidPair.OnContentsChanged += (frequency, slot) => Net.SendFluid(frequency, slot); baseFluidPair.Handler.GetSlotLimit += slot => 255 * 4; QEItemHandlers = new List <ItemPair>(); QEFluidHandlers = new List <FluidPair>(); }
public override void Initialize() { Instance = this; baseItemPair = new ItemPair { Handler = new ItemHandler(27) }; baseItemPair.OnContentsChanged += (frequency, slot) => Net.SendItem(frequency, slot); baseFluidPair = new FluidPair { Handler = new FluidHandler() }; baseFluidPair.OnContentsChanged += (frequency, slot) => Net.SendFluid(frequency, slot); baseFluidPair.Handler.GetSlotLimit += slot => 255 * 4; QEItemHandlers = new List <ItemPair>(); QEFluidHandlers = new List <FluidPair>(); }
public static void Write(this BinaryWriter writer, ItemPair pair) { writer.Write(pair.Frequency); pair.Handler.Write(writer); }