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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 B

After

Width:  |  Height:  |  Size: 789 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 580 B

After

Width:  |  Height:  |  Size: 542 B

View File

@@ -520,3 +520,4 @@ block.rotary-pump.name=Rotary Pump
block.nuclear-reactor.name=Nuclear Reactor block.nuclear-reactor.name=Nuclear Reactor
block.interceptor-factory.name=Interceptor Factory block.interceptor-factory.name=Interceptor Factory
block.command-center.name=Command Center block.command-center.name=Command Center
block.mass-driver.name=Mass Driver

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 138 KiB

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.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.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.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 //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(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"){{ massDriver = new MassDriver("mass-driver"){{
size = 3; size = 3;
itemCapacity = 80; 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; collidesTiles = false;
lifetime = 200f; lifetime = 200f;
@@ -190,11 +190,14 @@ public class TurretBullets extends BulletList implements ContentList{
@Override @Override
public void draw(Bullet b){ public void draw(Bullet b){
Draw.color(Color.LIGHT_GRAY); float w = 11f, h = 13f;
Fill.square(b.x, b.y, 3f, b.angle());
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(); Draw.reset();
} }

View File

@@ -45,34 +45,22 @@ public interface BuilderTrait extends Entity{
float placeDistance = 150f; float placeDistance = 150f;
float mineDistance = 70f; float mineDistance = 70f;
/** /**Returns the queue for storing build requests.*/
* Returns the queue for storing build requests.
*/
Queue<BuildRequest> getPlaceQueue(); Queue<BuildRequest> getPlaceQueue();
/** /**Returns the tile this builder is currently mining.*/
* Returns the tile this builder is currently mining.
*/
Tile getMineTile(); Tile getMineTile();
/** /**Sets the tile this builder is currently mining.*/
* Sets the tile this builder is currently mining.
*/
void setMineTile(Tile tile); 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(); 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); 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(){ default boolean canCreateBlocks(){
return true; 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(){ default boolean isBuilding(){
return getPlaceQueue().size != 0; return getPlaceQueue().size != 0;
} }
@@ -145,16 +131,12 @@ public interface BuilderTrait extends Entity{
addBuildRequest(new BuildRequest(x, y, rotation, recipe)); addBuildRequest(new BuildRequest(x, y, rotation, recipe));
} }
/** /**Clears the placement queue.*/
* Clears the placement queue.
*/
default void clearBuilding(){ default void clearBuilding(){
getPlaceQueue().clear(); 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){ default void addBuildRequest(BuildRequest place){
synchronized(getPlaceQueue()){ synchronized(getPlaceQueue()){
for(BuildRequest request : getPlaceQueue()){ for(BuildRequest request : getPlaceQueue()){
@@ -233,9 +215,7 @@ public interface BuilderTrait extends Entity{
current.progress = entity.progress(); current.progress = entity.progress();
} }
/** /**Do not call directly.*/
* Do not call directly.
*/
default void updateMining(Unit unit){ default void updateMining(Unit unit){
Tile tile = getMineTile(); 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){ default void drawBuilding(Unit unit){
BuildRequest request; BuildRequest request;
@@ -320,9 +298,7 @@ public interface BuilderTrait extends Entity{
Draw.color(); Draw.color();
} }
/** /**Internal use only.*/
* Internal use only.
*/
default void drawMining(Unit unit){ default void drawMining(Unit unit){
Tile tile = getMineTile(); Tile tile = getMineTile();
@@ -349,9 +325,7 @@ public interface BuilderTrait extends Entity{
Draw.color(); 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{ class BuildRequest{
public final int x, y, rotation; public final int x, y, rotation;
public final Recipe recipe; public final Recipe recipe;
@@ -359,9 +333,7 @@ public interface BuilderTrait extends Entity{
public float progress; public float progress;
/** /**This creates a build request.*/
* This creates a build request.
*/
public BuildRequest(int x, int y, int rotation, Recipe recipe){ public BuildRequest(int x, int y, int rotation, Recipe recipe){
this.x = x; this.x = x;
this.y = y; this.y = y;
@@ -370,9 +342,7 @@ public interface BuilderTrait extends Entity{
this.remove = false; this.remove = false;
} }
/** /**This creates a remove request.*/
* This creates a remove request.
*/
public BuildRequest(int x, int y){ public BuildRequest(int x, int y){
this.x = x; this.x = x;
this.y = y; this.y = y;

View File

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

View File

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

View File

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

View File

@@ -10,7 +10,6 @@ import io.anuke.mindustry.type.Upgrade;
import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.blocks.Floor; import io.anuke.mindustry.world.blocks.Floor;
import io.anuke.mindustry.world.blocks.OreBlock; import io.anuke.mindustry.world.blocks.OreBlock;
import io.anuke.mindustry.world.blocks.defense.turrets.Turret;
import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Hue; import io.anuke.ucore.graphics.Hue;
@@ -26,7 +25,7 @@ public class Generators {
continue; continue;
} }
if(block instanceof Turret){ if(block.turretIcon){
Color color = Color.ROYAL; Color color = Color.ROYAL;
Image image = context.get(block.name); Image image = context.get(block.name);