Fully implemented mass driver

This commit is contained in:
Anuken
2018-07-30 17:00:18 -04:00
parent e88ce078df
commit fe9b11e771
13 changed files with 853 additions and 851 deletions

View File

@@ -51,6 +51,7 @@ public class Recipes implements ContentList{
new Recipe(distribution, DistributionBlocks.sorter, new ItemStack(Items.carbide, 4), new ItemStack(Items.tungsten, 4));
new Recipe(distribution, DistributionBlocks.overflowGate, new ItemStack(Items.carbide, 4), new ItemStack(Items.tungsten, 8));
new Recipe(distribution, DistributionBlocks.bridgeConveyor, new ItemStack(Items.carbide, 8), new ItemStack(Items.tungsten, 8));
new Recipe(distribution, DistributionBlocks.massDriver, new ItemStack(Items.carbide, 400), new ItemStack(Items.silicon, 300), new ItemStack(Items.lead, 400), new ItemStack(Items.thorium, 250));
//CRAFTING
@@ -172,8 +173,6 @@ public class Recipes implements ContentList{
new Recipe(production, ProductionBlocks.oilextractor, new ItemStack(Items.titanium, 40), new ItemStack(Items.surgealloy, 40));*/
//new Recipe(distribution, DistributionBlocks.massDriver, new ItemStack(Items.carbide, 1));
/*

View File

@@ -50,7 +50,7 @@ public class DistributionBlocks extends BlockList implements ContentList{
massDriver = new MassDriver("mass-driver"){{
size = 3;
itemCapacity = 80;
range = 300f;
range = 340f;
}};
}
}

View File

@@ -179,7 +179,7 @@ public class TurretBullets extends BulletList implements ContentList{
}
};
driverBolt = new BulletType(5f, 20){
driverBolt = new BulletType(5f, 50){
{
collidesTiles = false;
lifetime = 200f;
@@ -190,11 +190,14 @@ public class TurretBullets extends BulletList implements ContentList{
@Override
public void draw(Bullet b){
Draw.color(Color.LIGHT_GRAY);
Fill.square(b.x, b.y, 3f, b.angle());
float w = 11f, h = 13f;
Draw.color(Palette.bulletYellowBack);
Draw.rect("shell-back", b.x, b.y, w, h, b.angle() + 90);
Draw.color(Palette.bulletYellow);
Draw.rect("shell", b.x, b.y, w, h, b.angle() + 90);
Draw.color(Palette.lighterOrange);
Fill.square(b.x, b.y, 2f, b.angle());
Draw.reset();
}

View File

@@ -45,34 +45,22 @@ public interface BuilderTrait extends Entity{
float placeDistance = 150f;
float mineDistance = 70f;
/**
* Returns the queue for storing build requests.
*/
/**Returns the queue for storing build requests.*/
Queue<BuildRequest> getPlaceQueue();
/**
* Returns the tile this builder is currently mining.
*/
/**Returns the tile this builder is currently mining.*/
Tile getMineTile();
/**
* Sets the tile this builder is currently mining.
*/
/**Sets the tile this builder is currently mining.*/
void setMineTile(Tile tile);
/**
* Returns the minining speed of this miner. 1 = standard, 0.5 = half speed, 2 = double speed, etc.
*/
/**Returns the minining speed of this miner. 1 = standard, 0.5 = half speed, 2 = double speed, etc.*/
float getMinePower();
/**
* Build power, can be any float. 1 = builds recipes in normal time, 0 = doesn't build at all.
*/
/**Build power, can be any float. 1 = builds recipes in normal time, 0 = doesn't build at all.*/
float getBuildPower(Tile tile);
/**
* Whether this type of builder can begin creating new blocks.
*/
/**Whether this type of builder can begin creating new blocks.*/
default boolean canCreateBlocks(){
return true;
}
@@ -120,9 +108,7 @@ public interface BuilderTrait extends Entity{
}
}
/**
* Return whether this builder's place queue contains items.
*/
/**Return whether this builder's place queue contains items.*/
default boolean isBuilding(){
return getPlaceQueue().size != 0;
}
@@ -145,16 +131,12 @@ public interface BuilderTrait extends Entity{
addBuildRequest(new BuildRequest(x, y, rotation, recipe));
}
/**
* Clears the placement queue.
*/
/**Clears the placement queue.*/
default void clearBuilding(){
getPlaceQueue().clear();
}
/**
* Add another build requests to the tail of the queue, if it doesn't exist there yet.
*/
/**Add another build requests to the tail of the queue, if it doesn't exist there yet.*/
default void addBuildRequest(BuildRequest place){
synchronized(getPlaceQueue()){
for(BuildRequest request : getPlaceQueue()){
@@ -233,9 +215,7 @@ public interface BuilderTrait extends Entity{
current.progress = entity.progress();
}
/**
* Do not call directly.
*/
/**Do not call directly.*/
default void updateMining(Unit unit){
Tile tile = getMineTile();
@@ -261,9 +241,7 @@ public interface BuilderTrait extends Entity{
}
}
/**
* Draw placement effects for an entity. This includes mining
*/
/**Draw placement effects for an entity. This includes mining*/
default void drawBuilding(Unit unit){
BuildRequest request;
@@ -320,9 +298,7 @@ public interface BuilderTrait extends Entity{
Draw.color();
}
/**
* Internal use only.
*/
/**Internal use only.*/
default void drawMining(Unit unit){
Tile tile = getMineTile();
@@ -349,9 +325,7 @@ public interface BuilderTrait extends Entity{
Draw.color();
}
/**
* Class for storing build requests. Can be either a place or remove request.
*/
/**Class for storing build requests. Can be either a place or remove request.*/
class BuildRequest{
public final int x, y, rotation;
public final Recipe recipe;
@@ -359,9 +333,7 @@ public interface BuilderTrait extends Entity{
public float progress;
/**
* This creates a build request.
*/
/**This creates a build request.*/
public BuildRequest(int x, int y, int rotation, Recipe recipe){
this.x = x;
this.y = y;
@@ -370,9 +342,7 @@ public interface BuilderTrait extends Entity{
this.remove = false;
}
/**
* This creates a remove request.
*/
/**This creates a remove request.*/
public BuildRequest(int x, int y){
this.x = x;
this.y = y;

View File

@@ -105,6 +105,8 @@ public class Block extends BaseBlock implements Content{
public Color minimapColor = Color.CLEAR;
/** View range of this block type. Use a value < 0 to disable. */
public float viewRange = 10;
/**Whether the top icon is outlined, like a turret.*/
public boolean turretIcon = false;
protected Array<Tile> tempTiles = new Array<>();
protected Color tempColor = new Color();

View File

@@ -85,6 +85,7 @@ public abstract class Turret extends Block{
solid = true;
layer = Layer.turret;
group = BlockGroup.turrets;
turretIcon = true;
}
@Override

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.world.blocks.distribution;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.ObjectSet;
import com.badlogic.gdx.utils.Pool.Poolable;
import io.anuke.annotations.Annotations.Loc;
@@ -38,11 +39,12 @@ public class MassDriver extends Block{
protected float translation = 7f;
protected int minDistribute = 10;
protected float knockback = 4f;
protected float reloadTime = 80f;
protected float reloadTime = 100f;
protected Effect shootEffect = ShootFx.shootBig2;
protected Effect smokeEffect = ShootFx.shootBigSmoke2;
protected Effect recieveEffect = BlockFx.smeltsmoke;
protected Effect recieveEffect = BlockFx.mineBig;
protected float shake = 3f;
protected TextureRegion turretRegion;
public MassDriver(String name){
super(name);
@@ -53,6 +55,7 @@ public class MassDriver extends Block{
itemCapacity = 50;
layer = Layer.turret;
hasPower = true;
turretIcon = true;
}
@Remote(targets = Loc.both, called = Loc.server, forward = true)
@@ -99,6 +102,28 @@ public class MassDriver extends Block{
Effects.shake(driver.shake, driver.shake, entity);
}
@Override
public TextureRegion[] getBlockIcon(){
if(blockIcon == null){
blockIcon = new TextureRegion[]{region, turretRegion};
}
return super.getBlockIcon();
}
@Override
public void load(){
super.load();
turretRegion = Draw.region(name + "-turret");
}
@Override
public void init(){
super.init();
viewRange = range;
}
@Override
public void update(Tile tile){
MassDriverEntity entity = tile.entity();
@@ -148,7 +173,7 @@ public class MassDriver extends Block{
public void drawLayer(Tile tile){
MassDriverEntity entity = tile.entity();
Draw.rect(name + "-turret",
Draw.rect(turretRegion,
tile.drawx() + Angles.trnsx(entity.rotation + 180f, entity.reload * knockback),
tile.drawy() + Angles.trnsy(entity.rotation + 180f, entity.reload * knockback),
entity.rotation - 90);
@@ -156,7 +181,11 @@ public class MassDriver extends Block{
@Override
public void drawConfigure(Tile tile){
super.drawConfigure(tile);
float sin = Mathf.absin(Timers.time(), 6f, 1f);
Draw.color(Palette.accent);
Lines.stroke(1f);
Lines.circle(tile.drawx(), tile.drawy(), (tile.block().size/2f+1) * tilesize + sin);
MassDriverEntity entity = tile.entity();
@@ -164,8 +193,7 @@ public class MassDriver extends Block{
Tile target = world.tile(entity.link);
Draw.color(Palette.place);
Lines.square(target.drawx(), target.drawy(),
target.block().size * tilesize / 2f + 1f);
Lines.circle(target.drawx(), target.drawy(), (target.block().size/2f+1) * tilesize + sin);
Draw.reset();
}
@@ -217,7 +245,6 @@ public class MassDriver extends Block{
public void reset(){
from = null;
to = null;
;
}
}