public override bool IsTransferable(ACommand c) { GetArmorsAnswerCommand command = c as GetArmorsAnswerCommand; if (command != null) { ArmorV1_0[] armors = new ArmorV1_0[command.ARMORS.Length]; for (int i = 0; i < armors.Length; i++) { armors[i] = new ArmorV1_0(command.ARMORS[i]); } cache.Cached(command, new GetArmorsAnswerCommandV10(armors)); return(true); } return(false); }
/// <summary> /// Get equipment from server. /// </summary> private static void LoadEquip(NetworkStream sns) { lock (MOTORS_BY_ID) { if (MOTORS_BY_ID.Count == 0) { sns.SendCommandAsync(new GetMotorsCommand()).Wait(); GetMotorsAnswerCommand motorAnswer = (GetMotorsAnswerCommand)checkCommand(sns.ReceiveCommand()); sns.SendCommandAsync(new GetArmorsCommand()).Wait(); GetArmorsAnswerCommand armorsAnswer = (GetArmorsAnswerCommand)checkCommand(sns.ReceiveCommand()); sns.SendCommandAsync(new GetGunsCommand()).Wait(); GetGunsAnswerCommand gunAnswer = (GetGunsAnswerCommand)checkCommand(sns.ReceiveCommand()); sns.SendCommandAsync(new GetRepairToolsCommand()).Wait(); GetRepairToolsAnswerCommand repairToolsAnswer = (GetRepairToolsAnswerCommand)checkCommand(sns.ReceiveCommand()); sns.SendCommandAsync(new GetMineGunsCommand()).Wait(); GetMineGunsAnswerCommand mineGunsAnswer = (GetMineGunsAnswerCommand)checkCommand(sns.ReceiveCommand()); foreach (Motor motor in motorAnswer.MOTORS) { MOTORS_BY_ID.Add(motor.ID, motor); } foreach (Armor armor in armorsAnswer.ARMORS) { ARMORS_BY_ID.Add(armor.ID, armor); } foreach (Gun gun in gunAnswer.GUNS) { GUNS_BY_ID.Add(gun.ID, gun); } foreach (RepairTool repairTool in repairToolsAnswer.REPAIR_TOOLS) { REPAIR_TOOLS_BY_ID.Add(repairTool.ID, repairTool); } foreach (MineGun mineGun in mineGunsAnswer.MINE_GUNS) { MINE_GUNS_BY_ID.Add(mineGun.ID, mineGun); } } } }