Launchpad block

This commit is contained in:
Anuken
2019-01-09 11:44:33 -05:00
parent 048b7bd32f
commit 33afab7294
17 changed files with 3161 additions and 3078 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

+6 -6
View File
@@ -392,16 +392,13 @@ content.liquid.name = Liquids
content.unit.name = Units content.unit.name = Units
content.recipe.name = Blocks content.recipe.name = Blocks
content.mech.name = Mechs content.mech.name = Mechs
item.stone.name = Stone
item.stone.description = A common raw material. Used for separating and refining into other materials, or melting into lava.
item.copper.name = Copper item.copper.name = Copper
item.copper.description = A useful structure material. Used extensively in all types of blocks. item.copper.description = A useful structure material. Used extensively in all types of blocks.
item.lead.name = Lead item.lead.name = Lead
item.lead.description = A basic starter material. Used extensively in electronics and liquid transportation blocks. item.lead.description = A basic starter material. Used extensively in electronics and liquid transportation blocks.
item.coal.name = Coal item.coal.name = Coal
item.coal.description = A common and readily available fuel. item.coal.description = A common and readily available fuel.
item.dense-alloy.name = Dense Alloy item.graphite.name = Graphite
item.dense-alloy.description = A tough alloy made with lead and copper. Used in advanced transportation blocks and high-tier drills.
item.titanium.name = Titanium item.titanium.name = Titanium
item.titanium.description = A rare super-light metal used extensively in liquid transportation, drills and aircraft. item.titanium.description = A rare super-light metal used extensively in liquid transportation, drills and aircraft.
item.thorium.name = Thorium item.thorium.name = Thorium
@@ -422,6 +419,8 @@ item.blast-compound.name = Blast Compound
item.blast-compound.description = A volatile compound used in bombs and explosives. While it can burned as fuel, this is not advised. item.blast-compound.description = A volatile compound used in bombs and explosives. While it can burned as fuel, this is not advised.
item.pyratite.name = Pyratite item.pyratite.name = Pyratite
item.pyratite.description = An extremely flammable substance used in incendiary weapons. item.pyratite.description = An extremely flammable substance used in incendiary weapons.
item.bioglass.name = Bioglass
item.scrap.name = Scrap
liquid.water.name = Water liquid.water.name = Water
liquid.lava.name = Lava liquid.lava.name = Lava
liquid.oil.name = Oil liquid.oil.name = Oil
@@ -491,8 +490,8 @@ block.blackrock.name = Black Rock
block.icerock.name = icerock block.icerock.name = icerock
block.copper-wall.name = Copper Wall block.copper-wall.name = Copper Wall
block.copper-wall-large.name = Large Copper Wall block.copper-wall-large.name = Large Copper Wall
block.dense-alloy-wall.name = Dense Alloy Wall block.titanium-wall.name = Titanium Wall
block.dense-alloy-wall-large.name = Large Dense Alloy Wall block.titanium-wall-large.name = Large Titanium Wall
block.phase-wall.name = Phase Wall block.phase-wall.name = Phase Wall
block.phase-wall-large.name = Large Phase Wall block.phase-wall-large.name = Large Phase Wall
block.thorium-wall.name = Thorium Wall block.thorium-wall.name = Thorium Wall
@@ -601,6 +600,7 @@ block.spectre.name = Spectre
block.meltdown.name = Meltdown block.meltdown.name = Meltdown
block.container.name = Container block.container.name = Container
block.core.description = The most important building in the game. block.core.description = The most important building in the game.
block.launch-pad.name = Launch Pad
team.blue.name = blue team.blue.name = blue
team.red.name = red team.red.name = red
team.orange.name = orange team.orange.name = orange
File diff suppressed because it is too large Load Diff
Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 335 KiB

