pain
This commit is contained in:
@@ -10,7 +10,6 @@ public class AssemblerAI extends AIController{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMovement(){
|
public void updateMovement(){
|
||||||
//TODO
|
|
||||||
if(!targetPos.isZero()){
|
if(!targetPos.isZero()){
|
||||||
moveTo(targetPos, 1f, 3f);
|
moveTo(targetPos, 1f, 3f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -313,11 +313,11 @@ public class Fx{
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
unitAssemble = new Effect(70, e -> {
|
unitAssemble = new Effect(70, e -> {
|
||||||
if(!(e.data instanceof Unit unit)) return;
|
if(!(e.data instanceof UnitType type)) return;
|
||||||
|
|
||||||
alpha(e.fout());
|
alpha(e.fout());
|
||||||
mixcol(Pal.accent, 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),
|
}).layer(Layer.flyingUnit + 5f),
|
||||||
|
|
||||||
padlaunch = new Effect(10, e -> {
|
padlaunch = new Effect(10, e -> {
|
||||||
|
|||||||
@@ -3141,7 +3141,7 @@ public class UnitTypes{
|
|||||||
mineTier = 4;
|
mineTier = 4;
|
||||||
buildSpeed = 0.8f;
|
buildSpeed = 0.8f;
|
||||||
drag = 0.08f;
|
drag = 0.08f;
|
||||||
speed = 5.4f;
|
speed = 5.6f;
|
||||||
rotateSpeed = 7f;
|
rotateSpeed = 7f;
|
||||||
accel = 0.09f;
|
accel = 0.09f;
|
||||||
itemCapacity = 60;
|
itemCapacity = 60;
|
||||||
@@ -3198,7 +3198,7 @@ public class UnitTypes{
|
|||||||
mineTier = 4;
|
mineTier = 4;
|
||||||
buildSpeed = 1.1f;
|
buildSpeed = 1.1f;
|
||||||
drag = 0.08f;
|
drag = 0.08f;
|
||||||
speed = 6.6f;
|
speed = 7f;
|
||||||
rotateSpeed = 8f;
|
rotateSpeed = 8f;
|
||||||
accel = 0.09f;
|
accel = 0.09f;
|
||||||
itemCapacity = 90;
|
itemCapacity = 90;
|
||||||
@@ -3267,7 +3267,7 @@ public class UnitTypes{
|
|||||||
mineTier = 4;
|
mineTier = 4;
|
||||||
buildSpeed = 1.4f;
|
buildSpeed = 1.4f;
|
||||||
drag = 0.08f;
|
drag = 0.08f;
|
||||||
speed = 7.4f;
|
speed = 7.5f;
|
||||||
rotateSpeed = 8f;
|
rotateSpeed = 8f;
|
||||||
accel = 0.08f;
|
accel = 0.08f;
|
||||||
itemCapacity = 110;
|
itemCapacity = 110;
|
||||||
@@ -3331,6 +3331,7 @@ public class UnitTypes{
|
|||||||
allowedInPayloads = false;
|
allowedInPayloads = false;
|
||||||
logicControllable = false;
|
logicControllable = false;
|
||||||
envDisabled = 0;
|
envDisabled = 0;
|
||||||
|
payloadCapacity = 0f;
|
||||||
|
|
||||||
lowAltitude = false;
|
lowAltitude = false;
|
||||||
flying = true;
|
flying = true;
|
||||||
@@ -3360,6 +3361,7 @@ public class UnitTypes{
|
|||||||
health = 90;
|
health = 90;
|
||||||
engineSize = 2f;
|
engineSize = 2f;
|
||||||
engineOffset = 6.5f;
|
engineOffset = 6.5f;
|
||||||
|
payloadCapacity = 0f;
|
||||||
|
|
||||||
outlineColor = Pal.darkOutline;
|
outlineColor = Pal.darkOutline;
|
||||||
isCounted = false;
|
isCounted = false;
|
||||||
|
|||||||
@@ -408,6 +408,8 @@ public class TypeIO{
|
|||||||
write.i(((Unit)ai.attackTarget).id);
|
write.i(((Unit)ai.attackTarget).id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}else if(control instanceof AssemblerAI){ //hate
|
||||||
|
write.b(5);
|
||||||
}else{
|
}else{
|
||||||
write.b(2);
|
write.b(2);
|
||||||
}
|
}
|
||||||
@@ -464,11 +466,15 @@ public class TypeIO{
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ai;
|
return ai;
|
||||||
|
}else if(type == 5){
|
||||||
|
//augh
|
||||||
|
return prev instanceof AssemblerAI ? prev : new AssemblerAI();
|
||||||
}else{
|
}else{
|
||||||
//there are two cases here:
|
//there are two cases here:
|
||||||
//1: prev controller was not a player, carry on
|
//1: prev controller was not a player, carry on
|
||||||
//2: prev controller was a player, so replace this controller with *anything else*
|
//2: prev controller was a player, so replace this controller with *anything else*
|
||||||
//...since AI doesn't update clientside it doesn't matter
|
//...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;
|
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);
|
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.add(new Bar("stat.payloadcapacity", Pal.items, () -> payload.payloadUsed() / unit.type().payloadCapacity));
|
||||||
bars.row();
|
bars.row();
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public class DirectionBridge extends Block{
|
|||||||
noUpdateDisabled = true;
|
noUpdateDisabled = true;
|
||||||
envEnabled = Env.space | Env.terrestrial | Env.underwater;
|
envEnabled = Env.space | Env.terrestrial | Env.underwater;
|
||||||
drawArrow = false;
|
drawArrow = false;
|
||||||
|
regionRotated1 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ public class WallCrafter extends Block{
|
|||||||
rotate = true;
|
rotate = true;
|
||||||
update = true;
|
update = true;
|
||||||
solid = true;
|
solid = true;
|
||||||
|
regionRotated1 = 1;
|
||||||
|
|
||||||
envEnabled |= Env.space;
|
envEnabled |= Env.space;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ public class UnitAssembler extends PayloadBlock{
|
|||||||
rotateDraw = false;
|
rotateDraw = false;
|
||||||
acceptsPayload = true;
|
acceptsPayload = true;
|
||||||
flags = EnumSet.of(BlockFlag.unitAssembler);
|
flags = EnumSet.of(BlockFlag.unitAssembler);
|
||||||
|
regionRotated1 = 1;
|
||||||
|
sync = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rect getRect(Rect rect, float x, float y, int rotation){
|
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>{
|
public class UnitAssemblerBuild extends PayloadBlockBuild<BuildPayload>{
|
||||||
protected IntSeq readUnits = new IntSeq();
|
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<Unit> units = new Seq<>();
|
||||||
public Seq<UnitAssemblerModuleBuild> modules = new Seq<>();
|
public Seq<UnitAssemblerModuleBuild> modules = new Seq<>();
|
||||||
@@ -282,6 +298,16 @@ public class UnitAssembler extends PayloadBlock{
|
|||||||
readUnits.clear();
|
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));
|
units.removeAll(u -> !u.isAdded() || u.dead || !(u.controller() instanceof AssemblerAI));
|
||||||
|
|
||||||
powerWarmup = Mathf.lerpDelta(powerWarmup, efficiency() > 0.0001f ? 1f : 0f, 0.1f);
|
powerWarmup = Mathf.lerpDelta(powerWarmup, efficiency() > 0.0001f ? 1f : 0f, 0.1f);
|
||||||
@@ -289,16 +315,20 @@ public class UnitAssembler extends PayloadBlock{
|
|||||||
totalDroneProgress += droneWarmup * Time.delta;
|
totalDroneProgress += droneWarmup * Time.delta;
|
||||||
|
|
||||||
if(units.size < dronesCreated && (droneProgress += edelta() / droneConstructTime) >= 1f){
|
if(units.size < dronesCreated && (droneProgress += edelta() / droneConstructTime) >= 1f){
|
||||||
var unit = droneType.create(team);
|
if(!net.client()){
|
||||||
if(unit instanceof BuildingTetherc bt){
|
var unit = droneType.create(team);
|
||||||
bt.building(this);
|
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);
|
if(units.size >= dronesCreated){
|
||||||
units.add(unit);
|
|
||||||
droneProgress = 0f;
|
droneProgress = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +350,7 @@ public class UnitAssembler extends PayloadBlock{
|
|||||||
|
|
||||||
wasOccupied = checkSolid(spawn, false);
|
wasOccupied = checkSolid(spawn, false);
|
||||||
boolean visualOccupied = checkSolid(spawn, true);
|
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);
|
sameTypeWarmup = Mathf.lerpDelta(sameTypeWarmup, wasOccupied && !visualOccupied ? 0f : 1f, 0.1f);
|
||||||
invalidWarmup = Mathf.lerpDelta(invalidWarmup, visualOccupied ? 1f : 0f, 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);
|
warmup = Mathf.lerpDelta(warmup, efficiency(), 0.1f);
|
||||||
|
|
||||||
if((progress += edelta() * eff / plan.time) >= 1f){
|
if((progress += edelta() * eff / plan.time) >= 1f){
|
||||||
consume();
|
Call.assemblerUnitSpawned(tile);
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
warmup = Mathf.lerpDelta(warmup, 0f, 0.1f);
|
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
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
Draw.rect(region, x, y);
|
Draw.rect(region, x, y);
|
||||||
@@ -372,7 +417,7 @@ public class UnitAssembler extends PayloadBlock{
|
|||||||
Draw.rect(topRegion, x, y);
|
Draw.rect(topRegion, x, y);
|
||||||
|
|
||||||
//draw drone construction
|
//draw drone construction
|
||||||
if(droneWarmup > 0){
|
if(droneWarmup > 0.001f){
|
||||||
Draw.draw(Layer.blockOver + 0.2f, () -> {
|
Draw.draw(Layer.blockOver + 0.2f, () -> {
|
||||||
Drawf.construct(this, droneType.fullIcon, Pal.accent, 0f, droneProgress, droneWarmup, totalDroneProgress, 14f);
|
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++){
|
for(int i = 0; i < count; i++){
|
||||||
readUnits.add(read.i());
|
readUnits.add(read.i());
|
||||||
}
|
}
|
||||||
|
whenSyncedUnits.clear();
|
||||||
|
|
||||||
blocks.read(read);
|
blocks.read(read);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user