Fix crash in rtsai (#6932)

Fixes #6862
This commit is contained in:
buthed010203 2022-06-08 08:26:07 -04:00 committed by GitHub
parent bbb61cd6f0
commit 99eee2e738
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -277,9 +277,9 @@ public class RtsAI{
float extraRadius = 50f;
for(var turret : Vars.indexer.getEnemy(data.team, BlockFlag.turret)){
if(Intersector.distanceSegmentPoint(fromX, fromY, x, y, turret.x, turret.y) <= ((TurretBuild)turret).range() + extraRadius){
health[0] += turret.health;
dps[0] += ((TurretBuild)turret).estimateDps();
if(turret instanceof TurretBuild t && Intersector.distanceSegmentPoint(fromX, fromY, x, y, t.x, t.y) <= t.range() + extraRadius){
health[0] += t.health;
dps[0] += t.estimateDps();
}
}