From b46455642a68994f4fd6101abc3402843d0c0a05 Mon Sep 17 00:00:00 2001 From: Patrick 'Quezler' Mounier Date: Tue, 31 Dec 2019 21:10:12 +0100 Subject: [PATCH] Experiment with reserving tiles --- .../entities/type/base/CraterUnit.java | 35 +++++++++++++++++-- .../distribution/CompressedConveyor.java | 3 +- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/entities/type/base/CraterUnit.java b/core/src/mindustry/entities/type/base/CraterUnit.java index 0a1cd2c09c..e979c89970 100644 --- a/core/src/mindustry/entities/type/base/CraterUnit.java +++ b/core/src/mindustry/entities/type/base/CraterUnit.java @@ -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(){ diff --git a/core/src/mindustry/world/blocks/distribution/CompressedConveyor.java b/core/src/mindustry/world/blocks/distribution/CompressedConveyor.java index b375dc8e2e..cdc4ed9ff8 100644 --- a/core/src/mindustry/world/blocks/distribution/CompressedConveyor.java +++ b/core/src/mindustry/world/blocks/distribution/CompressedConveyor.java @@ -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