修訂 | f7ff312b9d09cc026badcecf8d51136d59792847 (tree) |
---|---|
時間 | 2021-08-05 07:04:15 |
作者 | sebastian_bugiu |
Commiter | sebastian_bugiu |
Added AI now prioritize the enemy cargo ships. Added some performance indicators.
@@ -978,7 +978,7 @@ | ||
978 | 978 | } |
979 | 979 | |
980 | 980 | protected void initializeGson() { |
981 | - final GsonBuilder gsonBuilder = new GsonBuilder(); | |
981 | + final GsonBuilder gsonBuilder = new GsonBuilder().setPrettyPrinting(); | |
982 | 982 | gson = gsonBuilder.create(); |
983 | 983 | } |
984 | 984 |
@@ -33,6 +33,8 @@ | ||
33 | 33 | import headwayent.blackholedarksun.net.NetManager; |
34 | 34 | import headwayent.blackholedarksun.net.clientapi.ClientAPI; |
35 | 35 | import headwayent.blackholedarksun.physics.PhysicsUtility; |
36 | +import headwayent.blackholedarksun.statistics.InGameStatistics; | |
37 | +import headwayent.blackholedarksun.statistics.InGameStatisticsManager; | |
36 | 38 | import headwayent.blackholedarksun.systems.*; |
37 | 39 | import headwayent.blackholedarksun.world.WorldManager; |
38 | 40 | import headwayent.blackholedarksun.world.WorldManagerBase; |
@@ -544,6 +546,14 @@ | ||
544 | 546 | hudManager.updateRadarFinalState(); |
545 | 547 | hudManager.unlockRadarData(); |
546 | 548 | |
549 | + renderWindow.updateStats(); | |
550 | + | |
551 | + InGameStatisticsManager statisticsManager = InGameStatisticsManager.getInstance(); | |
552 | + InGameStatistics statistics = statisticsManager.getInGameStatistics(); | |
553 | + statistics.performanceStatistics.averageFps = renderWindow.getAverageFPS(); | |
554 | + statistics.performanceStatistics.maxFps = renderWindow.getBestFPS(); | |
555 | + statistics.performanceStatistics.minFps = renderWindow.getWorstFPS(); | |
556 | + | |
547 | 557 | if (HudManager.SHOW_DEBUGGING_INDICATORS) { |
548 | 558 | hudManager.setFps(renderWindow.getLastFPS()); |
549 | 559 | // System.out.println("LastFPS: " + renderWindow.getLastFPS()); |
@@ -115,6 +115,7 @@ | ||
115 | 115 | public static final String SPHERE_AROUND_POINT_SIGNUM_X = "sphere_around_point_signum_x"; |
116 | 116 | public static final String SPHERE_AROUND_POINT_SIGNUM_Y = "sphere_around_point_signum_y"; |
117 | 117 | public static final String SPHERE_AROUND_POINT_SIGNUM_Z = "sphere_around_point_signum_z"; |
118 | + public static final String CARGO_SHIP_SELECT_CLOSEST = "cargo_ship_select_closest "; | |
118 | 119 | |
119 | 120 | // private HashMap<String, AIEntity> aiEntityMap = new HashMap<>(); |
120 | 121 | // private HashMap<String, TrackerEntity> trackerEntityMap = new HashMap<>(); |
@@ -1,5 +1,6 @@ | ||
1 | 1 | package headwayent.blackholedarksun.systems; |
2 | 2 | |
3 | +import headwayent.blackholedarksun.entitydata.ShipData; | |
3 | 4 | import headwayent.blackholedarksun.entitydata.ShipData.ShipTeam; |
4 | 5 | import headwayent.blackholedarksun.entitydata.WeaponData; |
5 | 6 | import headwayent.blackholedarksun.entitydata.WeaponData.WeaponType; |
@@ -714,20 +715,43 @@ | ||
714 | 715 | // Find smallest distance |
715 | 716 | long closestEnemy = -1; |
716 | 717 | int enemyTeamSize = entities.size(); |
718 | + currentMinLen = Float.MAX_VALUE; | |
717 | 719 | for (int i = 0; i < enemyTeamSize; ++i) { |
718 | 720 | Entity entity = entities.get(i); |
719 | 721 | EntityProperties otherShipEntityProperties = entityPropertiesMapper.get(entity); |
720 | - ShipProperties otherShipShipProperties = shipPropertiesMapper.get(entity); | |
721 | - | |
722 | - otherShipEntityProperties.getNode().getPosition(otherPos); | |
723 | - otherPos.sub(currentPos, distVec); | |
724 | - if (i == 0) { | |
725 | - currentMinLen = distVec.squaredLength(); | |
726 | - closestEnemy = otherShipEntityProperties.getItemId(); | |
727 | - } else { | |
728 | - if (distVec.squaredLength() < currentMinLen) { | |
722 | + ShipProperties otherShipShipProperties = shipPropertiesMapper.getSafe(entity); | |
723 | + if (otherShipShipProperties != null && otherShipShipProperties.getShipData().shipType == ShipData.ShipType.CARGO) { | |
724 | + // Try to prioritize the enemy cargo ship. | |
725 | + if (i == 0) { | |
729 | 726 | currentMinLen = distVec.squaredLength(); |
730 | 727 | closestEnemy = otherShipEntityProperties.getItemId(); |
728 | + } else { | |
729 | + if (distVec.squaredLength() < currentMinLen) { | |
730 | + currentMinLen = distVec.squaredLength(); | |
731 | + closestEnemy = otherShipEntityProperties.getItemId(); | |
732 | + } | |
733 | + } | |
734 | + } | |
735 | + } | |
736 | + if ((closestEnemy == -1) || | |
737 | + (closestEnemy != -1 && | |
738 | + ENG_Utility.getRandom().nextInt(FrameInterval.CARGO_SHIP_SELECT_CLOSEST + entityProperties.getNode().getName(), 3) == 0)) { | |
739 | + for (int i = 0; i < enemyTeamSize; ++i) { | |
740 | + Entity entity = entities.get(i); | |
741 | + EntityProperties otherShipEntityProperties = entityPropertiesMapper.get(entity); | |
742 | +// ShipProperties otherShipShipProperties = shipPropertiesMapper.get(entity); | |
743 | + | |
744 | + otherShipEntityProperties.getNode().getPosition(otherPos); | |
745 | + otherPos.sub(currentPos, distVec); | |
746 | + | |
747 | + if (i == 0) { | |
748 | + currentMinLen = distVec.squaredLength(); | |
749 | + closestEnemy = otherShipEntityProperties.getItemId(); | |
750 | + } else { | |
751 | + if (distVec.squaredLength() < currentMinLen) { | |
752 | + currentMinLen = distVec.squaredLength(); | |
753 | + closestEnemy = otherShipEntityProperties.getItemId(); | |
754 | + } | |
731 | 755 | } |
732 | 756 | } |
733 | 757 | } |
@@ -1102,23 +1102,25 @@ | ||
1102 | 1102 | levelEvent.state = LevelEvent.EventState.LOST; |
1103 | 1103 | } |
1104 | 1104 | |
1105 | - InGameStatistics statistics = InGameStatisticsManager.getInstance().getInGameStatistics(); | |
1106 | - SessionStatistics latestSessionStatistics = statistics.getLatestSessionStatistics(); | |
1107 | - if (latestSessionStatistics != null) { | |
1108 | - LevelStatistics latestLevelStatistics = latestSessionStatistics.getLatestLevelStatistics(); | |
1109 | - if (latestLevelStatistics != null) { | |
1110 | - LevelEventStatistics latestLevelEventStatistics = latestLevelStatistics.getLatestLevelEventStatistics(); | |
1111 | - if (latestLevelEventStatistics != null) { | |
1112 | - latestLevelEventStatistics.state = levelEvent.state.toString(); | |
1113 | - latestLevelEventStatistics.levelEventEndDate = ENG_DateUtils.getCurrentDateTimestamp(); | |
1114 | - latestLevelEventStatistics.levelEventDuration = ENG_Utility.currentTimeMillis() - latestLevelEventStatistics.levelEventBeginTime; | |
1105 | + if (eventWon || eventLost) { | |
1106 | + InGameStatistics statistics = InGameStatisticsManager.getInstance().getInGameStatistics(); | |
1107 | + SessionStatistics latestSessionStatistics = statistics.getLatestSessionStatistics(); | |
1108 | + if (latestSessionStatistics != null) { | |
1109 | + LevelStatistics latestLevelStatistics = latestSessionStatistics.getLatestLevelStatistics(); | |
1110 | + if (latestLevelStatistics != null) { | |
1111 | + LevelEventStatistics latestLevelEventStatistics = latestLevelStatistics.getLatestLevelEventStatistics(); | |
1112 | + if (latestLevelEventStatistics != null) { | |
1113 | + latestLevelEventStatistics.state = levelEvent.state.toString(); | |
1114 | + latestLevelEventStatistics.levelEventEndDate = ENG_DateUtils.getCurrentDateTimestamp(); | |
1115 | + latestLevelEventStatistics.levelEventDuration = ENG_Utility.currentTimeMillis() - latestLevelEventStatistics.levelEventBeginTime; | |
1115 | 1116 | |
1116 | - updateWeaponData(latestLevelEventStatistics, latestLevelEventStatistics.weaponTypeStatisticsEventEndList); | |
1117 | + updateWeaponData(latestLevelEventStatistics, latestLevelEventStatistics.weaponTypeStatisticsEventEndList); | |
1117 | 1118 | |
1118 | - Entity entity = getEntity(playerShipEntityId); | |
1119 | - if (entity != null) { | |
1120 | - EntityProperties entityProperties = entityPropertiesComponentMapper.get(entity); | |
1121 | - latestLevelEventStatistics.healthEventEnd = entityProperties.getHealth(); | |
1119 | + Entity entity = getEntity(playerShipEntityId); | |
1120 | + if (entity != null) { | |
1121 | + EntityProperties entityProperties = entityPropertiesComponentMapper.get(entity); | |
1122 | + latestLevelEventStatistics.healthEventEnd = entityProperties.getHealth(); | |
1123 | + } | |
1122 | 1124 | } |
1123 | 1125 | } |
1124 | 1126 | } |