mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
Changed BlockPlan#block to Block
This commit is contained in:
parent
4648371383
commit
aadb994bdc
@ -258,7 +258,7 @@ public class BaseBuilderAI{
|
||||
|
||||
//queue it
|
||||
for(Stile tile : result.tiles){
|
||||
data.plans.add(new BlockPlan(cx + tile.x, cy + tile.y, tile.rotation, tile.block.id, tile.config));
|
||||
data.plans.add(new BlockPlan(cx + tile.x, cy + tile.y, tile.rotation, tile.block, tile.config));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -179,12 +179,12 @@ public class BuilderAI extends AIController{
|
||||
BlockPlan block = blocks.first();
|
||||
|
||||
//check if it's already been placed
|
||||
if(world.tile(block.x, block.y) != null && world.tile(block.x, block.y).block().id == block.block){
|
||||
if(world.tile(block.x, block.y) != null && world.tile(block.x, block.y).block() == block.block){
|
||||
blocks.removeFirst();
|
||||
}else if(Build.validPlace(content.block(block.block), unit.team(), block.x, block.y, block.rotation) && (!alwaysFlee || !nearEnemy(block.x, block.y))){ //it's valid
|
||||
}else if(Build.validPlace(block.block, unit.team(), block.x, block.y, block.rotation) && (!alwaysFlee || !nearEnemy(block.x, block.y))){ //it's valid
|
||||
lastPlan = block;
|
||||
//add build plan
|
||||
unit.addBuild(new BuildPlan(block.x, block.y, block.rotation, content.block(block.block), block.config));
|
||||
unit.addBuild(new BuildPlan(block.x, block.y, block.rotation, block.block, block.config));
|
||||
//shift build plan to tail so next unit builds something else
|
||||
blocks.addLast(blocks.removeFirst());
|
||||
}else{
|
||||
|
@ -4923,6 +4923,92 @@ public class Blocks{
|
||||
abilities.add(new ForceFieldAbility(30f, 0f, 160f, 999999999f));
|
||||
|
||||
}};
|
||||
}},
|
||||
|
||||
//TODO finish this
|
||||
Items.surgeAlloy, new BulletType(){{
|
||||
shootEffect = Fx.shootBig;
|
||||
smokeEffect = Fx.shootSmokeMissile;
|
||||
ammoMultiplier = 1f;
|
||||
|
||||
spawnUnit = new MissileUnitType("scathe-missile-surge"){{
|
||||
speed = 4.6f;
|
||||
maxRange = 6f;
|
||||
lifetime = 60f * 5.5f;
|
||||
outlineColor = Pal.darkOutline;
|
||||
engineColor = trailColor = Pal.redLight;
|
||||
engineLayer = Layer.effect;
|
||||
engineSize = 3.1f;
|
||||
engineOffset = 10f;
|
||||
rotateSpeed = 0.25f;
|
||||
trailLength = 18;
|
||||
missileAccelTime = 50f;
|
||||
lowAltitude = true;
|
||||
loopSound = Sounds.missileTrail;
|
||||
loopSoundVolume = 0.6f;
|
||||
deathSound = Sounds.largeExplosion;
|
||||
targetAir = false;
|
||||
targetUnderBlocks = false;
|
||||
|
||||
fogRadius = 6f;
|
||||
|
||||
health = 210;
|
||||
|
||||
weapons.add(new Weapon(){{
|
||||
shootCone = 360f;
|
||||
mirror = false;
|
||||
reload = 1f;
|
||||
deathExplosionEffect = Fx.massiveExplosion;
|
||||
shootOnDeath = true;
|
||||
shake = 10f;
|
||||
bullet = new ExplosionBulletType(1500f, 65f){{
|
||||
hitColor = Pal.redLight;
|
||||
shootEffect = new MultiEffect(Fx.massiveExplosion, Fx.scatheExplosion, Fx.scatheLight, new WaveEffect(){{
|
||||
lifetime = 10f;
|
||||
strokeFrom = 4f;
|
||||
sizeTo = 130f;
|
||||
}});
|
||||
|
||||
collidesAir = false;
|
||||
buildingDamageMultiplier = 0.25f;
|
||||
|
||||
ammoMultiplier = 1f;
|
||||
fragLifeMin = 0.1f;
|
||||
fragBullets = 7;
|
||||
fragBullet = new ArtilleryBulletType(3.4f, 32){{
|
||||
buildingDamageMultiplier = 0.3f;
|
||||
drag = 0.02f;
|
||||
hitEffect = Fx.massiveExplosion;
|
||||
despawnEffect = Fx.scatheSlash;
|
||||
knockback = 0.8f;
|
||||
lifetime = 23f;
|
||||
width = height = 18f;
|
||||
collidesTiles = false;
|
||||
splashDamageRadius = 40f;
|
||||
splashDamage = 160f;
|
||||
backColor = trailColor = hitColor = Pal.redLight;
|
||||
frontColor = Color.white;
|
||||
smokeEffect = Fx.shootBigSmoke2;
|
||||
despawnShake = 7f;
|
||||
lightRadius = 30f;
|
||||
lightColor = Pal.redLight;
|
||||
lightOpacity = 0.5f;
|
||||
|
||||
trailLength = 20;
|
||||
trailWidth = 3.5f;
|
||||
trailEffect = Fx.none;
|
||||
}};
|
||||
}};
|
||||
}});
|
||||
|
||||
abilities.add(new MoveEffectAbility(){{
|
||||
effect = Fx.missileTrailSmoke;
|
||||
rotation = 180f;
|
||||
y = -9f;
|
||||
color = Color.grays(0.6f).lerp(Pal.redLight, 0.5f).a(0.4f);
|
||||
interval = 7f;
|
||||
}});
|
||||
}};
|
||||
}}
|
||||
);
|
||||
|
||||
|
@ -458,7 +458,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
for(var plan : state.rules.waveTeam.data().plans){
|
||||
Tile tile = world.tile(plan.x, plan.y);
|
||||
if(tile != null){
|
||||
tile.setBlock(content.block(plan.block), state.rules.waveTeam, plan.rotation);
|
||||
tile.setBlock(plan.block, state.rules.waveTeam, plan.rotation);
|
||||
if(plan.config != null && tile.build != null){
|
||||
tile.build.configureAny(plan.config);
|
||||
}
|
||||
|
@ -210,8 +210,7 @@ public class Logic implements ApplicationListener{
|
||||
var bounds = tile.block().bounds(tile.x, tile.y, Tmp.r1);
|
||||
while(it.hasNext()){
|
||||
BlockPlan b = it.next();
|
||||
Block block = content.block(b.block);
|
||||
if(bounds.overlaps(block.bounds(b.x, b.y, Tmp.r2))){
|
||||
if(bounds.overlaps(b.block.bounds(b.x, b.y, Tmp.r2))){
|
||||
b.removed = true;
|
||||
it.remove();
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
}
|
||||
}
|
||||
|
||||
data.plans.addFirst(new BlockPlan(tile.x, tile.y, (short)rotation, toAdd.id, overrideConfig == null ? config() : overrideConfig));
|
||||
data.plans.addFirst(new BlockPlan(tile.x, tile.y, (short)rotation, toAdd, overrideConfig == null ? config() : overrideConfig));
|
||||
}
|
||||
|
||||
public @Nullable Tile findClosestEdge(Position to, Boolf<Tile> solid){
|
||||
|
@ -435,11 +435,12 @@ public class Teams{
|
||||
/** Represents a block made by this team that was destroyed somewhere on the map.
|
||||
* This does not include deconstructed blocks.*/
|
||||
public static class BlockPlan{
|
||||
public final short x, y, rotation, block;
|
||||
public final short x, y, rotation;
|
||||
public final Block block;
|
||||
public final Object config;
|
||||
public boolean removed;
|
||||
|
||||
public BlockPlan(int x, int y, short rotation, short block, Object config){
|
||||
public BlockPlan(int x, int y, short rotation, Block block, Object config){
|
||||
this.x = (short)x;
|
||||
this.y = (short)y;
|
||||
this.rotation = rotation;
|
||||
|
@ -274,7 +274,7 @@ public class BlockRenderer{
|
||||
|
||||
if(brokenFade > 0.001f){
|
||||
for(BlockPlan block : player.team().data().plans){
|
||||
Block b = content.block(block.block);
|
||||
Block b = block.block;
|
||||
if(!camera.bounds(Tmp.r1).grow(tilesize * 2f).overlaps(Tmp.r2.setSize(b.size * tilesize).setCenter(block.x * tilesize + b.offset, block.y * tilesize + b.offset))) continue;
|
||||
|
||||
Draw.alpha(0.33f * brokenFade);
|
||||
|
@ -1441,9 +1441,9 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
for(BlockPlan plan : player.team().data().plans){
|
||||
Block block = content.block(plan.block);
|
||||
Block block = plan.block;
|
||||
if(block.bounds(plan.x, plan.y, Tmp.r2).overlaps(Tmp.r1)){
|
||||
drawSelected(plan.x, plan.y, content.block(plan.block), Pal.remove);
|
||||
drawSelected(plan.x, plan.y, plan.block, Pal.remove);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1463,9 +1463,9 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
Tmp.r1.set(result.x, result.y, result.x2 - result.x, result.y2 - result.y);
|
||||
|
||||
for(BlockPlan plan : player.team().data().plans){
|
||||
Block block = content.block(plan.block);
|
||||
Block block = plan.block;
|
||||
if(block.bounds(plan.x, plan.y, Tmp.r2).overlaps(Tmp.r1)){
|
||||
drawSelected(plan.x, plan.y, content.block(plan.block), Pal.sapBullet);
|
||||
drawSelected(plan.x, plan.y, plan.block, Pal.sapBullet);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1629,7 +1629,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
Iterator<BlockPlan> broken = player.team().data().plans.iterator();
|
||||
while(broken.hasNext()){
|
||||
BlockPlan plan = broken.next();
|
||||
Block block = content.block(plan.block);
|
||||
Block block = plan.block;
|
||||
if(block.bounds(plan.x, plan.y, Tmp.r2).overlaps(Tmp.r1)){
|
||||
removed.add(Point2.pack(plan.x, plan.y));
|
||||
plan.removed = true;
|
||||
@ -2000,9 +2000,9 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
Iterator<BlockPlan> broken = player.team().data().plans.iterator();
|
||||
while(broken.hasNext()){
|
||||
BlockPlan plan = broken.next();
|
||||
Block block = content.block(plan.block);
|
||||
Block block = plan.block;
|
||||
if(block.bounds(plan.x, plan.y, Tmp.r2).overlaps(Tmp.r1)){
|
||||
player.unit().addBuild(new BuildPlan(plan.x, plan.y, plan.rotation, content.block(plan.block), plan.config));
|
||||
player.unit().addBuild(new BuildPlan(plan.x, plan.y, plan.rotation, plan.block, plan.config));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -368,7 +368,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
||||
stream.writeShort(block.x);
|
||||
stream.writeShort(block.y);
|
||||
stream.writeShort(block.rotation);
|
||||
stream.writeShort(block.block);
|
||||
stream.writeShort(block.block.id);
|
||||
TypeIO.writeObject(Writes.get(stream), block.config);
|
||||
}
|
||||
}
|
||||
@ -426,7 +426,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
||||
var obj = TypeIO.readObject(reads);
|
||||
//cannot have two in the same position
|
||||
if(set.add(Point2.pack(x, y))){
|
||||
data.plans.addLast(new BlockPlan(x, y, rot, content.block(bid).id, obj));
|
||||
data.plans.addLast(new BlockPlan(x, y, rot, content.block(bid), obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class Save3 extends LegacySaveVersion{
|
||||
TeamData data = team.data();
|
||||
int blocks = stream.readInt();
|
||||
for(int j = 0; j < blocks; j++){
|
||||
data.plans.addLast(new BlockPlan(stream.readShort(), stream.readShort(), stream.readShort(), content.block(stream.readShort()).id, stream.readInt()));
|
||||
data.plans.addLast(new BlockPlan(stream.readShort(), stream.readShort(), stream.readShort(), content.block(stream.readShort()), stream.readInt()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,10 +146,10 @@ public class BuildTurret extends BaseTurret{
|
||||
for(int i = 0; i < blocks.size; i++){
|
||||
var block = blocks.get(i);
|
||||
if(within(block.x * tilesize, block.y * tilesize, range)){
|
||||
var btype = content.block(block.block);
|
||||
var btype = block.block;
|
||||
|
||||
if(Build.validPlace(btype, unit.team(), block.x, block.y, block.rotation) && (state.rules.infiniteResources || team.rules().infiniteResources || team.items().has(btype.requirements, state.rules.buildCostMultiplier))){
|
||||
unit.addBuild(new BuildPlan(block.x, block.y, block.rotation, content.block(block.block), block.config));
|
||||
unit.addBuild(new BuildPlan(block.x, block.y, block.rotation, block.block, block.config));
|
||||
//shift build plan to tail so next unit builds something else
|
||||
blocks.addLast(blocks.removeIndex(i));
|
||||
lastPlan = block;
|
||||
|
Loading…
Reference in New Issue
Block a user