mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-26 06:22:17 -08:00
Building tile referernce cleanup
This commit is contained in:
parent
0acd339e33
commit
af3467035b
12 changed files with 26 additions and 18 deletions
|
|
@ -106,7 +106,7 @@ public class LaserTurret extends PowerTurret{
|
|||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import arc.graphics.g2d.*;
|
|||
import arc.struct.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.gen.*;
|
||||
|
|
@ -100,13 +101,14 @@ public class LiquidTurret extends Turret{
|
|||
@Override
|
||||
protected void findTarget(){
|
||||
if(extinguish && liquids.current().canExtinguish()){
|
||||
int tx = World.toTile(x), ty = World.toTile(y);
|
||||
Fire result = null;
|
||||
float mindst = 0f;
|
||||
int tr = (int)(range / tilesize);
|
||||
for(int x = -tr; x <= tr; x++){
|
||||
for(int y = -tr; y <= tr; y++){
|
||||
Tile other = world.tile(x + tile.x, y + tile.y);
|
||||
var fire = Fires.get(x + tile.x, y + tile.y);
|
||||
Tile other = world.tile(x + tx, y + ty);
|
||||
var fire = Fires.get(x + tx, y + ty);
|
||||
float dst = fire == null ? 0 : dst2(fire);
|
||||
//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)){
|
||||
|
|
|
|||
|
|
@ -163,8 +163,8 @@ public class Conveyor extends Block implements Autotiler{
|
|||
tr2.trns(rotation * 90, -tilesize / 2f, xs[i] * tilesize / 2f);
|
||||
|
||||
Draw.rect(item.fullIcon,
|
||||
(tile.x * tilesize + tr1.x * ys[i] + tr2.x),
|
||||
(tile.y * tilesize + tr1.y * ys[i] + tr2.y),
|
||||
(x + tr1.x * ys[i] + tr2.x),
|
||||
(y + tr1.y * ys[i] + tr2.y),
|
||||
itemSize, itemSize);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ public class MassDriver extends Block{
|
|||
}
|
||||
|
||||
//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){
|
||||
//if there's nothing to shoot at OR someone wants to shoot at this thing, bail
|
||||
if(!hasLink || (!waitingShooters.isEmpty() && (itemCapacity - items.total() >= minDistribute))){
|
||||
|
|
@ -173,7 +173,7 @@ public class MassDriver extends Block{
|
|||
return;
|
||||
}
|
||||
|
||||
float targetRotation = tile.angleTo(link);
|
||||
float targetRotation = angleTo(link);
|
||||
|
||||
if(
|
||||
items.total() >= minDistribute && //must shoot minimum amount of items
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ public class MessageBlock extends Block{
|
|||
dialog.hide();
|
||||
}).size(130f, 60f);
|
||||
dialog.update(() -> {
|
||||
if(tile.block() != MessageBlock.this){
|
||||
if(tile.build != this){
|
||||
dialog.hide();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ public class BuildPayload implements Payload{
|
|||
@Override
|
||||
public void draw(){
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ public class PayloadMassDriver extends PayloadBlock{
|
|||
}
|
||||
|
||||
//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){
|
||||
//if there's nothing to shoot at OR someone wants to shoot at this thing, bail
|
||||
if(!hasLink || (!waitingShooters.isEmpty() && payload == null)){
|
||||
|
|
@ -241,7 +241,7 @@ public class PayloadMassDriver extends PayloadBlock{
|
|||
return;
|
||||
}
|
||||
|
||||
float targetRotation = tile.angleTo(link);
|
||||
float targetRotation = angleTo(link);
|
||||
boolean movedOut = false;
|
||||
|
||||
payRotation = Angles.moveToward(payRotation, turretRotation, payloadRotateSpeed * delta());
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ public class ImpactReactor extends PowerGenerator{
|
|||
|
||||
if(warmup < 0.3f || !state.rules.reactorExplosions) return;
|
||||
|
||||
Sounds.explosionbig.at(tile);
|
||||
Sounds.explosionbig.at(this);
|
||||
|
||||
Damage.damage(x, y, explosionRadius * tilesize, explosionDamage * 4);
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ public class NuclearReactor extends PowerGenerator{
|
|||
|
||||
public class NuclearReactorBuild extends GeneratorBuild{
|
||||
public float heat;
|
||||
public float flash;
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
|
|
@ -130,7 +131,7 @@ public class NuclearReactor extends PowerGenerator{
|
|||
public void onDestroyed(){
|
||||
super.onDestroyed();
|
||||
|
||||
Sounds.explosionbig.at(tile);
|
||||
Sounds.explosionbig.at(this);
|
||||
|
||||
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);
|
||||
|
||||
if(heat > flashThreshold){
|
||||
float flash = 1f + ((heat - flashThreshold) / (1f - flashThreshold)) * 5.4f;
|
||||
flash += flash * Time.delta;
|
||||
flash += (1f + ((heat - flashThreshold) / (1f - flashThreshold)) * 5.4f) * Time.delta;
|
||||
Draw.color(Color.red, Color.yellow, Mathf.absin(flash, 9f, 1f));
|
||||
Draw.alpha(0.6f);
|
||||
Draw.alpha(0.3f);
|
||||
Draw.rect(lightsRegion, x, y);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -243,6 +243,11 @@ public class Drill extends Block{
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pickedUp(){
|
||||
dominantItem = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProximityUpdate(){
|
||||
super.onProximityUpdate();
|
||||
|
|
|
|||
|
|
@ -97,9 +97,9 @@ public class CommandCenter extends Block{
|
|||
float size = 6f;
|
||||
|
||||
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.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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ public class RepairPoint extends Block{
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue