Esempio n. 1
0
        public static ItemPair ReadItemPair(this BinaryReader reader)
        {
            ItemPair pair = QSWorld.baseItemPair.Clone();

            pair.Frequency = reader.ReadFrequency();
            pair.Handler.Read(reader);
            return(pair);
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
        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>();
        }
Esempio n. 5
0
        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>();
        }
Esempio n. 6
0
 public static void Write(this BinaryWriter writer, ItemPair pair)
 {
     writer.Write(pair.Frequency);
     pair.Handler.Write(writer);
 }