drone construction time

This commit is contained in:
Anuken 2021-12-19 12:38:52 -05:00
parent 8023ea1d34
commit 3844121913
5 changed files with 29 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 1023 B

View File

@ -387,8 +387,12 @@ public class Drawf{
public static void construct(Building t, TextureRegion region, float rotation, float progress, float speed, float time){
construct(t, region, Pal.accent, rotation, progress, speed, time);
}
public static void construct(Building t, TextureRegion region, Color color, float rotation, float progress, float speed, float time){
construct(t, region, color, rotation, progress, speed, time, t.block.size * tilesize - 4f);
}
public static void construct(Building t, TextureRegion region, Color color, float rotation, float progress, float speed, float time, float size){
Shaders.build.region = region;
Shaders.build.progress = progress;
Shaders.build.color.set(color);
@ -402,7 +406,7 @@ public class Drawf{
Draw.color(Pal.accent);
Draw.alpha(speed);
Lines.lineAngleCenter(t.x + Mathf.sin(time, 20f, Vars.tilesize / 2f * t.block.size - 2f), t.y, 90, t.block.size * Vars.tilesize - 4f);
Lines.lineAngleCenter(t.x + Mathf.sin(time, 20f, size / 2f), t.y, 90, size);
Draw.reset();
}

View File

@ -36,6 +36,7 @@ public class UnitAssembler extends PayloadBlock{
public int areaSize = 11;
public UnitType droneType = UnitTypes.assemblyDrone;
public int dronesCreated = 4;
public float droneConstructTime = 60f * 3f;
public Seq<AssemblerUnitPlan> plans = new Seq<>(4);
@ -137,6 +138,7 @@ public class UnitAssembler extends PayloadBlock{
AssemblerUnitPlan(){}
}
/** hbgwerjhbagjegwg */
public static class YeetData{
public Vec2 target;
public Block block;
@ -153,11 +155,13 @@ public class UnitAssembler extends PayloadBlock{
public Seq<Unit> units = new Seq<>();
public Seq<UnitAssemblerModuleBuild> modules = new Seq<>();
public BlockSeq blocks = new BlockSeq();
public float progress, warmup;
public float progress, warmup, droneWarmup;
public float invalidWarmup = 0f;
public int currentTier = 0;
public boolean wasOccupied = false;
public float droneProgress, totalDroneProgress;
public Vec2 getUnitSpawn(){
float len = tilesize * (areaSize + size)/2f;
float unitX = x + Geometry.d4x(rotation) * len, unitY = y + Geometry.d4y(rotation) * len;
@ -275,8 +279,10 @@ public class UnitAssembler extends PayloadBlock{
units.removeAll(u -> !u.isAdded() || u.dead || !(u.controller() instanceof AssemblerAI));
//TODO build up units, don't spawn immediately in batches
if(efficiency() > 0 && units.size < dronesCreated){
droneWarmup = Mathf.lerpDelta(droneWarmup, units.size < dronesCreated ? efficiency() : 0f, 0.1f);
totalDroneProgress += droneWarmup * Time.delta;
if(units.size < dronesCreated && (droneProgress += edelta() / droneConstructTime) >= 1f){
var unit = droneType.create(team);
if(unit instanceof BuildingTetherc bt){
bt.building(this);
@ -287,6 +293,7 @@ public class UnitAssembler extends PayloadBlock{
Fx.spawn.at(unit);
units.add(unit);
droneProgress = 0f;
}
//TODO units should pick up and move payloads into position
@ -359,8 +366,15 @@ public class UnitAssembler extends PayloadBlock{
Draw.z(Layer.blockOver + 0.1f);
//TODO top?
//Draw.rect(topRegion, x, y);
Draw.rect(topRegion, x, y);
//draw drone construction
if(droneWarmup > 0){
//TODO draw it - better animations?
Draw.draw(Layer.blockOver + 0.2f, () -> {
Drawf.construct(this, droneType.fullIcon, Pal.accent, 0f, droneProgress, droneWarmup, totalDroneProgress, 14f);
});
}
Vec2 spawn = getUnitSpawn();
@ -437,7 +451,8 @@ public class UnitAssembler extends PayloadBlock{
@Override
public boolean acceptPayload(Building source, Payload payload){
var plan = plan();
return this.payload == null && payload instanceof BuildPayload bp && plan.requirements.contains(b -> b.block == bp.block() && blocks.get(bp.block()) < b.amount);
return (this.payload == null || source instanceof UnitAssemblerModuleBuild) &&
payload instanceof BuildPayload bp && plan.requirements.contains(b -> b.block == bp.block() && blocks.get(bp.block()) < b.amount);
}
@Override

View File

@ -20,6 +20,7 @@ public class UnitAssemblerModule extends PayloadBlock{
super(name);
rotate = true;
rotateDraw = false;
acceptsPayload = true;
}
@Override
@ -81,7 +82,7 @@ public class UnitAssemblerModule extends PayloadBlock{
@Override
public boolean acceptPayload(Building source, Payload payload){
return link != null && this.payload == null && link.acceptPayload(source, payload);
return link != null && this.payload == null && link.acceptPayload(this, payload);
}
@Override