Building tile referernce cleanup
This commit is contained in:
@@ -106,7 +106,7 @@ public class LaserTurret extends PowerTurret{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void bullet(BulletType type, float angle){
|
protected void bullet(BulletType type, float angle){
|
||||||
bullet = type.create(tile.build, team, x + tr.x, y + tr.y, angle);
|
bullet = type.create(this, team, x + tr.x, y + tr.y, angle);
|
||||||
bulletLife = shootDuration;
|
bulletLife = shootDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import arc.graphics.g2d.*;
|
|||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
|
import mindustry.core.*;
|
||||||
import mindustry.entities.*;
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.bullet.*;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
@@ -100,13 +101,14 @@ public class LiquidTurret extends Turret{
|
|||||||
@Override
|
@Override
|
||||||
protected void findTarget(){
|
protected void findTarget(){
|
||||||
if(extinguish && liquids.current().canExtinguish()){
|
if(extinguish && liquids.current().canExtinguish()){
|
||||||
|
int tx = World.toTile(x), ty = World.toTile(y);
|
||||||
Fire result = null;
|
Fire result = null;
|
||||||
float mindst = 0f;
|
float mindst = 0f;
|
||||||
int tr = (int)(range / tilesize);
|
int tr = (int)(range / tilesize);
|
||||||
for(int x = -tr; x <= tr; x++){
|
for(int x = -tr; x <= tr; x++){
|
||||||
for(int y = -tr; y <= tr; y++){
|
for(int y = -tr; y <= tr; y++){
|
||||||
Tile other = world.tile(x + tile.x, y + tile.y);
|
Tile other = world.tile(x + tx, y + ty);
|
||||||
var fire = Fires.get(x + tile.x, y + tile.y);
|
var fire = Fires.get(x + tx, y + ty);
|
||||||
float dst = fire == null ? 0 : dst2(fire);
|
float dst = fire == null ? 0 : dst2(fire);
|
||||||
//do not extinguish fires on other team blocks
|
//do not extinguish fires on other team blocks
|
||||||
if(other != null && fire != null && Fires.has(other.x, other.y) && dst <= range * range && (result == null || dst < mindst) && (other.build == null || other.team() == team)){
|
if(other != null && fire != null && Fires.has(other.x, other.y) && dst <= range * range && (result == null || dst < mindst) && (other.build == null || other.team() == team)){
|
||||||
|
|||||||
@@ -163,8 +163,8 @@ public class Conveyor extends Block implements Autotiler{
|
|||||||
tr2.trns(rotation * 90, -tilesize / 2f, xs[i] * tilesize / 2f);
|
tr2.trns(rotation * 90, -tilesize / 2f, xs[i] * tilesize / 2f);
|
||||||
|
|
||||||
Draw.rect(item.fullIcon,
|
Draw.rect(item.fullIcon,
|
||||||
(tile.x * tilesize + tr1.x * ys[i] + tr2.x),
|
(x + tr1.x * ys[i] + tr2.x),
|
||||||
(tile.y * tilesize + tr1.y * ys[i] + tr2.y),
|
(y + tr1.y * ys[i] + tr2.y),
|
||||||
itemSize, itemSize);
|
itemSize, itemSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ public class MassDriver extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//align to shooter rotation
|
//align to shooter rotation
|
||||||
rotation = Angles.moveToward(rotation, tile.angleTo(currentShooter()), rotateSpeed * efficiency());
|
rotation = Angles.moveToward(rotation, angleTo(currentShooter()), rotateSpeed * efficiency());
|
||||||
}else if(state == DriverState.shooting){
|
}else if(state == DriverState.shooting){
|
||||||
//if there's nothing to shoot at OR someone wants to shoot at this thing, bail
|
//if there's nothing to shoot at OR someone wants to shoot at this thing, bail
|
||||||
if(!hasLink || (!waitingShooters.isEmpty() && (itemCapacity - items.total() >= minDistribute))){
|
if(!hasLink || (!waitingShooters.isEmpty() && (itemCapacity - items.total() >= minDistribute))){
|
||||||
@@ -173,7 +173,7 @@ public class MassDriver extends Block{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float targetRotation = tile.angleTo(link);
|
float targetRotation = angleTo(link);
|
||||||
|
|
||||||
if(
|
if(
|
||||||
items.total() >= minDistribute && //must shoot minimum amount of items
|
items.total() >= minDistribute && //must shoot minimum amount of items
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class MessageBlock extends Block{
|
|||||||
dialog.hide();
|
dialog.hide();
|
||||||
}).size(130f, 60f);
|
}).size(130f, 60f);
|
||||||
dialog.update(() -> {
|
dialog.update(() -> {
|
||||||
if(tile.block() != MessageBlock.this){
|
if(tile.build != this){
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ public class BuildPayload implements Payload{
|
|||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
drawShadow(1f);
|
drawShadow(1f);
|
||||||
|
//build.draw(); //TODO broken for blocks that change layers, such as conveyors, but would be nice...
|
||||||
Draw.rect(build.block.fullIcon, build.x, build.y);
|
Draw.rect(build.block.fullIcon, build.x, build.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ public class PayloadMassDriver extends PayloadBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//align to shooter rotation
|
//align to shooter rotation
|
||||||
turretRotation = Angles.moveToward(turretRotation, tile.angleTo(currentShooter()), rotateSpeed * efficiency());
|
turretRotation = Angles.moveToward(turretRotation, angleTo(currentShooter()), rotateSpeed * efficiency());
|
||||||
}else if(state == shooting){
|
}else if(state == shooting){
|
||||||
//if there's nothing to shoot at OR someone wants to shoot at this thing, bail
|
//if there's nothing to shoot at OR someone wants to shoot at this thing, bail
|
||||||
if(!hasLink || (!waitingShooters.isEmpty() && payload == null)){
|
if(!hasLink || (!waitingShooters.isEmpty() && payload == null)){
|
||||||
@@ -241,7 +241,7 @@ public class PayloadMassDriver extends PayloadBlock{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float targetRotation = tile.angleTo(link);
|
float targetRotation = angleTo(link);
|
||||||
boolean movedOut = false;
|
boolean movedOut = false;
|
||||||
|
|
||||||
payRotation = Angles.moveToward(payRotation, turretRotation, payloadRotateSpeed * delta());
|
payRotation = Angles.moveToward(payRotation, turretRotation, payloadRotateSpeed * delta());
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public class ImpactReactor extends PowerGenerator{
|
|||||||
|
|
||||||
if(warmup < 0.3f || !state.rules.reactorExplosions) return;
|
if(warmup < 0.3f || !state.rules.reactorExplosions) return;
|
||||||
|
|
||||||
Sounds.explosionbig.at(tile);
|
Sounds.explosionbig.at(this);
|
||||||
|
|
||||||
Damage.damage(x, y, explosionRadius * tilesize, explosionDamage * 4);
|
Damage.damage(x, y, explosionRadius * tilesize, explosionDamage * 4);
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ public class NuclearReactor extends PowerGenerator{
|
|||||||
|
|
||||||
public class NuclearReactorBuild extends GeneratorBuild{
|
public class NuclearReactorBuild extends GeneratorBuild{
|
||||||
public float heat;
|
public float heat;
|
||||||
|
public float flash;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTile(){
|
public void updateTile(){
|
||||||
@@ -130,7 +131,7 @@ public class NuclearReactor extends PowerGenerator{
|
|||||||
public void onDestroyed(){
|
public void onDestroyed(){
|
||||||
super.onDestroyed();
|
super.onDestroyed();
|
||||||
|
|
||||||
Sounds.explosionbig.at(tile);
|
Sounds.explosionbig.at(this);
|
||||||
|
|
||||||
int fuel = items.get(consumes.<ConsumeItems>get(ConsumeType.item).items[0].item);
|
int fuel = items.get(consumes.<ConsumeItems>get(ConsumeType.item).items[0].item);
|
||||||
|
|
||||||
@@ -160,10 +161,9 @@ public class NuclearReactor extends PowerGenerator{
|
|||||||
Draw.rect(topRegion, x, y);
|
Draw.rect(topRegion, x, y);
|
||||||
|
|
||||||
if(heat > flashThreshold){
|
if(heat > flashThreshold){
|
||||||
float flash = 1f + ((heat - flashThreshold) / (1f - flashThreshold)) * 5.4f;
|
flash += (1f + ((heat - flashThreshold) / (1f - flashThreshold)) * 5.4f) * Time.delta;
|
||||||
flash += flash * Time.delta;
|
|
||||||
Draw.color(Color.red, Color.yellow, Mathf.absin(flash, 9f, 1f));
|
Draw.color(Color.red, Color.yellow, Mathf.absin(flash, 9f, 1f));
|
||||||
Draw.alpha(0.6f);
|
Draw.alpha(0.3f);
|
||||||
Draw.rect(lightsRegion, x, y);
|
Draw.rect(lightsRegion, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -243,6 +243,11 @@ public class Drill extends Block{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pickedUp(){
|
||||||
|
dominantItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProximityUpdate(){
|
public void onProximityUpdate(){
|
||||||
super.onProximityUpdate();
|
super.onProximityUpdate();
|
||||||
|
|||||||
@@ -97,9 +97,9 @@ public class CommandCenter extends Block{
|
|||||||
float size = 6f;
|
float size = 6f;
|
||||||
|
|
||||||
Draw.color(bottomColor);
|
Draw.color(bottomColor);
|
||||||
Draw.rect(commandRegions[team.data().command.ordinal()].getRegion(), tile.drawx(), tile.drawy() - 1, size, size);
|
Draw.rect(commandRegions[team.data().command.ordinal()].getRegion(), x, y - 1, size, size);
|
||||||
Draw.color(topColor == null ? team.color : topColor);
|
Draw.color(topColor == null ? team.color : topColor);
|
||||||
Draw.rect(commandRegions[team.data().command.ordinal()].getRegion(), tile.drawx(), tile.drawy(), size, size);
|
Draw.rect(commandRegions[team.data().command.ordinal()].getRegion(), x, y, size, size);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ public class RepairPoint extends Block{
|
|||||||
multiplier = liq.valid(this) ? 1f + liquids.current().heatCapacity * coolantMultiplier : 1f;
|
multiplier = liq.valid(this) ? 1f + liquids.current().heatCapacity * coolantMultiplier : 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(target != null && (target.dead() || target.dst(tile) - target.hitSize/2f > repairRadius || target.health() >= target.maxHealth())){
|
if(target != null && (target.dead() || target.dst(this) - target.hitSize/2f > repairRadius || target.health() >= target.maxHealth())){
|
||||||
target = null;
|
target = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user