@@ -19,6 +19,7 @@ import io.anuke.mindustry.world.blocks.power.*;
import io.anuke.mindustry.world.blocks.production.*; import io.anuke.mindustry.world.blocks.production.*;
import io.anuke.mindustry.world.blocks.sandbox.*; import io.anuke.mindustry.world.blocks.sandbox.*;
import io.anuke.mindustry.world.blocks.storage.CoreBlock; import io.anuke.mindustry.world.blocks.storage.CoreBlock;
import io.anuke.mindustry.world.blocks.storage.LaunchPad;
import io.anuke.mindustry.world.blocks.storage.SortedUnloader; import io.anuke.mindustry.world.blocks.storage.SortedUnloader;
import io.anuke.mindustry.world.blocks.storage.Vault; import io.anuke.mindustry.world.blocks.storage.Vault;
import io.anuke.mindustry.world.blocks.units.*; import io.anuke.mindustry.world.blocks.units.*;
@@ -57,7 +58,7 @@ public class Blocks implements ContentList{
mechanicalDrill, pneumaticDrill, laserDrill, blastDrill, plasmaDrill, waterExtractor, oilExtractor, cultivator, mechanicalDrill, pneumaticDrill, laserDrill, blastDrill, plasmaDrill, waterExtractor, oilExtractor, cultivator,
//storage //storage
core, vault, container, unloader, core, vault, container, unloader, launchPad,
//turrets //turrets
duo, scorch, hail, wave, lancer, arc, swarmer, salvo, fuse, ripple, cyclone, spectre, meltdown, duo, scorch, hail, wave, lancer, arc, swarmer, salvo, fuse, ripple, cyclone, spectre, meltdown,
@@ -725,7 +726,7 @@ public class Blocks implements ContentList{
core = new CoreBlock("core"){{ core = new CoreBlock("core"){{
health = 1100; health = 1100;
itemCapacity = 3000; itemCapacity = 2000;
}}; }};
vault = new Vault("vault"){{ vault = new Vault("vault"){{
@@ -742,6 +743,13 @@ public class Blocks implements ContentList{
speed = 7f; speed = 7f;
}}; }};
launchPad = new LaunchPad("launch-pad"){{
size = 3;
itemCapacity = 100;
launchTime = 60f * 6;
consumes.power(0.1f);
}};
//endregion //endregion
//region turrets //region turrets
@@ -42,6 +42,7 @@ public class Recipes implements ContentList{
new Recipe(effect, Blocks.container, new ItemStack(Items.titanium, 200)); new Recipe(effect, Blocks.container, new ItemStack(Items.titanium, 200));
new Recipe(effect, Blocks.vault, new ItemStack(Items.titanium, 500), new ItemStack(Items.thorium, 250)); new Recipe(effect, Blocks.vault, new ItemStack(Items.titanium, 500), new ItemStack(Items.thorium, 250));
new Recipe(effect, Blocks.launchPad, new ItemStack(Items.copper, 500));
//removed; no longer fits gameplay //removed; no longer fits gameplay
/*new Recipe(effect, Blocks.core, /*new Recipe(effect, Blocks.core,
@@ -46,7 +46,7 @@ import static io.anuke.mindustry.Vars.*;
public class Control implements ApplicationListener{ public class Control implements ApplicationListener{
public final Saves saves; public final Saves saves;
private Interval timerRPC = new Interval(); private Interval timer = new Interval(2);
private boolean hiscore = false; private boolean hiscore = false;
private boolean wasPaused = false; private boolean wasPaused = false;
private InputHandler[] inputs = {}; private InputHandler[] inputs = {};
@@ -309,8 +309,13 @@ public class Control implements ApplicationListener{
input.update(); input.update();
} }
//autosave global data every second if it's modified
if(timer.get(1, 60)){
data.checkSave();
}
//auto-update rpc every 5 seconds //auto-update rpc every 5 seconds
if(timerRPC.get(60 * 5)){ if(timer.get(60 * 5)){
Platform.instance.updateRPC(); Platform.instance.updateRPC();
} }
@@ -25,7 +25,6 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
idle = new UnitState(){ idle = new UnitState(){
public void update(){ public void update(){
if(!isCommanded()){
retarget(() -> { retarget(() -> {
targetClosest(); targetClosest();
targetClosestEnemyFlag(BlockFlag.target); targetClosestEnemyFlag(BlockFlag.target);
@@ -34,7 +33,6 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
setState(attack); setState(attack);
} }
}); });
}
target = getClosestCore(); target = getClosestCore();
if(target != null){ if(target != null){
@@ -58,7 +56,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
retarget(() -> { retarget(() -> {
targetClosest(); targetClosest();
if(target == null && isCommanded() && getCommand() == UnitCommand.patrol){ if(target == null){
setState(patrol); setState(patrol);
return; return;
} }
@@ -67,7 +65,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
if(target == null) targetClosestEnemyFlag(BlockFlag.producer); if(target == null) targetClosestEnemyFlag(BlockFlag.producer);
if(target == null) targetClosestEnemyFlag(BlockFlag.turret); if(target == null) targetClosestEnemyFlag(BlockFlag.turret);
if(target == null && !isCommanded()){ if(target == null){
setState(idle); setState(idle);
} }
}); });
@@ -108,7 +106,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
} }
public void update(){ public void update(){
if(health >= maxHealth() && !isCommanded()){ if(health >= maxHealth()){
state.set(attack); state.set(attack);
}else if(!targetHasFlag(BlockFlag.repair)){ }else if(!targetHasFlag(BlockFlag.repair)){
retarget(() -> { retarget(() -> {
@@ -167,7 +165,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
@Override @Override
public void behavior(){ public void behavior(){
if(health <= health * type.retreatPercent && !isCommanded() && if(health <= health * type.retreatPercent &&
Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair)) != null){ Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair)) != null){
setState(retreat); setState(retreat);
} }
@@ -70,7 +70,7 @@ public abstract class GroundUnit extends BaseUnit{
} }
public void update(){ public void update(){
if(health >= maxHealth() && !isCommanded()){ if(health >= maxHealth()){
state.set(attack); state.set(attack);
} }
@@ -182,7 +182,7 @@ public abstract class GroundUnit extends BaseUnit{
@Override @Override
public void behavior(){ public void behavior(){
if(health <= health * type.retreatPercent && !isCommanded()){ if(health <= health * type.retreatPercent){
setState(retreat); setState(retreat);
} }
@@ -14,12 +14,18 @@ import io.anuke.mindustry.type.Item;
public class GlobalData{ public class GlobalData{
private ObjectMap<ContentType, ObjectSet<String>> unlocked = new ObjectMap<>(); private ObjectMap<ContentType, ObjectSet<String>> unlocked = new ObjectMap<>();
private ObjectIntMap<Item> items = new ObjectIntMap<>(); private ObjectIntMap<Item> items = new ObjectIntMap<>();
private boolean modified;
public GlobalData(){ public GlobalData(){
Core.settings.setSerializer(ContentType.class, (stream, t) -> stream.writeInt(t.ordinal()), stream -> ContentType.values()[stream.readInt()]); Core.settings.setSerializer(ContentType.class, (stream, t) -> stream.writeInt(t.ordinal()), stream -> ContentType.values()[stream.readInt()]);
Core.settings.setSerializer(Item.class, (stream, t) -> stream.writeUTF(t.name), stream -> Vars.content.getByName(ContentType.item, stream.readUTF())); Core.settings.setSerializer(Item.class, (stream, t) -> stream.writeUTF(t.name), stream -> Vars.content.getByName(ContentType.item, stream.readUTF()));
} }
public void addItem(Item item, int amount){
modified = true;
items.getAndIncrement(item, 0, amount);
}
public ObjectIntMap<Item> items(){ public ObjectIntMap<Item> items(){
return items; return items;
} }
@@ -43,6 +49,7 @@ public class GlobalData{
//fire unlock event so other classes can use it //fire unlock event so other classes can use it
if(ret){ if(ret){
modified = true;
content.onUnlock(); content.onUnlock();
Events.fire(new UnlockEvent(content)); Events.fire(new UnlockEvent(content));
save(); save();
@@ -56,6 +63,13 @@ public class GlobalData{
save(); save();
} }
public void checkSave(){
if(modified){
save();
modified = false;
}
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void load(){ public void load(){
unlocked = Core.settings.getObject("unlocks", ObjectMap.class, ObjectMap::new); unlocked = Core.settings.getObject("unlocks", ObjectMap.class, ObjectMap::new);
@@ -139,8 +139,8 @@ public class WorldGenerator{
int sx = (short)Mathf.range(Short.MAX_VALUE/2); int sx = (short)Mathf.range(Short.MAX_VALUE/2);
int sy = (short)Mathf.range(Short.MAX_VALUE/2); int sy = (short)Mathf.range(Short.MAX_VALUE/2);
int width = 512; int width = 256;
int height = 512; int height = 256;
Array<Point2> spawns = new Array<>(); Array<Point2> spawns = new Array<>();
Array<Item> ores = Item.getAllOres(); Array<Item> ores = Item.getAllOres();
@@ -14,8 +14,11 @@ public class DeployDialog extends FloatingDialog{
} }
void setup(){ void setup(){
buttons().clear();
content().clear(); content().clear();
addCloseButton();
content().stack(new Table(){{ content().stack(new Table(){{
top().left().margin(10); top().left().margin(10);
@@ -29,7 +32,10 @@ public class DeployDialog extends FloatingDialog{
} }
} }
}}, new Table(){{ }}, new Table(){{
addButton("$text.play", () -> Vars.world.generator.playRandomMap()).margin(15); addButton("$text.play", () -> {
hide();
Vars.world.generator.playRandomMap();
}).margin(15);
}}).grow(); }}).grow();
} }
} }
@@ -59,7 +59,6 @@ public class MassDriver extends Block{
layer = Layer.turret; layer = Layer.turret;
hasPower = true; hasPower = true;
consumes.powerBuffered(30f); consumes.powerBuffered(30f);
consumes.require(ConsumePower.class);
} }
@Remote(targets = Loc.both, called = Loc.server, forward = true) @Remote(targets = Loc.both, called = Loc.server, forward = true)
@@ -9,22 +9,19 @@ import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.Lines; import io.anuke.arc.graphics.g2d.Lines;
import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.math.Mathf; import io.anuke.arc.math.Mathf;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.UnitTypes;
import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Unit; import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.traits.SpawnerTrait; import io.anuke.mindustry.entities.traits.SpawnerTrait;
import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.entities.units.UnitType;
import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.graphics.Palette; import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.graphics.Shaders; import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemType;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockFlag; import io.anuke.mindustry.world.meta.BlockFlag;
@@ -77,6 +74,11 @@ public class CoreBlock extends StorageBlock{
if(entity != null) entity.solid = solid; if(entity != null) entity.solid = solid;
} }
@Override
public boolean acceptItem(Item item, Tile tile, Tile source){
return item.type == ItemType.material && super.acceptItem(item, tile, source);
}
@Override @Override
public int getMaximumAccepted(Tile tile, Item item){ public int getMaximumAccepted(Tile tile, Item item){
return itemCapacity * state.teams.get(tile.getTeam()).cores.size; return itemCapacity * state.teams.get(tile.getTeam()).cores.size;
@@ -124,7 +126,7 @@ public class CoreBlock extends StorageBlock{
public void draw(Tile tile){ public void draw(Tile tile){
CoreEntity entity = tile.entity(); CoreEntity entity = tile.entity();
Draw.rect(entity.solid ? Core.atlas.find(name) : openRegion, tile.drawx(), tile.drawy()); Draw.rect(entity.solid ? region : openRegion, tile.drawx(), tile.drawy());
Draw.alpha(entity.heat); Draw.alpha(entity.heat);
Draw.rect(topRegion, tile.drawx(), tile.drawy()); Draw.rect(topRegion, tile.drawx(), tile.drawy());
@@ -0,0 +1,42 @@
package io.anuke.mindustry.world.blocks.storage;
import io.anuke.arc.entities.Effects;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import static io.anuke.mindustry.Vars.data;
public class LaunchPad extends Block{
protected final int timerLaunch = timers++;
/**Time inbetween launches.*/
protected float launchTime;
public LaunchPad(String name){
super(name);
update = true;
hasPower = true;
hasItems = true;
solid = true;
}
@Override
public void update(Tile tile){
TileEntity entity = tile.entity;
if(entity.cons.valid()){
for(Item item : Vars.content.items()){
if(entity.items.get(item) >= itemCapacity && entity.timer.get(timerLaunch, launchTime)){
//TODO play animation of some sort
Effects.effect(Fx.dooropenlarge, tile);
data.addItem(item, entity.items.get(item));
entity.items.set(item, 0);
}
}
}
}
}
+1 -1
View File
@@ -98,7 +98,7 @@ task scaleSprites4x(){
task scaleSprites(){ task scaleSprites(){
finalizedBy 'genSprites' finalizedBy 'genSprites'
//dependsOn 'scaleSprites4x' dependsOn 'scaleSprites4x'
} }
task pack(){ task pack(){
+2 -1
View File
@@ -12,6 +12,7 @@ import io.anuke.mindustry.world.blocks.Floor;
import io.anuke.mindustry.world.blocks.OreBlock; import io.anuke.mindustry.world.blocks.OreBlock;
import static io.anuke.mindustry.Vars.content; import static io.anuke.mindustry.Vars.content;
import static io.anuke.mindustry.Vars.tilesize;
public class Generators { public class Generators {
@@ -143,7 +144,7 @@ public class Generators {
Image image = ImagePacker.get(base.name + (i+1)); Image image = ImagePacker.get(base.name + (i+1));
Image shadow = ImagePacker.get(item.name + (i+1)); Image shadow = ImagePacker.get(item.name + (i+1));
int offset = 3; int offset = image.width()/tilesize;
for (int x = 0; x < image.width(); x++) { for (int x = 0; x < image.width(); x++) {
for (int y = offset; y < image.height(); y++) { for (int y = offset; y < image.height(); y++) {