Internal refactoring & cleanup
This commit is contained in:
@@ -17,7 +17,7 @@ import mindustry.world.blocks.production.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class PayloadConveyor extends Block{
|
||||
public float moveTime = 50f;
|
||||
public float moveTime = 40f, moveForce = 201f;
|
||||
public @Load("@-top") TextureRegion topRegion;
|
||||
public @Load("@-edge") TextureRegion edgeRegion;
|
||||
public Interp interp = Interp.pow5;
|
||||
@@ -53,6 +53,7 @@ public class PayloadConveyor extends Block{
|
||||
public class PayloadConveyorBuild extends Building{
|
||||
public @Nullable Payload item;
|
||||
public float progress, itemRotation, animation;
|
||||
public float curInterp, lastInterp;
|
||||
public @Nullable Building next;
|
||||
public boolean blocked;
|
||||
public int step = -1, stepAccepted = -1;
|
||||
@@ -99,6 +100,10 @@ public class PayloadConveyor extends Block{
|
||||
public void updateTile(){
|
||||
if(!enabled) return;
|
||||
|
||||
lastInterp = curInterp;
|
||||
curInterp = fract();
|
||||
//rollover skip
|
||||
if(lastInterp > curInterp) lastInterp = 0f;
|
||||
progress = time() % moveTime;
|
||||
|
||||
updatePayload();
|
||||
@@ -201,6 +206,14 @@ public class PayloadConveyor extends Block{
|
||||
return Time.time();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unitOn(Unit unit){
|
||||
//calculate derivative of units moved last frame
|
||||
float delta = (curInterp - lastInterp) * size * tilesize;
|
||||
Tmp.v1.trns(rotdeg(), delta * moveForce).scl(1f / Math.max(unit.mass(), 201f));
|
||||
unit.move(Tmp.v1.x, Tmp.v1.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptPayload(Building source, Payload payload){
|
||||
if(source == this){
|
||||
|
||||
@@ -8,6 +8,7 @@ import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.EntityCollisions.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
@@ -47,15 +48,16 @@ public class UnitPayload implements Payload{
|
||||
return false;
|
||||
}
|
||||
|
||||
//naval units need water.
|
||||
if(unit instanceof WaterMovec){
|
||||
//check if unit can be dumped here
|
||||
SolidPred solid = unit.solidity();
|
||||
if(solid != null){
|
||||
int tx = unit.tileX(), ty = unit.tileY();
|
||||
boolean nearEmpty = !EntityCollisions.waterSolid(tx, ty);
|
||||
boolean nearEmpty = !solid.solid(tx, ty);
|
||||
for(Point2 p : Geometry.d4){
|
||||
nearEmpty |= !EntityCollisions.waterSolid(tx + p.x, ty + p.y);
|
||||
nearEmpty |= !solid.solid(tx + p.x, ty + p.y);
|
||||
}
|
||||
|
||||
//cannot dump on dry land
|
||||
//cannot dump on solid blocks
|
||||
if(!nearEmpty) return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user