mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-06 02:40:23 -08:00
pain
This commit is contained in:
parent
bad2e017d0
commit
58c044f509
8 changed files with 83 additions and 28 deletions
|
|
@ -10,7 +10,6 @@ public class AssemblerAI extends AIController{
|
|||
|
||||
@Override
|
||||
public void updateMovement(){
|
||||
//TODO
|
||||
if(!targetPos.isZero()){
|
||||
moveTo(targetPos, 1f, 3f);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -313,11 +313,11 @@ public class Fx{
|
|||
}),
|
||||
|
||||
unitAssemble = new Effect(70, e -> {
|
||||
if(!(e.data instanceof Unit unit)) return;
|
||||
if(!(e.data instanceof UnitType type)) return;
|
||||
|
||||
alpha(e.fout());
|
||||
mixcol(Pal.accent, e.fout());
|
||||
rect(unit.type.fullIcon, unit.x, unit.y, unit.rotation - 90);
|
||||
rect(type.fullIcon, e.x, e.y, e.rotation);
|
||||
}).layer(Layer.flyingUnit + 5f),
|
||||
|
||||
padlaunch = new Effect(10, e -> {
|
||||
|
|
|
|||
|
|
@ -3141,7 +3141,7 @@ public class UnitTypes{
|
|||
mineTier = 4;
|
||||
buildSpeed = 0.8f;
|
||||
drag = 0.08f;
|
||||
speed = 5.4f;
|
||||
speed = 5.6f;
|
||||
rotateSpeed = 7f;
|
||||
accel = 0.09f;
|
||||
itemCapacity = 60;
|
||||
|
|
@ -3198,7 +3198,7 @@ public class UnitTypes{
|
|||
mineTier = 4;
|
||||
buildSpeed = 1.1f;
|
||||
drag = 0.08f;
|
||||
speed = 6.6f;
|
||||
speed = 7f;
|
||||
rotateSpeed = 8f;
|
||||
accel = 0.09f;
|
||||
itemCapacity = 90;
|
||||
|
|
@ -3267,7 +3267,7 @@ public class UnitTypes{
|
|||
mineTier = 4;
|
||||
buildSpeed = 1.4f;
|
||||
drag = 0.08f;
|
||||
speed = 7.4f;
|
||||
speed = 7.5f;
|
||||
rotateSpeed = 8f;
|
||||
accel = 0.08f;
|
||||
itemCapacity = 110;
|
||||
|
|
@ -3331,6 +3331,7 @@ public class UnitTypes{
|
|||
allowedInPayloads = false;
|
||||
logicControllable = false;
|
||||
envDisabled = 0;
|
||||
payloadCapacity = 0f;
|
||||
|
||||
lowAltitude = false;
|
||||
flying = true;
|
||||
|
|
@ -3360,6 +3361,7 @@ public class UnitTypes{
|
|||
health = 90;
|
||||
engineSize = 2f;
|
||||
engineOffset = 6.5f;
|
||||
payloadCapacity = 0f;
|
||||
|
||||
outlineColor = Pal.darkOutline;
|
||||
isCounted = false;
|
||||
|
|
|
|||
|
|
@ -408,6 +408,8 @@ public class TypeIO{
|
|||
write.i(((Unit)ai.attackTarget).id);
|
||||
}
|
||||
}
|
||||
}else if(control instanceof AssemblerAI){ //hate
|
||||
write.b(5);
|
||||
}else{
|
||||
write.b(2);
|
||||
}
|
||||
|
|
@ -464,11 +466,15 @@ public class TypeIO{
|
|||
}
|
||||
|
||||
return ai;
|
||||
}else if(type == 5){
|
||||
//augh
|
||||
return prev instanceof AssemblerAI ? prev : new AssemblerAI();
|
||||
}else{
|
||||
//there are two cases here:
|
||||
//1: prev controller was not a player, carry on
|
||||
//2: prev controller was a player, so replace this controller with *anything else*
|
||||
//...since AI doesn't update clientside it doesn't matter
|
||||
//TODO I hate this
|
||||
return (!(prev instanceof AIController) || (prev instanceof FormationAI) || (prev instanceof LogicAI)) ? new GroundAI() : prev;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ public class UnitType extends UnlockableContent{
|
|||
ability.displayBars(unit, bars);
|
||||
}
|
||||
|
||||
if(unit instanceof Payloadc payload){
|
||||
if(payloadCapacity > 0 && unit instanceof Payloadc payload){
|
||||
bars.add(new Bar("stat.payloadcapacity", Pal.items, () -> payload.payloadUsed() / unit.type().payloadCapacity));
|
||||
bars.row();
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ public class DirectionBridge extends Block{
|
|||
noUpdateDisabled = true;
|
||||
envEnabled = Env.space | Env.terrestrial | Env.underwater;
|
||||
drawArrow = false;
|
||||
regionRotated1 = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ public class WallCrafter extends Block{
|
|||
rotate = true;
|
||||
update = true;
|
||||
solid = true;
|
||||
regionRotated1 = 1;
|
||||
|
||||
envEnabled |= Env.space;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ public class UnitAssembler extends PayloadBlock{
|
|||
rotateDraw = false;
|
||||
acceptsPayload = true;
|
||||
flags = EnumSet.of(BlockFlag.unitAssembler);
|
||||
regionRotated1 = 1;
|
||||
sync = true;
|
||||
}
|
||||
|
||||
public Rect getRect(Rect rect, float x, float y, int rotation){
|
||||
|
|
@ -166,8 +168,22 @@ public class UnitAssembler extends PayloadBlock{
|
|||
}
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void assemblerUnitSpawned(Tile tile){
|
||||
if(tile == null || !(tile.build instanceof UnitAssemblerBuild build)) return;
|
||||
build.spawned();
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void assemblerDroneSpawned(Tile tile, int id){
|
||||
if(tile == null || !(tile.build instanceof UnitAssemblerBuild build)) return;
|
||||
build.droneSpawned(id);
|
||||
}
|
||||
|
||||
public class UnitAssemblerBuild extends PayloadBlockBuild<BuildPayload>{
|
||||
protected IntSeq readUnits = new IntSeq();
|
||||
//holds drone IDs that have been sent, but not synced yet - add to list as soon as possible
|
||||
protected IntSeq whenSyncedUnits = new IntSeq();
|
||||
|
||||
public Seq<Unit> units = new Seq<>();
|
||||
public Seq<UnitAssemblerModuleBuild> modules = new Seq<>();
|
||||
|
|
@ -282,6 +298,16 @@ public class UnitAssembler extends PayloadBlock{
|
|||
readUnits.clear();
|
||||
}
|
||||
|
||||
//read newly synced drones on client end
|
||||
if(units.size < dronesCreated && whenSyncedUnits.size > 0){
|
||||
whenSyncedUnits.each(id -> {
|
||||
var unit = Groups.unit.getByID(id);
|
||||
if(unit != null){
|
||||
units.addUnique(unit);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
units.removeAll(u -> !u.isAdded() || u.dead || !(u.controller() instanceof AssemblerAI));
|
||||
|
||||
powerWarmup = Mathf.lerpDelta(powerWarmup, efficiency() > 0.0001f ? 1f : 0f, 0.1f);
|
||||
|
|
@ -289,16 +315,20 @@ public class UnitAssembler extends PayloadBlock{
|
|||
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);
|
||||
if(!net.client()){
|
||||
var unit = droneType.create(team);
|
||||
if(unit instanceof BuildingTetherc bt){
|
||||
bt.building(this);
|
||||
}
|
||||
unit.set(x, y);
|
||||
unit.rotation = 90f;
|
||||
unit.add();
|
||||
units.add(unit);
|
||||
Call.assemblerDroneSpawned(tile, unit.id);
|
||||
}
|
||||
unit.set(x, y);
|
||||
unit.rotation = 90f;
|
||||
unit.add();
|
||||
}
|
||||
|
||||
Fx.spawn.at(unit);
|
||||
units.add(unit);
|
||||
if(units.size >= dronesCreated){
|
||||
droneProgress = 0f;
|
||||
}
|
||||
|
||||
|
|
@ -320,7 +350,7 @@ public class UnitAssembler extends PayloadBlock{
|
|||
|
||||
wasOccupied = checkSolid(spawn, false);
|
||||
boolean visualOccupied = checkSolid(spawn, true);
|
||||
float eff = (units.count(u -> ((AssemblerAI)u.controller()).inPosition()) / (float)dronesCreated);
|
||||
float eff = (units.count(u -> ((AssemblerAI)u.controller()).inPosition()) / (float)dronesCreated);
|
||||
|
||||
sameTypeWarmup = Mathf.lerpDelta(sameTypeWarmup, wasOccupied && !visualOccupied ? 0f : 1f, 0.1f);
|
||||
invalidWarmup = Mathf.lerpDelta(invalidWarmup, visualOccupied ? 1f : 0f, 0.1f);
|
||||
|
|
@ -332,23 +362,38 @@ public class UnitAssembler extends PayloadBlock{
|
|||
warmup = Mathf.lerpDelta(warmup, efficiency(), 0.1f);
|
||||
|
||||
if((progress += edelta() * eff / plan.time) >= 1f){
|
||||
consume();
|
||||
|
||||
var unit = plan.unit.create(team);
|
||||
unit.set(spawn.x + Mathf.range(0.001f), spawn.y + Mathf.range(0.001f));
|
||||
unit.rotation = 90f;
|
||||
unit.add();
|
||||
progress = 0f;
|
||||
|
||||
Fx.unitAssemble.at(unit.x, unit.y, 0f, unit);
|
||||
|
||||
blocks.clear();
|
||||
Call.assemblerUnitSpawned(tile);
|
||||
}
|
||||
}else{
|
||||
warmup = Mathf.lerpDelta(warmup, 0f, 0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
public void droneSpawned(int id){
|
||||
Fx.spawn.at(x, y);
|
||||
droneProgress = 0f;
|
||||
if(net.client()){
|
||||
whenSyncedUnits.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
public void spawned(){
|
||||
var plan = plan();
|
||||
Vec2 spawn = getUnitSpawn();
|
||||
consume();
|
||||
|
||||
if(!net.client()){
|
||||
var unit = plan.unit.create(team);
|
||||
unit.set(spawn.x + Mathf.range(0.001f), spawn.y + Mathf.range(0.001f));
|
||||
unit.rotation = 90f;
|
||||
unit.add();
|
||||
}
|
||||
|
||||
progress = 0f;
|
||||
Fx.unitAssemble.at(spawn.x, spawn.y, 0f, plan.unit);
|
||||
blocks.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(region, x, y);
|
||||
|
|
@ -372,7 +417,7 @@ public class UnitAssembler extends PayloadBlock{
|
|||
Draw.rect(topRegion, x, y);
|
||||
|
||||
//draw drone construction
|
||||
if(droneWarmup > 0){
|
||||
if(droneWarmup > 0.001f){
|
||||
Draw.draw(Layer.blockOver + 0.2f, () -> {
|
||||
Drawf.construct(this, droneType.fullIcon, Pal.accent, 0f, droneProgress, droneWarmup, totalDroneProgress, 14f);
|
||||
});
|
||||
|
|
@ -503,6 +548,7 @@ public class UnitAssembler extends PayloadBlock{
|
|||
for(int i = 0; i < count; i++){
|
||||
readUnits.add(read.i());
|
||||
}
|
||||
whenSyncedUnits.clear();
|
||||
|
||||
blocks.read(read);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue