- Resolved all remaining TODOs
This commit is contained in:
@@ -83,7 +83,6 @@ public class DefenseBlocks extends BlockList implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
forceProjector = new ForceProjector("force-projector"){{
|
forceProjector = new ForceProjector("force-projector"){{
|
||||||
consumes.powerDirect(0.2f);
|
|
||||||
size = 3;
|
size = 3;
|
||||||
consumes.item(Items.phasefabric).optional(true);
|
consumes.item(Items.phasefabric).optional(true);
|
||||||
}};
|
}};
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public class PowerBlocks extends BlockList implements ContentList{
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
largeSolarPanel = new SolarGenerator("solar-panel-large"){{
|
largeSolarPanel = new SolarGenerator("solar-panel-large"){{
|
||||||
|
size = 3;
|
||||||
powerProduction = 0.055f;
|
powerProduction = 0.055f;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import io.anuke.mindustry.world.BarType;
|
|||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter;
|
import io.anuke.mindustry.world.consumers.ConsumeLiquidFilter;
|
||||||
|
import io.anuke.mindustry.world.consumers.ConsumePower;
|
||||||
import io.anuke.mindustry.world.meta.BlockBar;
|
import io.anuke.mindustry.world.meta.BlockBar;
|
||||||
import io.anuke.mindustry.world.meta.BlockStat;
|
import io.anuke.mindustry.world.meta.BlockStat;
|
||||||
import io.anuke.mindustry.world.meta.StatUnit;
|
import io.anuke.mindustry.world.meta.StatUnit;
|
||||||
@@ -41,9 +42,12 @@ public class ForceProjector extends Block {
|
|||||||
protected float cooldownNormal = 1.75f;
|
protected float cooldownNormal = 1.75f;
|
||||||
protected float cooldownLiquid = 1.5f;
|
protected float cooldownLiquid = 1.5f;
|
||||||
protected float cooldownBrokenBase = 0.35f;
|
protected float cooldownBrokenBase = 0.35f;
|
||||||
|
protected float basePowerDraw = 0.2f;
|
||||||
protected float powerDamage = 0.1f;
|
protected float powerDamage = 0.1f;
|
||||||
|
protected final ConsumePower consumePower;
|
||||||
protected TextureRegion topRegion;
|
protected TextureRegion topRegion;
|
||||||
|
|
||||||
|
|
||||||
public ForceProjector(String name) {
|
public ForceProjector(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
update = true;
|
update = true;
|
||||||
@@ -54,7 +58,7 @@ public class ForceProjector extends Block {
|
|||||||
hasItems = true;
|
hasItems = true;
|
||||||
itemCapacity = 10;
|
itemCapacity = 10;
|
||||||
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.1f)).optional(true).update(false);
|
consumes.add(new ConsumeLiquidFilter(liquid -> liquid.temperature <= 0.5f && liquid.flammability < 0.1f, 0.1f)).optional(true).update(false);
|
||||||
consumes.powerBuffered(60f);
|
consumePower = consumes.powerBuffered(60f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -67,6 +71,7 @@ public class ForceProjector extends Block {
|
|||||||
public void setStats(){
|
public void setStats(){
|
||||||
super.setStats();
|
super.setStats();
|
||||||
|
|
||||||
|
stats.add(BlockStat.powerUse, basePowerDraw * 60f, StatUnit.powerSecond);
|
||||||
stats.add(BlockStat.powerDamage, powerDamage, StatUnit.powerUnits);
|
stats.add(BlockStat.powerDamage, powerDamage, StatUnit.powerUnits);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,16 +104,18 @@ public class ForceProjector extends Block {
|
|||||||
Effects.effect(BlockFx.reactorsmoke, tile.drawx() + Mathf.range(tilesize/2f), tile.drawy() + Mathf.range(tilesize/2f));
|
Effects.effect(BlockFx.reactorsmoke, tile.drawx() + Mathf.range(tilesize/2f), tile.drawy() + Mathf.range(tilesize/2f));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!entity.cons.valid() && !cheat){
|
// Draw base power from buffer manually (ConsumePower doesn't support both filling a buffer and drawing power additionally so we have to do it here)
|
||||||
|
entity.power.satisfaction -= Math.min(entity.power.satisfaction, basePowerDraw / consumePower.powerCapacity);
|
||||||
|
|
||||||
|
if(entity.power.satisfaction == 0.0f && !cheat){
|
||||||
entity.warmup = Mathf.lerpDelta(entity.warmup, 0f, 0.15f);
|
entity.warmup = Mathf.lerpDelta(entity.warmup, 0f, 0.15f);
|
||||||
if(entity.warmup <= 0.09f){
|
if(entity.warmup <= 0.09f){
|
||||||
entity.broken = true;
|
entity.broken = true;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.1f);
|
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.1f);
|
||||||
// TODO Adapt power calculations to new power system
|
float relativePowerDraw = powerDamage * entity.delta() * (1f + entity.buildup / breakage) / consumePower.powerCapacity;
|
||||||
// float powerUse = Math.min(powerDamage * entity.delta() * (1f + entity.buildup / breakage), powerCapacity);
|
entity.power.satisfaction -= Math.min(relativePowerDraw, entity.power.satisfaction);
|
||||||
// entity.power.amount -= powerUse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.buildup > 0){
|
if(entity.buildup > 0){
|
||||||
@@ -143,14 +150,13 @@ public class ForceProjector extends Block {
|
|||||||
if(trait.canBeAbsorbed() && trait.getTeam() != tile.getTeam() && isInsideHexagon(trait.getX(), trait.getY(), realRadius * 2f, tile.drawx(), tile.drawy())){
|
if(trait.canBeAbsorbed() && trait.getTeam() != tile.getTeam() && isInsideHexagon(trait.getX(), trait.getY(), realRadius * 2f, tile.drawx(), tile.drawy())){
|
||||||
trait.absorb();
|
trait.absorb();
|
||||||
Effects.effect(BulletFx.absorb, trait);
|
Effects.effect(BulletFx.absorb, trait);
|
||||||
float hit = trait.getShieldDamage()*powerDamage;
|
float relativePowerDraw = trait.getShieldDamage() * powerDamage / consumePower.powerCapacity;
|
||||||
entity.hit = 1f;
|
entity.hit = 1f;
|
||||||
// TODO Adapt power calculations to new power system
|
|
||||||
// entity.power.amount -= Math.min(hit, entity.power.amount);
|
entity.power.satisfaction -= Math.min(relativePowerDraw, entity.power.satisfaction);
|
||||||
//
|
if(entity.power.satisfaction <= 0.0001f){
|
||||||
// if(entity.power.amount <= 0.0001f){
|
entity.buildup += trait.getShieldDamage() * entity.warmup * 2f;
|
||||||
// entity.buildup += trait.getShieldDamage() * entity.warmup*2f;
|
}
|
||||||
// }
|
|
||||||
entity.buildup += trait.getShieldDamage() * entity.warmup;
|
entity.buildup += trait.getShieldDamage() * entity.warmup;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
// TODO Adapt whole class to new power system
|
|
||||||
public class MassDriver extends Block{
|
public class MassDriver extends Block{
|
||||||
protected float range;
|
protected float range;
|
||||||
protected float rotateSpeed = 0.04f;
|
protected float rotateSpeed = 0.04f;
|
||||||
@@ -49,7 +48,7 @@ public class MassDriver extends Block{
|
|||||||
protected Effect smokeEffect = ShootFx.shootBigSmoke2;
|
protected Effect smokeEffect = ShootFx.shootBigSmoke2;
|
||||||
protected Effect recieveEffect = BlockFx.mineBig;
|
protected Effect recieveEffect = BlockFx.mineBig;
|
||||||
protected float shake = 3f;
|
protected float shake = 3f;
|
||||||
protected final static float powerPercentageUsed = 0.8f;
|
protected final static float powerPercentageUsed = 1.0f;
|
||||||
protected TextureRegion turretRegion;
|
protected TextureRegion turretRegion;
|
||||||
|
|
||||||
public MassDriver(String name){
|
public MassDriver(String name){
|
||||||
@@ -171,8 +170,8 @@ public class MassDriver extends Block{
|
|||||||
|
|
||||||
entity.rotation = Mathf.slerpDelta(entity.rotation, tile.angleTo(waiter), rotateSpeed);
|
entity.rotation = Mathf.slerpDelta(entity.rotation, tile.angleTo(waiter), rotateSpeed);
|
||||||
}else if(tile.entity.items.total() >= minDistribute &&
|
}else if(tile.entity.items.total() >= minDistribute &&
|
||||||
linkValid(tile) && //only fire when at least at 80% power capacity
|
linkValid(tile) && //only fire when at 100% power capacity
|
||||||
tile.entity.power.satisfaction > powerPercentageUsed &&
|
tile.entity.power.satisfaction >= powerPercentageUsed &&
|
||||||
link.block().itemCapacity - link.entity.items.total() >= minDistribute && entity.reload <= 0.0001f){
|
link.block().itemCapacity - link.entity.items.total() >= minDistribute && entity.reload <= 0.0001f){
|
||||||
|
|
||||||
MassDriverEntity other = link.entity();
|
MassDriverEntity other = link.entity();
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ import io.anuke.mindustry.graphics.Layer;
|
|||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.mindustry.world.consumers.ConsumePower;
|
||||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||||
|
import io.anuke.mindustry.world.meta.BlockStat;
|
||||||
|
import io.anuke.mindustry.world.meta.StatUnit;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.graphics.Lines;
|
import io.anuke.ucore.graphics.Lines;
|
||||||
@@ -26,6 +29,8 @@ public class RepairPoint extends Block{
|
|||||||
|
|
||||||
protected float repairRadius = 50f;
|
protected float repairRadius = 50f;
|
||||||
protected float repairSpeed = 0.3f;
|
protected float repairSpeed = 0.3f;
|
||||||
|
protected float powerPerEvent = 0.06f;
|
||||||
|
protected ConsumePower consumePower;
|
||||||
|
|
||||||
protected TextureRegion topRegion;
|
protected TextureRegion topRegion;
|
||||||
|
|
||||||
@@ -37,8 +42,7 @@ public class RepairPoint extends Block{
|
|||||||
layer = Layer.turret;
|
layer = Layer.turret;
|
||||||
layer2 = Layer.laser;
|
layer2 = Layer.laser;
|
||||||
hasPower = true;
|
hasPower = true;
|
||||||
// TODO Adapt to new power system - Make it use power while repairing
|
consumePower = consumes.powerBuffered(20f);
|
||||||
consumes.powerBuffered(20f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -48,6 +52,12 @@ public class RepairPoint extends Block{
|
|||||||
topRegion = Draw.region(name + "-turret");
|
topRegion = Draw.region(name + "-turret");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStats(){
|
||||||
|
super.setStats();
|
||||||
|
stats.add(BlockStat.powerUse, powerPerEvent * 60f, StatUnit.powerSecond);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawSelect(Tile tile){
|
public void drawSelect(Tile tile){
|
||||||
Draw.color(Palette.accent);
|
Draw.color(Palette.accent);
|
||||||
@@ -83,17 +93,22 @@ public class RepairPoint extends Block{
|
|||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
RepairPointEntity entity = tile.entity();
|
RepairPointEntity entity = tile.entity();
|
||||||
|
|
||||||
|
boolean targetIsBeingRepaired = false;
|
||||||
if(entity.target != null && (entity.target.isDead() || entity.target.distanceTo(tile) > repairRadius ||
|
if(entity.target != null && (entity.target.isDead() || entity.target.distanceTo(tile) > repairRadius ||
|
||||||
entity.target.health >= entity.target.maxHealth())){
|
entity.target.health >= entity.target.maxHealth())){
|
||||||
entity.target = null;
|
entity.target = null;
|
||||||
}else if(entity.target != null){
|
}else if(entity.target != null){
|
||||||
entity.target.health += repairSpeed * Timers.delta() * entity.strength;
|
float relativeConsumption = powerPerEvent / consumePower.powerCapacity;
|
||||||
entity.target.clampHealth();
|
if(entity.power.satisfaction > 0.0f){
|
||||||
// TODO: Make it use power here and reset power once target goes null
|
entity.target.health += repairSpeed * Timers.delta() * entity.strength * Mathf.clamp(entity.power.satisfaction / relativeConsumption);
|
||||||
entity.rotation = Mathf.slerpDelta(entity.rotation, entity.angleTo(entity.target), 0.5f);
|
entity.target.clampHealth();
|
||||||
|
entity.rotation = Mathf.slerpDelta(entity.rotation, entity.angleTo(entity.target), 0.5f);
|
||||||
|
entity.power.satisfaction -= Math.min(entity.power.satisfaction, relativeConsumption);
|
||||||
|
targetIsBeingRepaired = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.target != null && entity.cons.valid()){
|
if(entity.target != null && targetIsBeingRepaired){
|
||||||
entity.strength = Mathf.lerpDelta(entity.strength, 1f, 0.08f * Timers.delta());
|
entity.strength = Mathf.lerpDelta(entity.strength, 1f, 0.08f * Timers.delta());
|
||||||
}else{
|
}else{
|
||||||
entity.strength = Mathf.lerpDelta(entity.strength, 0f, 0.07f * Timers.delta());
|
entity.strength = Mathf.lerpDelta(entity.strength, 0f, 0.07f * Timers.delta());
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class ConsumePower extends Consume{
|
|||||||
/** The maximum amount of power which can be processed per tick. This might influence efficiency or load a buffer. */
|
/** The maximum amount of power which can be processed per tick. This might influence efficiency or load a buffer. */
|
||||||
protected final float powerPerTick;
|
protected final float powerPerTick;
|
||||||
/** The minimum power satisfaction (fraction of powerPerTick) which must be achieved before the module may work. */
|
/** The minimum power satisfaction (fraction of powerPerTick) which must be achieved before the module may work. */
|
||||||
protected final float minimumSatisfaction;
|
public final float minimumSatisfaction;
|
||||||
/** The maximum power capacity in power units. */
|
/** The maximum power capacity in power units. */
|
||||||
public final float powerCapacity;
|
public final float powerCapacity;
|
||||||
/** True if the module can store power. */
|
/** True if the module can store power. */
|
||||||
@@ -64,7 +64,6 @@ public class ConsumePower extends Consume{
|
|||||||
@Override
|
@Override
|
||||||
public boolean valid(Block block, TileEntity entity){
|
public boolean valid(Block block, TileEntity entity){
|
||||||
if(isBuffered){
|
if(isBuffered){
|
||||||
// TODO - Verify: It might be necessary to know about the power required per shot/event here.
|
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
return entity.power.satisfaction >= minimumSatisfaction;
|
return entity.power.satisfaction >= minimumSatisfaction;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class Consumers{
|
|||||||
*/
|
*/
|
||||||
public ConsumePower powerBuffered(float powerCapacity){
|
public ConsumePower powerBuffered(float powerCapacity){
|
||||||
// TODO Balance: How long should it take to fill a buffer? The lower this value, the more power will be "stolen" from direct consumers.
|
// TODO Balance: How long should it take to fill a buffer? The lower this value, the more power will be "stolen" from direct consumers.
|
||||||
return powerBuffered(powerCapacity, 60);
|
return powerBuffered(powerCapacity, 60f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user