mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-25 22:58:47 +07:00
Bugfixes
This commit is contained in:
parent
605a370679
commit
702ba0ae84
@ -496,7 +496,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
}
|
||||
|
||||
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)){
|
||||
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 fract = liquids.get(liquid) / block.liquidCapacity * block.liquidPressure;
|
||||
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)){
|
||||
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
|
||||
public void remove(){
|
||||
if(sound != null){
|
||||
|
@ -3,4 +3,5 @@ package mindustry.logic;
|
||||
/** An object that can be controlled with logic. */
|
||||
public interface Controllable{
|
||||
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
|
||||
enabled("to"), //"to" is standard for single parameter access
|
||||
shoot("x", "y", "shoot"),
|
||||
shootp(true, "unit", "shoot")
|
||||
|
||||
;
|
||||
|
||||
public final String[] parameters;
|
||||
public final boolean isObj;
|
||||
|
||||
public static final LAccess[]
|
||||
all = values(),
|
||||
@ -42,5 +44,11 @@ public enum LAccess{
|
||||
|
||||
LAccess(String... 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);
|
||||
if(obj instanceof Controllable){
|
||||
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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user