Misc cleanup & target/hit movements

This commit is contained in:
Anuken
2022-05-03 20:39:54 -04:00
parent 8b9eb0b466
commit 7640fa0bf0
8 changed files with 20 additions and 30 deletions

View File

@@ -129,7 +129,7 @@ public class Units{
(range != Float.MAX_VALUE && !target.within(x, y, range + (target instanceof Sized hb ? hb.hitSize()/2f : 0f))) ||
(target instanceof Teamc t && t.team() == team) ||
(target instanceof Healthc h && !h.isValid()) ||
(target instanceof Unit u && !u.targetable());
(target instanceof Unit u && !u.targetable(team));
}
/** See {@link #invalidateTarget(Posc, Team, float, float, float)} */
@@ -274,7 +274,7 @@ public class Units{
cpriority = -99999f;
nearbyEnemies(team, x - range, y - range, range*2f, range*2f, e -> {
if(e.dead() || !predicate.get(e) || e.team == Team.derelict || !e.targetable()) return;
if(e.dead() || !predicate.get(e) || e.team == Team.derelict || !e.targetable(team)) return;
float dst2 = e.dst2(x, y) - (e.hitSize * e.hitSize);
if(dst2 < range*range && (result == null || dst2 < cdist || e.type.targetPriority > cpriority) && e.type.targetPriority >= cpriority){
@@ -296,7 +296,7 @@ public class Units{
cpriority = -99999f;
nearbyEnemies(team, x - range, y - range, range*2f, range*2f, e -> {
if(e.dead() || !predicate.get(e) || e.team == Team.derelict || !e.within(x, y, range + e.hitSize/2f) || !e.targetable()) return;
if(e.dead() || !predicate.get(e) || e.team == Team.derelict || !e.within(x, y, range + e.hitSize/2f) || !e.targetable(team)) return;
float cost = sort.cost(e, x, y);
if((result == null || cost < cdist || e.type.targetPriority > cpriority) && e.type.targetPriority >= cpriority){

View File

@@ -61,18 +61,6 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc, Unitc{
}
}
@Override
@Replace
public boolean targetable(){
return type.targetable || (type.vulnerableWithPayloads && hasPayload());
}
@Override
@Replace
public boolean hittable(){
return type.hittable || (type.vulnerableWithPayloads && hasPayload());
}
float payloadUsed(){
return payloads.sumf(p -> p.size() * p.size());
}

View File

@@ -355,12 +355,12 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
}
}
public boolean targetable(){
return type.targetable;
public boolean targetable(Team targeter){
return type.targetable(self(), targeter);
}
public boolean hittable(){
return type.hittable;
return type.hittable(self());
}
@Override