public static FluidPair ReadFluidPair(this BinaryReader reader) { FluidPair pair = QSWorld.baseFluidPair.Clone(); pair.Frequency = reader.ReadFrequency(); pair.Handler.Read(reader); return(pair); }
internal static void ReceiveFluidFrequency(BinaryReader reader, int whoAmI) { Frequency frequency = reader.ReadFrequency(); FluidPair handler = QSWorld.baseFluidPair.Clone(); handler.Frequency = frequency; ModContent.GetInstance <QSWorld>().QEFluidHandlers.Add(handler); if (Main.netMode == NetmodeID.Server) { SendFluidFrequency(frequency, whoAmI); } }
internal static void ReceiveFluid(BinaryReader reader, int whoAmI) { Frequency frequency = reader.ReadFrequency(); int slot = reader.ReadInt32(); ModFluid fluid = reader.ReadFluid(); FluidPair pair = ModContent.GetInstance <QSWorld>().QEFluidHandlers.FirstOrDefault(fluidPair => Equals(fluidPair.Frequency, frequency)); pair?.Handler.SetFluidInSlot(slot, fluid); if (Main.netMode == NetmodeID.Server) { SendFluid(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, FluidPair pair) { writer.Write(pair.Frequency); pair.Handler.Write(writer); }