mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-09 15:27:45 +07:00
Heat turret support
This commit is contained in:
@ -33,6 +33,7 @@ import mindustry.world.*;
|
|||||||
import mindustry.world.blocks.ConstructBlock.*;
|
import mindustry.world.blocks.ConstructBlock.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
import mindustry.world.blocks.environment.*;
|
import mindustry.world.blocks.environment.*;
|
||||||
|
import mindustry.world.blocks.heat.*;
|
||||||
import mindustry.world.blocks.logic.LogicBlock.*;
|
import mindustry.world.blocks.logic.LogicBlock.*;
|
||||||
import mindustry.world.blocks.payloads.*;
|
import mindustry.world.blocks.payloads.*;
|
||||||
import mindustry.world.blocks.power.*;
|
import mindustry.world.blocks.power.*;
|
||||||
@ -40,6 +41,8 @@ import mindustry.world.consumers.*;
|
|||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
import mindustry.world.modules.*;
|
import mindustry.world.modules.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@EntityDef(value = {Buildingc.class}, isFinal = false, genio = false, serialize = false)
|
@EntityDef(value = {Buildingc.class}, isFinal = false, genio = false, serialize = false)
|
||||||
@ -281,6 +284,23 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float calculateHeat(float[] sideHeat){
|
||||||
|
Arrays.fill(sideHeat, 0f);
|
||||||
|
float heat = 0f;
|
||||||
|
|
||||||
|
for(var edge : block.getEdges()){
|
||||||
|
Building build = nearby(edge.x, edge.y);
|
||||||
|
if(build != null && build.team == team && build instanceof HeatBlock heater && (!build.block.rotate || (relativeTo(build) + 2) % 4 == build.rotation)){
|
||||||
|
//heat is distributed across building size
|
||||||
|
float add = heater.heat() / build.block.size;
|
||||||
|
|
||||||
|
sideHeat[Mathf.mod(relativeTo(build), 4)] += add;
|
||||||
|
heat += add;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return heat;
|
||||||
|
}
|
||||||
|
|
||||||
public void applyBoost(float intensity, float duration){
|
public void applyBoost(float intensity, float duration){
|
||||||
//do not refresh time scale when getting a weaker intensity
|
//do not refresh time scale when getting a weaker intensity
|
||||||
if(intensity >= this.timeScale - 0.001f){
|
if(intensity >= this.timeScale - 0.001f){
|
||||||
|
@ -176,7 +176,7 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
|
|||||||
tiles.getn(endX, endY).setOverlay(Blocks.spawn);
|
tiles.getn(endX, endY).setOverlay(Blocks.spawn);
|
||||||
|
|
||||||
//TODO tech is lazy and boring
|
//TODO tech is lazy and boring
|
||||||
tech(Blocks.darkPanel3, Blocks.darkPanel5, Blocks.darkMetal);
|
//tech(Blocks.darkPanel3, Blocks.darkPanel5, Blocks.darkMetal);
|
||||||
|
|
||||||
//ores
|
//ores
|
||||||
pass((x, y) -> {
|
pass((x, y) -> {
|
||||||
@ -234,7 +234,7 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
decoration(0.015f);
|
decoration(0.017f);
|
||||||
|
|
||||||
//not allowed
|
//not allowed
|
||||||
state.rules.hiddenBuildItems.addAll(Items.copper, Items.titanium, Items.coal, Items.lead, Items.blastCompound, Items.pyratite, Items.sporePod, Items.metaglass, Items.plastanium);
|
state.rules.hiddenBuildItems.addAll(Items.copper, Items.titanium, Items.coal, Items.lead, Items.blastCompound, Items.pyratite, Items.sporePod, Items.metaglass, Items.plastanium);
|
||||||
|
@ -22,6 +22,7 @@ import mindustry.gen.*;
|
|||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.logic.*;
|
import mindustry.logic.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
import mindustry.ui.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
import mindustry.world.draw.*;
|
import mindustry.world.draw.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
@ -56,6 +57,8 @@ public class Turret extends ReloadTurret{
|
|||||||
|
|
||||||
public int maxAmmo = 30;
|
public int maxAmmo = 30;
|
||||||
public int ammoPerShot = 1;
|
public int ammoPerShot = 1;
|
||||||
|
public float heatRequirement = -1f;
|
||||||
|
public float maxHeatEfficiency = 3f;
|
||||||
|
|
||||||
//TODO all the fields below should be deprecated and moved into a ShootPattern class or similar
|
//TODO all the fields below should be deprecated and moved into a ShootPattern class or similar
|
||||||
//TODO ...however, it would be nice to unify the weapon and turret systems into one.
|
//TODO ...however, it would be nice to unify the weapon and turret systems into one.
|
||||||
@ -143,6 +146,20 @@ public class Turret extends ReloadTurret{
|
|||||||
stats.add(Stat.targetsAir, targetAir);
|
stats.add(Stat.targetsAir, targetAir);
|
||||||
stats.add(Stat.targetsGround, targetGround);
|
stats.add(Stat.targetsGround, targetGround);
|
||||||
if(ammoPerShot != 1) stats.add(Stat.ammoUse, ammoPerShot, StatUnit.perShot);
|
if(ammoPerShot != 1) stats.add(Stat.ammoUse, ammoPerShot, StatUnit.perShot);
|
||||||
|
if(heatRequirement > 0) stats.add(Stat.input, heatRequirement, StatUnit.heatUnits);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBars(){
|
||||||
|
super.setBars();
|
||||||
|
|
||||||
|
if(heatRequirement > 0){
|
||||||
|
bars.add("heat", (TurretBuild entity) ->
|
||||||
|
new Bar(() ->
|
||||||
|
Core.bundle.format("bar.heatpercent", (int)entity.heatReq, (int)(Math.min(entity.heatReq / heatRequirement, maxHeatEfficiency) * 100)),
|
||||||
|
() -> Pal.lightOrange,
|
||||||
|
() -> entity.heatReq / heatRequirement));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -194,6 +211,9 @@ public class Turret extends ReloadTurret{
|
|||||||
public BlockUnitc unit = (BlockUnitc)UnitTypes.block.create(team);
|
public BlockUnitc unit = (BlockUnitc)UnitTypes.block.create(team);
|
||||||
public boolean wasShooting, charging;
|
public boolean wasShooting, charging;
|
||||||
|
|
||||||
|
public float heatReq;
|
||||||
|
public float[] sideHeat = new float[4];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float warmup(){
|
public float warmup(){
|
||||||
return shootWarmup;
|
return shootWarmup;
|
||||||
@ -324,6 +344,10 @@ public class Turret extends ReloadTurret{
|
|||||||
logicControlTime -= Time.delta;
|
logicControlTime -= Time.delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(heatRequirement > 0){
|
||||||
|
heatReq = calculateHeat(sideHeat);
|
||||||
|
}
|
||||||
|
|
||||||
//turret always reloads regardless of whether it's targeting something
|
//turret always reloads regardless of whether it's targeting something
|
||||||
updateReload();
|
updateReload();
|
||||||
|
|
||||||
@ -403,6 +427,14 @@ public class Turret extends ReloadTurret{
|
|||||||
return !charging;
|
return !charging;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float efficiency(){
|
||||||
|
if(heatRequirement > 0){
|
||||||
|
return Math.min(heatReq / heatRequirement, maxHeatEfficiency) * super.efficiency();
|
||||||
|
}
|
||||||
|
return super.efficiency();
|
||||||
|
}
|
||||||
|
|
||||||
/** Consume ammo and return a type. */
|
/** Consume ammo and return a type. */
|
||||||
public BulletType useAmmo(){
|
public BulletType useAmmo(){
|
||||||
if(cheating()) return peekAmmo();
|
if(cheating()) return peekAmmo();
|
||||||
|
@ -2,14 +2,10 @@ package mindustry.world.blocks.production;
|
|||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import mindustry.gen.*;
|
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.blocks.heat.*;
|
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/** A crafter that requires contact from heater blocks to craft. */
|
/** A crafter that requires contact from heater blocks to craft. */
|
||||||
public class HeatCrafter extends GenericCrafter{
|
public class HeatCrafter extends GenericCrafter{
|
||||||
/** Base heat requirement for 100% efficiency. */
|
/** Base heat requirement for 100% efficiency. */
|
||||||
@ -48,19 +44,8 @@ public class HeatCrafter extends GenericCrafter{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTile(){
|
public void updateTile(){
|
||||||
Arrays.fill(sideHeat, 0f);
|
heat = calculateHeat(sideHeat);
|
||||||
heat = 0f;
|
|
||||||
|
|
||||||
for(var edge : getEdges()){
|
|
||||||
Building build = nearby(edge.x, edge.y);
|
|
||||||
if(build != null && build.team == team && build instanceof HeatBlock heater && (!build.block.rotate || (relativeTo(build) + 2) % 4 == build.rotation)){
|
|
||||||
//heat is distributed across building size
|
|
||||||
float add = heater.heat() / build.block.size;
|
|
||||||
|
|
||||||
sideHeat[Mathf.mod(relativeTo(build), 4)] += add;
|
|
||||||
heat += add;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.updateTile();
|
super.updateTile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user