drone construction time
This commit is contained in:
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 |
@@ -389,6 +389,10 @@ public class Drawf{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void construct(Building t, TextureRegion region, Color color, float rotation, float progress, float speed, float 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.region = region;
|
||||||
Shaders.build.progress = progress;
|
Shaders.build.progress = progress;
|
||||||
Shaders.build.color.set(color);
|
Shaders.build.color.set(color);
|
||||||
@@ -402,7 +406,7 @@ public class Drawf{
|
|||||||
Draw.color(Pal.accent);
|
Draw.color(Pal.accent);
|
||||||
Draw.alpha(speed);
|
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();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public class UnitAssembler extends PayloadBlock{
|
|||||||
public int areaSize = 11;
|
public int areaSize = 11;
|
||||||
public UnitType droneType = UnitTypes.assemblyDrone;
|
public UnitType droneType = UnitTypes.assemblyDrone;
|
||||||
public int dronesCreated = 4;
|
public int dronesCreated = 4;
|
||||||
|
public float droneConstructTime = 60f * 3f;
|
||||||
|
|
||||||
public Seq<AssemblerUnitPlan> plans = new Seq<>(4);
|
public Seq<AssemblerUnitPlan> plans = new Seq<>(4);
|
||||||
|
|
||||||
@@ -137,6 +138,7 @@ public class UnitAssembler extends PayloadBlock{
|
|||||||
AssemblerUnitPlan(){}
|
AssemblerUnitPlan(){}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** hbgwerjhbagjegwg */
|
||||||
public static class YeetData{
|
public static class YeetData{
|
||||||
public Vec2 target;
|
public Vec2 target;
|
||||||
public Block block;
|
public Block block;
|
||||||
@@ -153,11 +155,13 @@ public class UnitAssembler extends PayloadBlock{
|
|||||||
public Seq<Unit> units = new Seq<>();
|
public Seq<Unit> units = new Seq<>();
|
||||||
public Seq<UnitAssemblerModuleBuild> modules = new Seq<>();
|
public Seq<UnitAssemblerModuleBuild> modules = new Seq<>();
|
||||||
public BlockSeq blocks = new BlockSeq();
|
public BlockSeq blocks = new BlockSeq();
|
||||||
public float progress, warmup;
|
public float progress, warmup, droneWarmup;
|
||||||
public float invalidWarmup = 0f;
|
public float invalidWarmup = 0f;
|
||||||
public int currentTier = 0;
|
public int currentTier = 0;
|
||||||
public boolean wasOccupied = false;
|
public boolean wasOccupied = false;
|
||||||
|
|
||||||
|
public float droneProgress, totalDroneProgress;
|
||||||
|
|
||||||
public Vec2 getUnitSpawn(){
|
public Vec2 getUnitSpawn(){
|
||||||
float len = tilesize * (areaSize + size)/2f;
|
float len = tilesize * (areaSize + size)/2f;
|
||||||
float unitX = x + Geometry.d4x(rotation) * len, unitY = y + Geometry.d4y(rotation) * len;
|
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));
|
units.removeAll(u -> !u.isAdded() || u.dead || !(u.controller() instanceof AssemblerAI));
|
||||||
|
|
||||||
//TODO build up units, don't spawn immediately in batches
|
droneWarmup = Mathf.lerpDelta(droneWarmup, units.size < dronesCreated ? efficiency() : 0f, 0.1f);
|
||||||
if(efficiency() > 0 && units.size < dronesCreated){
|
totalDroneProgress += droneWarmup * Time.delta;
|
||||||
|
|
||||||
|
if(units.size < dronesCreated && (droneProgress += edelta() / droneConstructTime) >= 1f){
|
||||||
var unit = droneType.create(team);
|
var unit = droneType.create(team);
|
||||||
if(unit instanceof BuildingTetherc bt){
|
if(unit instanceof BuildingTetherc bt){
|
||||||
bt.building(this);
|
bt.building(this);
|
||||||
@@ -287,6 +293,7 @@ public class UnitAssembler extends PayloadBlock{
|
|||||||
|
|
||||||
Fx.spawn.at(unit);
|
Fx.spawn.at(unit);
|
||||||
units.add(unit);
|
units.add(unit);
|
||||||
|
droneProgress = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO units should pick up and move payloads into position
|
//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);
|
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();
|
Vec2 spawn = getUnitSpawn();
|
||||||
|
|
||||||
@@ -437,7 +451,8 @@ public class UnitAssembler extends PayloadBlock{
|
|||||||
@Override
|
@Override
|
||||||
public boolean acceptPayload(Building source, Payload payload){
|
public boolean acceptPayload(Building source, Payload payload){
|
||||||
var plan = plan();
|
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
|
@Override
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class UnitAssemblerModule extends PayloadBlock{
|
|||||||
super(name);
|
super(name);
|
||||||
rotate = true;
|
rotate = true;
|
||||||
rotateDraw = false;
|
rotateDraw = false;
|
||||||
|
acceptsPayload = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -81,7 +82,7 @@ public class UnitAssemblerModule extends PayloadBlock{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptPayload(Building source, Payload payload){
|
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
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user