mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-05 16:37:38 +07:00
- Resolved all remaining TODOs
This commit is contained in:
parent
982c9bf964
commit
14e057cf05
@ -83,7 +83,6 @@ public class DefenseBlocks extends BlockList implements ContentList{
|
||||
}};
|
||||
|
||||
forceProjector = new ForceProjector("force-projector"){{
|
||||
consumes.powerDirect(0.2f);
|
||||
size = 3;
|
||||
consumes.item(Items.phasefabric).optional(true);
|
||||
}};
|
||||
|
@ -43,6 +43,7 @@ public class PowerBlocks extends BlockList implements ContentList{
|
||||
}};
|
||||
|
||||
largeSolarPanel = new SolarGenerator("solar-panel-large"){{
|
||||
size = 3;
|
||||
powerProduction = 0.055f;
|
||||
}};
|
||||
|
||||
|
@ -11,6 +11,7 @@ import io.anuke.mindustry.world.BarType;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
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.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
@ -41,9 +42,12 @@ public class ForceProjector extends Block {
|
||||
protected float cooldownNormal = 1.75f;
|
||||
protected float cooldownLiquid = 1.5f;
|
||||
protected float cooldownBrokenBase = 0.35f;
|
||||
protected float basePowerDraw = 0.2f;
|
||||
protected float powerDamage = 0.1f;
|
||||
protected final ConsumePower consumePower;
|
||||
protected TextureRegion topRegion;
|
||||
|
||||
|
||||
public ForceProjector(String name) {
|
||||
super(name);
|
||||
update = true;
|
||||
@ -54,7 +58,7 @@ public class ForceProjector extends Block {
|
||||
hasItems = true;
|
||||
itemCapacity = 10;
|
||||
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
|
||||
@ -67,6 +71,7 @@ public class ForceProjector extends Block {
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
stats.add(BlockStat.powerUse, basePowerDraw * 60f, StatUnit.powerSecond);
|
||||
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));
|
||||
}
|
||||
|
||||
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);
|
||||
if(entity.warmup <= 0.09f){
|
||||
entity.broken = true;
|
||||
}
|
||||
}else{
|
||||
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, 0.1f);
|
||||
// TODO Adapt power calculations to new power system
|
||||
// float powerUse = Math.min(powerDamage * entity.delta() * (1f + entity.buildup / breakage), powerCapacity);
|
||||
// entity.power.amount -= powerUse;
|
||||
float relativePowerDraw = powerDamage * entity.delta() * (1f + entity.buildup / breakage) / consumePower.powerCapacity;
|
||||
entity.power.satisfaction -= Math.min(relativePowerDraw, entity.power.satisfaction);
|
||||
}
|
||||
|
||||
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())){
|
||||
trait.absorb();
|
||||
Effects.effect(BulletFx.absorb, trait);
|
||||
float hit = trait.getShieldDamage()*powerDamage;
|
||||
float relativePowerDraw = trait.getShieldDamage() * powerDamage / consumePower.powerCapacity;
|
||||
entity.hit = 1f;
|
||||
// TODO Adapt power calculations to new power system
|
||||
// entity.power.amount -= Math.min(hit, entity.power.amount);
|
||||
//
|
||||
// if(entity.power.amount <= 0.0001f){
|
||||
// entity.buildup += trait.getShieldDamage() * entity.warmup*2f;
|
||||
// }
|
||||
|
||||
entity.power.satisfaction -= Math.min(relativePowerDraw, entity.power.satisfaction);
|
||||
if(entity.power.satisfaction <= 0.0001f){
|
||||
entity.buildup += trait.getShieldDamage() * entity.warmup * 2f;
|
||||
}
|
||||
entity.buildup += trait.getShieldDamage() * entity.warmup;
|
||||
}
|
||||
});
|
||||
|
@ -37,7 +37,6 @@ import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
// TODO Adapt whole class to new power system
|
||||
public class MassDriver extends Block{
|
||||
protected float range;
|
||||
protected float rotateSpeed = 0.04f;
|
||||
@ -49,7 +48,7 @@ public class MassDriver extends Block{
|
||||
protected Effect smokeEffect = ShootFx.shootBigSmoke2;
|
||||
protected Effect recieveEffect = BlockFx.mineBig;
|
||||
protected float shake = 3f;
|
||||
protected final static float powerPercentageUsed = 0.8f;
|
||||
protected final static float powerPercentageUsed = 1.0f;
|
||||
protected TextureRegion turretRegion;
|
||||
|
||||
public MassDriver(String name){
|
||||
@ -171,8 +170,8 @@ public class MassDriver extends Block{
|
||||
|
||||
entity.rotation = Mathf.slerpDelta(entity.rotation, tile.angleTo(waiter), rotateSpeed);
|
||||
}else if(tile.entity.items.total() >= minDistribute &&
|
||||
linkValid(tile) && //only fire when at least at 80% power capacity
|
||||
tile.entity.power.satisfaction > powerPercentageUsed &&
|
||||
linkValid(tile) && //only fire when at 100% power capacity
|
||||
tile.entity.power.satisfaction >= powerPercentageUsed &&
|
||||
link.block().itemCapacity - link.entity.items.total() >= minDistribute && entity.reload <= 0.0001f){
|
||||
|
||||
MassDriverEntity other = link.entity();
|
||||
|
@ -10,7 +10,10 @@ import io.anuke.mindustry.graphics.Layer;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
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.BlockStat;
|
||||
import io.anuke.mindustry.world.meta.StatUnit;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
@ -26,6 +29,8 @@ public class RepairPoint extends Block{
|
||||
|
||||
protected float repairRadius = 50f;
|
||||
protected float repairSpeed = 0.3f;
|
||||
protected float powerPerEvent = 0.06f;
|
||||
protected ConsumePower consumePower;
|
||||
|
||||
protected TextureRegion topRegion;
|
||||
|
||||
@ -37,8 +42,7 @@ public class RepairPoint extends Block{
|
||||
layer = Layer.turret;
|
||||
layer2 = Layer.laser;
|
||||
hasPower = true;
|
||||
// TODO Adapt to new power system - Make it use power while repairing
|
||||
consumes.powerBuffered(20f);
|
||||
consumePower = consumes.powerBuffered(20f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,6 +52,12 @@ public class RepairPoint extends Block{
|
||||
topRegion = Draw.region(name + "-turret");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
stats.add(BlockStat.powerUse, powerPerEvent * 60f, StatUnit.powerSecond);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(Tile tile){
|
||||
Draw.color(Palette.accent);
|
||||
@ -83,17 +93,22 @@ public class RepairPoint extends Block{
|
||||
public void update(Tile tile){
|
||||
RepairPointEntity entity = tile.entity();
|
||||
|
||||
boolean targetIsBeingRepaired = false;
|
||||
if(entity.target != null && (entity.target.isDead() || entity.target.distanceTo(tile) > repairRadius ||
|
||||
entity.target.health >= entity.target.maxHealth())){
|
||||
entity.target = null;
|
||||
}else if(entity.target != null){
|
||||
entity.target.health += repairSpeed * Timers.delta() * entity.strength;
|
||||
float relativeConsumption = powerPerEvent / consumePower.powerCapacity;
|
||||
if(entity.power.satisfaction > 0.0f){
|
||||
entity.target.health += repairSpeed * Timers.delta() * entity.strength * Mathf.clamp(entity.power.satisfaction / relativeConsumption);
|
||||
entity.target.clampHealth();
|
||||
// TODO: Make it use power here and reset power once target goes null
|
||||
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());
|
||||
}else{
|
||||
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. */
|
||||
protected final float powerPerTick;
|
||||
/** 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. */
|
||||
public final float powerCapacity;
|
||||
/** True if the module can store power. */
|
||||
@ -64,7 +64,6 @@ public class ConsumePower extends Consume{
|
||||
@Override
|
||||
public boolean valid(Block block, TileEntity entity){
|
||||
if(isBuffered){
|
||||
// TODO - Verify: It might be necessary to know about the power required per shot/event here.
|
||||
return true;
|
||||
}else{
|
||||
return entity.power.satisfaction >= minimumSatisfaction;
|
||||
|
@ -63,7 +63,7 @@ public class Consumers{
|
||||
*/
|
||||
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.
|
||||
return powerBuffered(powerCapacity, 60);
|
||||
return powerBuffered(powerCapacity, 60f);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user