Bugfixes
This commit is contained in:
@@ -175,6 +175,20 @@ public abstract class Turret extends Block{
|
||||
super.control(type, p1, p2, p3, p4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void control(LAccess type, Object p1, double p2, double p3, double p4){
|
||||
if(type == LAccess.shootp && !unit.isPlayer()){
|
||||
logicControlTime = logicControlCooldown;
|
||||
logicShooting = !Mathf.zero(p2);
|
||||
|
||||
if(p1 instanceof Posc){
|
||||
targetPosition((Posc)p1);
|
||||
}
|
||||
}
|
||||
|
||||
super.control(type, p1, p2, p3, p4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor){
|
||||
return switch(sensor){
|
||||
@@ -199,6 +213,18 @@ public abstract class Turret extends Block{
|
||||
return target != null || (logicControlled() && logicShooting) || (isControlled() && unit.isShooting());
|
||||
}
|
||||
|
||||
public void targetPosition(Posc pos){
|
||||
BulletType bullet = peekAmmo();
|
||||
float speed = bullet.speed;
|
||||
//slow bullets never intersect
|
||||
if(speed < 0.1f) speed = 9999999f;
|
||||
|
||||
targetPos.set(Predict.intercept(this, pos, speed));
|
||||
if(targetPos.isZero()){
|
||||
targetPos.set(target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(baseRegion, x, y);
|
||||
@@ -246,15 +272,7 @@ public abstract class Turret extends Block{
|
||||
}else if(logicControlled()){ //logic behavior
|
||||
canShoot = logicShooting;
|
||||
}else{ //default AI behavior
|
||||
BulletType type = peekAmmo();
|
||||
float speed = type.speed;
|
||||
//slow bullets never intersect
|
||||
if(speed < 0.1f) speed = 9999999f;
|
||||
|
||||
targetPos.set(Predict.intercept(this, target, speed));
|
||||
if(targetPos.isZero()){
|
||||
targetPos.set(target);
|
||||
}
|
||||
targetPosition(target);
|
||||
|
||||
if(Float.isNaN(rotation)){
|
||||
rotation = 0;
|
||||
|
||||
@@ -200,11 +200,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
}
|
||||
}else{ //transfer
|
||||
if(state != stateLoad || (items.total() >= getMaximumAccepted(lastItem))){
|
||||
if(front() != null
|
||||
&& front().team == team
|
||||
&& front().block instanceof StackConveyor){
|
||||
StackConveyorBuild e = (StackConveyorBuild)front();
|
||||
|
||||
if(front() instanceof StackConveyorBuild e && e.team == team){
|
||||
// sleep if its occupied
|
||||
if(e.link == -1){
|
||||
e.items.addAll(items);
|
||||
@@ -227,7 +223,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
if(builds.first() instanceof ConveyorBuild build){
|
||||
Item item = build.items.first();
|
||||
if(item != null){
|
||||
handleStack(item, build.items.get(itemCapacity), null);
|
||||
handleStack(item, build.items.get(item), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@ public abstract class ConsumeLiquidBase extends Consume{
|
||||
}
|
||||
|
||||
protected float use(Building entity){
|
||||
return Math.min(amount * entity.delta(), entity.block.liquidCapacity);
|
||||
return Math.min(amount * entity.edelta(), entity.block.liquidCapacity);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user