//////////////// // Server Receivers //////////////// private static void ReceiveInvasionRequestOnServer(BinaryReader reader, int playerWho) { // Server only if (Main.netMode != 2) { return; } int musicType = reader.ReadInt32(); string spawnInfoEnc = reader.ReadString(); var spawnInfo = JsonConvert.DeserializeObject <List <KeyValuePair <int, ISet <int> > > >(spawnInfoEnc); var myworld = ModContent.GetInstance <DynamicInvasionsWorld>(); myworld.Logic.StartInvasion(musicType, spawnInfo.AsReadOnly()); for (int i = 0; i < Main.player.Length; i++) { Player player = Main.player[i]; if (player == null || !player.active) { continue; } ServerPacketHandlers.SendInvasionFromServer(player, musicType, spawnInfoEnc); } }
private static void ReceiveInvasionStatusRequestOnServer(BinaryReader reader, int playerWho) { // Server only if (Main.netMode != 2) { return; } ServerPacketHandlers.SendInvasionStatusFromServer(Main.player[playerWho]); }
public static void RoutePacket(BinaryReader reader, int playerWho) { NetProtocolTypes protocol = (NetProtocolTypes)reader.ReadByte(); switch (protocol) { case NetProtocolTypes.RequestInvasion: if (DynamicInvasionsMod.Config.DebugModeInfo) { LogHelpers.Log("ServerPacketHandlers.RequestInvasion"); } ServerPacketHandlers.ReceiveInvasionRequestOnServer(reader, playerWho); break; case NetProtocolTypes.RequestInvasionStatus: if (DynamicInvasionsMod.Config.DebugModeInfo) { LogHelpers.Log("ServerPacketHandlers.RequestInvasionStatus"); } ServerPacketHandlers.ReceiveInvasionStatusRequestOnServer(reader, playerWho); break; case NetProtocolTypes.RequestEndInvasion: if (DynamicInvasionsMod.Config.DebugModeInfo) { LogHelpers.Log("ServerPacketHandlers.RequestEndInvasion"); } ServerPacketHandlers.ReceiveEndInvasionRequestOnServer(reader, playerWho); break; default: if (DynamicInvasionsMod.Config.DebugModeInfo) { LogHelpers.Log("ServerPacketHandlers ...? " + protocol); } break; } }
private static void ReceiveEndInvasionRequestOnServer(BinaryReader reader, int playerWho) { // Server only if (Main.netMode != 2) { return; } var myworld = ModContent.GetInstance <DynamicInvasionsWorld>(); myworld.Logic.EndInvasion(); for (int i = 0; i < Main.player.Length; i++) { Player player = Main.player[i]; if (player == null || !player.active) { continue; } ServerPacketHandlers.SendEndInvasionFromServer(player); } }