📄 hmpfile.java
字号:
} // left arm criticals for (int x = 0; x < 12; x++) { laCriticals[x] = readUnsignedInt(dis); } // left torso criticals for (int x = 0; x < 12; x++) { ltCriticals[x] = readUnsignedInt(dis); } // left leg criticals for (int x = 0; x < 12; x++) { llCriticals[x] = readUnsignedInt(dis); } // right arm criticals for (int x = 0; x < 12; x++) { raCriticals[x] = readUnsignedInt(dis); } // right torso criticals for (int x = 0; x < 12; x++) { rtCriticals[x] = readUnsignedInt(dis); } // right leg criticals for (int x = 0; x < 12; x++) { rlCriticals[x] = readUnsignedInt(dis); } // head criticals for (int x = 0; x < 12; x++) { headCriticals[x] = readUnsignedInt(dis); } // center torso criticals for (int x = 0; x < 12; x++) { ctCriticals[x] = readUnsignedInt(dis); } dis.skipBytes(4); int fluffSize = 0; fluff = "Overview:\n\r"; buffer = new byte[readUnsignedShort(dis)]; dis.read(buffer); fluff += new String(buffer); fluffSize += new String(buffer).length(); fluff += "\n\rCapability:\n\r"; buffer = new byte[readUnsignedShort(dis)]; dis.read(buffer); fluff += new String(buffer); fluffSize += new String(buffer).length(); fluff += "\n\rBattle History:\n\r"; buffer = new byte[readUnsignedShort(dis)]; dis.read(buffer); fluff += new String(buffer); fluffSize += new String(buffer).length(); fluff += "\n\rVariants:\n\r"; buffer = new byte[readUnsignedShort(dis)]; dis.read(buffer); fluff += new String(buffer); fluffSize += new String(buffer).length(); fluff += "\n\rFamous Mechs and Warriors:\n\r"; buffer = new byte[readUnsignedShort(dis)]; dis.read(buffer); fluff += new String(buffer); fluffSize += new String(buffer).length(); fluff += "\n\rDeployment:\n\r"; buffer = new byte[readUnsignedShort(dis)]; dis.read(buffer); fluff += new String(buffer); fluffSize += new String(buffer).length(); // just a catch all for small Fluffs anything well less then 10 // characters, per section, isn't worth printing. if (fluffSize <= 60) fluff = null; // non printing notes dis.skipBytes(readUnsignedShort(dis)); dis.skipBytes(readUnsignedShort(dis)); dis.skipBytes(8); // mechs with supercharger have an 01 in here, // but we can identify from the criticals // Get cockpit and gyro type, if any. if (rulesLevel > 2) { gyroType = readUnsignedShort(dis); cockpitType = readUnsignedShort(dis); dis.skipBytes(16); targSys = readUnsignedShort(dis); } else { gyroType = Mech.GYRO_STANDARD; cockpitType = Mech.COCKPIT_STANDARD; } dis.close(); } catch (IOException ex) { ex.printStackTrace(); /* OMIT_FOR_JHMPREAD_COMPILATION BLOCK_BEGIN */ throw new EntityLoadingException("I/O Error reading file"); /* BLOCK_END */ } } private short readUnsignedByte(DataInputStream dis) throws IOException { short b = dis.readByte(); b += b < 0 ? 256 : 0; return b; } private int readUnsignedShort(DataInputStream dis) throws IOException { int b2 = readUnsignedByte(dis); int b1 = readUnsignedByte(dis); b1 <<= 8; return b1 + b2; } private long readUnsignedInt(DataInputStream dis) throws IOException { long b4 = readUnsignedByte(dis); long b3 = readUnsignedByte(dis); b3 <<= 8; long b2 = readUnsignedByte(dis); b2 <<= 16; long b1 = readUnsignedByte(dis); b1 <<= 32; return b1 + b2 + b3 + b4; } /* OMIT_FOR_JHMPREAD_COMPILATION BLOCK_BEGIN */ public Entity getEntity() throws EntityLoadingException { try { Mech mech = null; if(chassisType == ChassisType.QUADRAPED_OMNI ||chassisType == ChassisType.QUADRAPED) { mech = new QuadMech(gyroType, cockpitType); } else if (chassisType == ChassisType.ARMLESS) { mech = new ArmlessMech(gyroType, cockpitType); } else { mech = new BipedMech(gyroType, cockpitType); } mech.setChassis(name); mech.setModel(model); mech.setYear(year); mech.setFluff(fluff); mech.setOmni(chassisType == ChassisType.BIPED_OMNI || chassisType == ChassisType.QUADRAPED_OMNI); if (techType == TechType.INNER_SPHERE) { switch (rulesLevel) { case 1: mech.setTechLevel(TechConstants.T_IS_LEVEL_1); break; case 2: mech.setTechLevel(TechConstants.T_IS_LEVEL_2); break; case 3: mech.setTechLevel(TechConstants.T_IS_LEVEL_3); break; default: throw new EntityLoadingException("Unsupported tech level: " + rulesLevel); } } else if (techType == TechType.CLAN) { switch (rulesLevel) { case 2: mech.setTechLevel(TechConstants.T_CLAN_LEVEL_2); break; case 3: mech.setTechLevel(TechConstants.T_CLAN_LEVEL_3); break; default: throw new EntityLoadingException("Unsupported tech level: " + rulesLevel); } } else if (techType == TechType.MIXED && mixedBaseTechType == TechType.INNER_SPHERE) { mech.setTechLevel(TechConstants.T_IS_LEVEL_3); mech.setMixedTech(true); } else if (techType == TechType.MIXED && mixedBaseTechType == TechType.CLAN) { mech.setTechLevel(TechConstants.T_CLAN_LEVEL_3); mech.setMixedTech(true); } else { throw new EntityLoadingException("Unsupported tech base: " + techType); } mech.setWeight(tonnage); int engineFlags = 0; if (techType == TechType.CLAN || engineTechType == TechType.CLAN) engineFlags = Engine.CLAN_ENGINE; mech.setEngine(new Engine(engineRating, Engine .getEngineTypeByString(engineType.toString()) ,engineFlags)); mech.setOriginalJumpMP(jumpMP); mech.setStructureType(internalStructureType.toString()); mech.autoSetInternal(); mech.setArmorType(armorType.toString()); mech.initializeArmor(laArmor, Mech.LOC_LARM); mech.initializeArmor(ltArmor, Mech.LOC_LT); mech.initializeRearArmor(ltrArmor, Mech.LOC_LT); mech.initializeArmor(llArmor, Mech.LOC_LLEG); mech.initializeArmor(raArmor, Mech.LOC_RARM); mech.initializeArmor(rtArmor, Mech.LOC_RT); mech.initializeRearArmor(rtrArmor, Mech.LOC_RT); mech.initializeArmor(rlArmor, Mech.LOC_RLEG); mech.initializeArmor(headArmor, Mech.LOC_HEAD); mech.initializeArmor(ctArmor, Mech.LOC_CT); mech.initializeRearArmor(ctrArmor, Mech.LOC_CT); setupCriticals(mech); if (mech.isClan()) { mech.addClanCase(); } if (rulesLevel > 2) { mech.setTargSysType(getTargSys()); } // add any heat sinks not allocated mech.addEngineSinks(heatSinks - mech.heatSinks(), heatSinkType == HeatSinkType.DOUBLE); return mech; } catch (Exception e) { e.printStackTrace(); throw new EntityLoadingException(e.getMessage()); } } private void removeArmActuators(Mech mech, long[] criticals, int location) { // Quad have leg and foot actuators, not arm and hand actuators. if (mech.getMovementMode() == IEntityMovementMode.QUAD) { if (!isLowerLegActuator(criticals[2])) { mech.setCritical(location, 2, null); } if (!isFootActuator(criticals[3])) { mech.setCritical(location, 3, null); } } else { if (!isLowerArmActuator(criticals[2])) { mech.setCritical(location, 2, null); } if (!isHandActuator(criticals[3])) { mech.setCritical(location, 3, null); } } } private void setupCriticals(Mech mech) throws EntityLoadingException { removeArmActuators(mech, laCriticals, Mech.LOC_LARM); removeArmActuators(mech, raCriticals, Mech.LOC_RARM); compactCriticals(rlCriticals); setupCriticals(mech, rlCriticals, Mech.LOC_RLEG); compactCriticals(llCriticals); setupCriticals(mech, llCriticals, Mech.LOC_LLEG); if(chassisType != ChassisType.ARMLESS) { //HMP helpfully includes arm actuators in armless mechs compactCriticals(raCriticals); setupCriticals(mech, raCriticals, Mech.LOC_RARM); compactCriticals(laCriticals);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -