Experiment with reserving tiles

This commit is contained in:
Patrick 'Quezler' Mounier
2019-12-31 21:10:12 +01:00
parent 9c1eca6d31
commit b46455642a
2 changed files with 34 additions and 4 deletions

View File

@@ -3,6 +3,7 @@ package mindustry.entities.type.base;
import arc.*;
import arc.math.*;
import arc.util.*;
import mindustry.entities.type.*;
import mindustry.ui.*;
import mindustry.type.*;
import mindustry.world.*;
@@ -14,6 +15,7 @@ import arc.scene.ui.layout.*;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.entities.Effects.*;
import mindustry.world.blocks.distribution.*;
import mindustry.world.blocks.distribution.CompressedConveyor.*;
import static mindustry.Vars.*;
@@ -22,6 +24,8 @@ public class CraterUnit extends GroundUnit{
private final Effect io = Fx.plasticburn; // effect to play when poofing in and out of existence
private int inactivity = 0;
private CraterUnit unit = (CraterUnit)this;
private final UnitState
load = new UnitState(){
@@ -32,14 +36,39 @@ public class CraterUnit extends GroundUnit{
},
move = new UnitState(){
public void update(){
// move in the direction/rotation of the block its currently on
velocity.add(vec.trnsExact(angleTo(on().front()), type.speed * Time.delta()));
rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed);
// Tile target = on().front();
// float f = (Time.time() / 100f) % 1f;/**/
// Log.info(timer.get(timerTarget, 21));
// Log.info(f);
// Timer.schedule()/**/
// if(retarget()){
// move in the direction/rotation of the block its currently on
// velocity.add(vec.trnsExact(angleTo(on().front()), type.speed * Time.delta()));
// rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed);
// }
// switch to unload when on an end tile
if(dst(on()) < 2.5f && on(Track.end)){
state.set(unload);
return;
}
Tile target = on().front();
CompressedConveyorEntity entity = target.ent();
if(entity == null) return;
if(entity.dibs == null) entity.dibs = unit;
if(entity.dibs != null) target = on();
velocity.add(vec.trnsExact(angleTo(target), type.speed * Time.delta()));
rotation = Mathf.slerpDelta(rotation, baseRotation, type.rotatespeed);
}
},
unload = new UnitState(){

View File

@@ -58,9 +58,10 @@ public class CompressedConveyor extends ArmoredConveyor{
if(entity.reload > 0) entity.reload--;
}
class CompressedConveyorEntity extends ConveyorEntity{
public class CompressedConveyorEntity extends ConveyorEntity{
public int reload = 0;
public CraterUnit crater = null;
public CraterUnit dibs = null;
}
@Override