Bugfixes
This commit is contained in:
@@ -496,7 +496,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void transferLiquid(Building next, float amount, Liquid liquid){
|
public void transferLiquid(Building next, float amount, Liquid liquid){
|
||||||
float flow = Math.min(next.block.liquidCapacity - next.liquids.get(liquid) - 0.001f, amount);
|
float flow = Math.min(next.block.liquidCapacity - next.liquids.get(liquid), amount);
|
||||||
|
|
||||||
if(next.acceptLiquid(self(), liquid, flow)){
|
if(next.acceptLiquid(self(), liquid, flow)){
|
||||||
next.handleLiquid(self(), liquid, flow);
|
next.handleLiquid(self(), liquid, flow);
|
||||||
@@ -528,7 +528,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
float ofract = next.liquids.get(liquid) / next.block.liquidCapacity;
|
float ofract = next.liquids.get(liquid) / next.block.liquidCapacity;
|
||||||
float fract = liquids.get(liquid) / block.liquidCapacity * block.liquidPressure;
|
float fract = liquids.get(liquid) / block.liquidCapacity * block.liquidPressure;
|
||||||
float flow = Math.min(Mathf.clamp((fract - ofract) * (1f)) * (block.liquidCapacity), liquids.get(liquid));
|
float flow = Math.min(Mathf.clamp((fract - ofract) * (1f)) * (block.liquidCapacity), liquids.get(liquid));
|
||||||
flow = Math.min(flow, next.block.liquidCapacity - next.liquids.get(liquid) - 0.001f);
|
flow = Math.min(flow, next.block.liquidCapacity - next.liquids.get(liquid));
|
||||||
|
|
||||||
if(flow > 0f && ofract <= fract && next.acceptLiquid(self(), liquid, flow)){
|
if(flow > 0f && ofract <= fract && next.acceptLiquid(self(), liquid, flow)){
|
||||||
next.handleLiquid(self(), liquid, flow);
|
next.handleLiquid(self(), liquid, flow);
|
||||||
@@ -1266,6 +1266,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void control(LAccess type, Object p1, double p2, double p3, double p4){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove(){
|
public void remove(){
|
||||||
if(sound != null){
|
if(sound != null){
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ package mindustry.logic;
|
|||||||
/** An object that can be controlled with logic. */
|
/** An object that can be controlled with logic. */
|
||||||
public interface Controllable{
|
public interface Controllable{
|
||||||
void control(LAccess type, double p1, double p2, double p3, double p4);
|
void control(LAccess type, double p1, double p2, double p3, double p4);
|
||||||
|
void control(LAccess type, Object p1, double p2, double p3, double p4);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,12 @@ public enum LAccess{
|
|||||||
//values with parameters are considered controllable
|
//values with parameters are considered controllable
|
||||||
enabled("to"), //"to" is standard for single parameter access
|
enabled("to"), //"to" is standard for single parameter access
|
||||||
shoot("x", "y", "shoot"),
|
shoot("x", "y", "shoot"),
|
||||||
|
shootp(true, "unit", "shoot")
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
public final String[] parameters;
|
public final String[] parameters;
|
||||||
|
public final boolean isObj;
|
||||||
|
|
||||||
public static final LAccess[]
|
public static final LAccess[]
|
||||||
all = values(),
|
all = values(),
|
||||||
@@ -42,5 +44,11 @@ public enum LAccess{
|
|||||||
|
|
||||||
LAccess(String... parameters){
|
LAccess(String... parameters){
|
||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
|
isObj = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LAccess(boolean obj, String... parameters){
|
||||||
|
this.parameters = parameters;
|
||||||
|
isObj = obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,11 @@ public class LExecutor{
|
|||||||
Object obj = exec.obj(target);
|
Object obj = exec.obj(target);
|
||||||
if(obj instanceof Controllable){
|
if(obj instanceof Controllable){
|
||||||
Controllable cont = (Controllable)obj;
|
Controllable cont = (Controllable)obj;
|
||||||
cont.control(type, exec.num(p1), exec.num(p2), exec.num(p3), exec.num(p4));
|
if(type.isObj){
|
||||||
|
cont.control(type, exec.obj(p1), exec.num(p2), exec.num(p3), exec.num(p4));
|
||||||
|
}else{
|
||||||
|
cont.control(type, exec.num(p1), exec.num(p2), exec.num(p3), exec.num(p4));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,6 +175,20 @@ public abstract class Turret extends Block{
|
|||||||
super.control(type, p1, p2, p3, p4);
|
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
|
@Override
|
||||||
public double sense(LAccess sensor){
|
public double sense(LAccess sensor){
|
||||||
return switch(sensor){
|
return switch(sensor){
|
||||||
@@ -199,6 +213,18 @@ public abstract class Turret extends Block{
|
|||||||
return target != null || (logicControlled() && logicShooting) || (isControlled() && unit.isShooting());
|
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
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
Draw.rect(baseRegion, x, y);
|
Draw.rect(baseRegion, x, y);
|
||||||
@@ -246,15 +272,7 @@ public abstract class Turret extends Block{
|
|||||||
}else if(logicControlled()){ //logic behavior
|
}else if(logicControlled()){ //logic behavior
|
||||||
canShoot = logicShooting;
|
canShoot = logicShooting;
|
||||||
}else{ //default AI behavior
|
}else{ //default AI behavior
|
||||||
BulletType type = peekAmmo();
|
targetPosition(target);
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(Float.isNaN(rotation)){
|
if(Float.isNaN(rotation)){
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
|
|||||||
@@ -200,11 +200,7 @@ public class StackConveyor extends Block implements Autotiler{
|
|||||||
}
|
}
|
||||||
}else{ //transfer
|
}else{ //transfer
|
||||||
if(state != stateLoad || (items.total() >= getMaximumAccepted(lastItem))){
|
if(state != stateLoad || (items.total() >= getMaximumAccepted(lastItem))){
|
||||||
if(front() != null
|
if(front() instanceof StackConveyorBuild e && e.team == team){
|
||||||
&& front().team == team
|
|
||||||
&& front().block instanceof StackConveyor){
|
|
||||||
StackConveyorBuild e = (StackConveyorBuild)front();
|
|
||||||
|
|
||||||
// sleep if its occupied
|
// sleep if its occupied
|
||||||
if(e.link == -1){
|
if(e.link == -1){
|
||||||
e.items.addAll(items);
|
e.items.addAll(items);
|
||||||
@@ -227,7 +223,7 @@ public class StackConveyor extends Block implements Autotiler{
|
|||||||
if(builds.first() instanceof ConveyorBuild build){
|
if(builds.first() instanceof ConveyorBuild build){
|
||||||
Item item = build.items.first();
|
Item item = build.items.first();
|
||||||
if(item != null){
|
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){
|
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