@@ -265,7 +265,7 @@ public enum UnitType {
265265 * @return The maximum width of all unit types, in pixels.
266266 */
267267 public static int maxUnitWidth () {
268- return Arrays . stream ( UnitType . values ()). max ( Comparator . comparingInt ( UnitType :: width )). get (). width () ;
268+ return UnitTypeContainer . maxUnitWidth ;
269269 }
270270
271271 /**
@@ -275,7 +275,7 @@ public static int maxUnitWidth() {
275275 * @return The maximum height of all unit types, in pixels.
276276 */
277277 public static int maxUnitHeight () {
278- return Arrays . stream ( UnitType . values ()). max ( Comparator . comparingInt ( UnitType :: height )). get (). height () ;
278+ return UnitTypeContainer . maxUnitHeight ;
279279 }
280280
281281 /**
@@ -298,17 +298,7 @@ public Race getRace() {
298298 * Returns pair({@link UnitType#None},0) If this unit type cannot be made by the player.
299299 */
300300 public Pair <UnitType , Integer > whatBuilds () {
301- // Retrieve the type
302- final UnitType type = UnitTypeContainer .whatBuilds [id ];
303- int count = 1 ;
304- // Set count to 0 if there is no whatBuilds and 2 if it's an archon
305- if (type == UnitType .None ) {
306- count = 0 ;
307- } else if (this == UnitType .Protoss_Archon || this == UnitType .Protoss_Dark_Archon ) {
308- count = 2 ;
309- }
310- // Return the desired pair
311- return new Pair <>(type , count );
301+ return UnitTypeContainer .whatBuildsPairs [id ];
312302 }
313303
314304 /**
@@ -365,7 +355,7 @@ public TechType cloakingTech() {
365355 * @return List of TechTypes containing ability information.
366356 */
367357 public List <TechType > abilities () {
368- return Collections . unmodifiableList ( Arrays . asList ( UnitTypeContainer .unitTechs [id ])) ;
358+ return UnitTypeContainer .unitTechsLists [id ];
369359 }
370360
371361 /**
@@ -374,7 +364,7 @@ public List<TechType> abilities() {
374364 * @return List of UpgradeTypes containing upgrade types that will impact this unit type.
375365 */
376366 public List <UpgradeType > upgrades () {
377- return Collections . unmodifiableList ( Arrays . asList ( UnitTypeContainer .upgrades [id ])) ;
367+ return UnitTypeContainer .upgradesLists [id ];
378368 }
379369
380370 /**
@@ -578,7 +568,7 @@ public int tileHeight() {
578568 * @return {@link TilePosition} containing the width (x) and height (y) of the unit type, in tiles.
579569 */
580570 public TilePosition tileSize () {
581- return new TilePosition ( tileWidth (), tileHeight ()) ;
571+ return UnitTypeContainer . tileSizes [ id ] ;
582572 }
583573
584574 /**
@@ -1194,7 +1184,7 @@ public boolean canBuildAddon() {
11941184 * @since 4.1.2
11951185 */
11961186 public List <UnitType > buildsWhat () {
1197- return Collections . unmodifiableList ( Arrays . asList ( UnitTypeContainer .buildsWhat [id ])) ;
1187+ return UnitTypeContainer .buildsWhatLists [id ];
11981188 }
11991189
12001190 /**
@@ -1209,7 +1199,7 @@ public List<UnitType> buildsWhat() {
12091199 * @since 4.1.2
12101200 */
12111201 public List <TechType > researchesWhat () {
1212- return Collections . unmodifiableList ( Arrays . asList ( UnitTypeContainer .researchesWhat [id ])) ;
1202+ return UnitTypeContainer .researchesWhatLists [id ];
12131203 }
12141204
12151205 /**
@@ -1223,7 +1213,7 @@ public List<TechType> researchesWhat() {
12231213 * @since 4.1.2
12241214 */
12251215 public List <UpgradeType > upgradesWhat () {
1226- return Collections . unmodifiableList ( Arrays . asList ( UnitTypeContainer .upgradesWhat [id ])) ;
1216+ return UnitTypeContainer .upgradesWhatLists [id ];
12271217 }
12281218
12291219 /**
0 commit comments