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

@@ -1284,7 +1284,7 @@ public class Blocks{
}};
carbideCrucible = new HeatCrafter("carbide-crucible"){{
requirements(Category.crafting, with(Items.tungsten, 90, Items.thorium, 70, Items.oxide, 50));
requirements(Category.crafting, with(Items.tungsten, 110, Items.thorium, 70, Items.oxide, 60));
craftEffect = Fx.none;
outputItem = new ItemStack(Items.carbide, 1);
craftTime = 60f * 3f;
@@ -2585,9 +2585,9 @@ public class Blocks{
//TODO awful name
largePlasmaBore = new BeamDrill("large-plasma-bore"){{
//TODO requirements
requirements(Category.production, with(Items.silicon, 100, Items.oxide, 30, Items.beryllium, 100, Items.tungsten, 70));
requirements(Category.production, with(Items.silicon, 100, Items.oxide, 25, Items.beryllium, 100, Items.tungsten, 70));
consumePower(0.8f);
drillTime = 120f;
drillTime = 110f;
tier = 5;
size = 3;
range = 6;
@@ -2596,7 +2596,7 @@ public class Blocks{
itemCapacity = 20;
consumeLiquid(Liquids.hydrogen, 0.5f / 60f);
consumeLiquid(Liquids.nitrogen, 4f / 60f).boost();
consumeLiquid(Liquids.nitrogen, 3f / 60f).boost();
}};
//TODO should be crusher or something
@@ -3757,7 +3757,7 @@ public class Blocks{
requirements(Category.turret, with(Items.beryllium, 150, Items.silicon, 200, Items.graphite, 200, Items.tungsten, 50));
ammo(
Items.graphite, new BasicBulletType(8f, 40){{
Items.graphite, new BasicBulletType(8f, 44){{
knockback = 4f;
width = 25f;
hitSize = 7f;

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

View File

@@ -776,7 +776,7 @@ public class LExecutor{
void find(Ranged b, float range, int sortDir, Team team){
Units.nearby(team, b.x(), b.y(), range, u -> {
if(!u.within(b, range) || !u.targetable()) return;
if(!u.within(b, range) || !u.targetable(team)) return;
boolean valid =
target1.func.get(b.team(), u) &&

View File

@@ -452,6 +452,14 @@ public class UnitType extends UnlockableContent{
return weapons.size > 0;
}
public boolean targetable(Unit unit, Team targeter){
return targetable || (vulnerableWithPayloads && unit instanceof Payloadc p && p.hasPayload());
}
public boolean hittable(Unit unit){
return hittable || (vulnerableWithPayloads && unit instanceof Payloadc p && p.hasPayload());
}
public void update(Unit unit){
}

View File

@@ -22,7 +22,6 @@ public class LiquidModule extends BlockModule{
private float[] liquids = new float[content.liquids().size];
private Liquid current = content.liquid(0);
private float total;
private @Nullable WindowedMean[] flow;
@@ -86,7 +85,6 @@ public class LiquidModule extends BlockModule{
public void reset(Liquid liquid, float amount){
Arrays.fill(liquids, 0f);
liquids[liquid.id] = amount;
total = amount;
current = liquid;
}
@@ -99,13 +97,11 @@ public class LiquidModule extends BlockModule{
}
public void clear(){
total = 0;
Arrays.fill(liquids, 0);
}
public void add(Liquid liquid, float amount){
liquids[liquid.id] += amount;
total += amount;
current = liquid;
if(flow != null){
@@ -162,7 +158,6 @@ public class LiquidModule extends BlockModule{
@Override
public void read(Reads read, boolean legacy){
Arrays.fill(liquids, 0);
total = 0f;
int count = legacy ? read.ub() : read.s();
for(int j = 0; j < count; j++){
@@ -173,7 +168,6 @@ public class LiquidModule extends BlockModule{
if(amount > 0){
current = liq;
}
this.total += amount;
}
}