Everything has been broken
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 313 B |
Binary file not shown.
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 93 KiB |
@@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Sat Mar 17 00:38:14 EDT 2018
|
#Sat Mar 17 11:51:42 EDT 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=533
|
androidBuildCode=535
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.4
|
code=3.4
|
||||||
build=custom build
|
build=custom build
|
||||||
|
|||||||
@@ -164,7 +164,9 @@ public class NetClient extends Module {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Net.handleClient(PlacePacket.class, (packet) -> {
|
Net.handleClient(PlacePacket.class, (packet) -> {
|
||||||
Placement.placeBlock(packet.x, packet.y, Block.getByID(packet.block), packet.rotation, true, Timers.get("placeblocksound", 10));
|
Player placer = playerGroup.getByID(packet.playerid);
|
||||||
|
|
||||||
|
Placement.placeBlock(placer.team, packet.x, packet.y, Block.getByID(packet.block), packet.rotation, true, Timers.get("placeblocksound", 10));
|
||||||
|
|
||||||
if(packet.playerid == player.id){
|
if(packet.playerid == player.id){
|
||||||
Tile tile = world.tile(packet.x, packet.y);
|
Tile tile = world.tile(packet.x, packet.y);
|
||||||
@@ -172,8 +174,11 @@ public class NetClient extends Module {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Net.handleClient(BreakPacket.class, (packet) ->
|
Net.handleClient(BreakPacket.class, (packet) -> {
|
||||||
Placement.breakBlock(packet.x, packet.y, true, Timers.get("breakblocksound", 10)));
|
Player placer = playerGroup.getByID(packet.playerid);
|
||||||
|
|
||||||
|
Placement.breakBlock(placer.team, packet.x, packet.y, true, Timers.get("breakblocksound", 10));
|
||||||
|
});
|
||||||
|
|
||||||
Net.handleClient(EntitySpawnPacket.class, packet -> {
|
Net.handleClient(EntitySpawnPacket.class, packet -> {
|
||||||
EntityGroup group = packet.group;
|
EntityGroup group = packet.group;
|
||||||
|
|||||||
@@ -172,11 +172,12 @@ public class NetServer extends Module{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Net.handleServer(PlacePacket.class, (id, packet) -> {
|
Net.handleServer(PlacePacket.class, (id, packet) -> {
|
||||||
packet.playerid = connections.get(id).id;
|
Player placer = connections.get(id);
|
||||||
|
packet.playerid = placer.id;
|
||||||
|
|
||||||
Block block = Block.getByID(packet.block);
|
Block block = Block.getByID(packet.block);
|
||||||
|
|
||||||
if(!Placement.validPlace(packet.x, packet.y, block)) return;
|
if(!Placement.validPlace(placer.team, packet.x, packet.y, block)) return;
|
||||||
|
|
||||||
Recipe recipe = Recipes.getByResult(block);
|
Recipe recipe = Recipes.getByResult(block);
|
||||||
|
|
||||||
@@ -184,7 +185,7 @@ public class NetServer extends Module{
|
|||||||
|
|
||||||
state.inventory.removeItems(recipe.requirements);
|
state.inventory.removeItems(recipe.requirements);
|
||||||
|
|
||||||
Placement.placeBlock(packet.x, packet.y, block, packet.rotation, true, false);
|
Placement.placeBlock(placer.team, packet.x, packet.y, block, packet.rotation, true, false);
|
||||||
|
|
||||||
admins.getTrace(Net.getConnection(id).address).lastBlockPlaced = block;
|
admins.getTrace(Net.getConnection(id).address).lastBlockPlaced = block;
|
||||||
admins.getTrace(Net.getConnection(id).address).totalBlocksPlaced ++;
|
admins.getTrace(Net.getConnection(id).address).totalBlocksPlaced ++;
|
||||||
@@ -193,11 +194,12 @@ public class NetServer extends Module{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Net.handleServer(BreakPacket.class, (id, packet) -> {
|
Net.handleServer(BreakPacket.class, (id, packet) -> {
|
||||||
packet.playerid = connections.get(id).id;
|
Player placer = connections.get(id);
|
||||||
|
packet.playerid = placer.id;
|
||||||
|
|
||||||
if(!Placement.validBreak(packet.x, packet.y)) return;
|
if(!Placement.validBreak(placer.team, packet.x, packet.y)) return;
|
||||||
|
|
||||||
Block block = Placement.breakBlock(packet.x, packet.y, true, false);
|
Block block = Placement.breakBlock(placer.team, packet.x, packet.y, true, false);
|
||||||
|
|
||||||
if(block != null) {
|
if(block != null) {
|
||||||
admins.getTrace(Net.getConnection(id).address).lastBlockBroken = block;
|
admins.getTrace(Net.getConnection(id).address).lastBlockBroken = block;
|
||||||
|
|||||||
@@ -224,9 +224,9 @@ public class Renderer extends RendererModule{
|
|||||||
Shaders.outline.color.set(team.color);
|
Shaders.outline.color.set(team.color);
|
||||||
|
|
||||||
Graphics.beginShaders(Shaders.outline);
|
Graphics.beginShaders(Shaders.outline);
|
||||||
//Graphics.shader(Shaders.hit);
|
Graphics.shader(Shaders.hit, false);
|
||||||
drawTeam(team, flying);
|
drawTeam(team, flying);
|
||||||
//Graphics.shader();
|
Graphics.shader();
|
||||||
Graphics.endShaders();
|
Graphics.endShaders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ public class World extends Module{
|
|||||||
private Tile[][] tiles;
|
private Tile[][] tiles;
|
||||||
private Pathfind pathfind = new Pathfind();
|
private Pathfind pathfind = new Pathfind();
|
||||||
private Maps maps = new Maps();
|
private Maps maps = new Maps();
|
||||||
private Tile core;
|
private Array<Tile> allyCores = new Array<>();
|
||||||
|
private Array<Tile> enemyCores = new Array<>();
|
||||||
private Array<SpawnPoint> spawns = new Array<>();
|
private Array<SpawnPoint> spawns = new Array<>();
|
||||||
|
|
||||||
private Array<Tile> tempTiles = new Array<>();
|
private Array<Tile> tempTiles = new Array<>();
|
||||||
@@ -186,42 +187,11 @@ public class World extends Module{
|
|||||||
|
|
||||||
Placement.placeBlock(core.x, core.y, ProductionBlocks.core, 0, false, false);
|
Placement.placeBlock(core.x, core.y, ProductionBlocks.core, 0, false, false);
|
||||||
|
|
||||||
if(!map.name.equals("tutorial")){
|
|
||||||
setDefaultBlocks();
|
|
||||||
}else{
|
|
||||||
control.tutorial().setDefaultBlocks(core.x, core.y);
|
control.tutorial().setDefaultBlocks(core.x, core.y);
|
||||||
}
|
|
||||||
|
|
||||||
pathfind.resetPaths();
|
pathfind.resetPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDefaultBlocks(){
|
|
||||||
int x = core.x, y = core.y;
|
|
||||||
int flip = Mathf.sign(!currentMap.flipBase);
|
|
||||||
int fr = currentMap.flipBase ? 2 : 0;
|
|
||||||
|
|
||||||
set(x, y-2*flip, DistributionBlocks.conveyor, 1 + fr);
|
|
||||||
set(x, y-3*flip, DistributionBlocks.conveyor, 1 + fr);
|
|
||||||
|
|
||||||
for(int i = 0; i < 2; i ++){
|
|
||||||
int d = Mathf.sign(i-0.5f);
|
|
||||||
|
|
||||||
set(x+2*d, y-2*flip, ProductionBlocks.stonedrill, d);
|
|
||||||
set(x+2*d, y-1*flip, DistributionBlocks.conveyor, 1 + fr);
|
|
||||||
set(x+2*d, y, DistributionBlocks.conveyor, 1 + fr);
|
|
||||||
set(x+2*d, y+1*flip, WeaponBlocks.doubleturret, 0 + fr);
|
|
||||||
|
|
||||||
set(x+1*d, y-3*flip, DistributionBlocks.conveyor, 2*d);
|
|
||||||
set(x+2*d, y-3*flip, DistributionBlocks.conveyor, 2*d);
|
|
||||||
set(x+2*d, y-4*flip, DistributionBlocks.conveyor, 1 + fr);
|
|
||||||
set(x+2*d, y-5*flip, DistributionBlocks.conveyor, 1 + fr);
|
|
||||||
|
|
||||||
set(x+3*d, y-5*flip, ProductionBlocks.stonedrill, 0 + fr);
|
|
||||||
set(x+3*d, y-4*flip, ProductionBlocks.stonedrill, 0 + fr);
|
|
||||||
set(x+3*d, y-3*flip, ProductionBlocks.stonedrill, 0 + fr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void set(int x, int y, Block type, int rot){
|
void set(int x, int y, Block type, int rot){
|
||||||
if(!Mathf.inBounds(x, y, tiles)){
|
if(!Mathf.inBounds(x, y, tiles)){
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package io.anuke.mindustry.entities;
|
package io.anuke.mindustry.entities;
|
||||||
|
|
||||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.entities.BulletEntity;
|
import io.anuke.ucore.entities.BulletEntity;
|
||||||
import io.anuke.ucore.entities.Entity;
|
|
||||||
import io.anuke.ucore.util.Timer;
|
import io.anuke.ucore.util.Timer;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
@@ -12,7 +10,7 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
public class Bullet extends BulletEntity{
|
public class Bullet extends BulletEntity{
|
||||||
public Timer timer = new Timer(3);
|
public Timer timer = new Timer(3);
|
||||||
|
|
||||||
public Bullet(BulletType type, Entity owner, float x, float y, float angle){
|
public Bullet(BulletType type, Unit owner, float x, float y, float angle){
|
||||||
super(type, owner, angle);
|
super(type, owner, angle);
|
||||||
set(x, y);
|
set(x, y);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@@ -38,7 +36,11 @@ public class Bullet extends BulletEntity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean collidesTiles(){
|
public boolean collidesTiles(){
|
||||||
return owner instanceof BaseUnit;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Unit owner(){
|
||||||
|
return (Unit)owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Team team(){
|
public Team team(){
|
||||||
@@ -56,7 +58,7 @@ public class Bullet extends BulletEntity{
|
|||||||
if (tile == null) return false;
|
if (tile == null) return false;
|
||||||
tile = tile.target();
|
tile = tile.target();
|
||||||
|
|
||||||
if (tile.entity != null && tile.entity.collide(this) && !tile.entity.dead) {
|
if (tile.entity != null && tile.entity.collide(this) && !tile.entity.dead && tile.entity.tile.getTeam() != team()) {
|
||||||
tile.entity.collision(this);
|
tile.entity.collision(this);
|
||||||
remove();
|
remove();
|
||||||
type.hit(this);
|
type.hit(this);
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
|||||||
public void hit(Bullet b, float hitx, float hity) {
|
public void hit(Bullet b, float hitx, float hity) {
|
||||||
Effects.effect(shellsmoke, b);
|
Effects.effect(shellsmoke, b);
|
||||||
for(int i = 0; i < 3; i ++){
|
for(int i = 0; i < 3; i ++){
|
||||||
Bullet bullet = new Bullet(flakspark, b.owner, hitx, hity, b.angle() + Mathf.range(120f));
|
Bullet bullet = new Bullet(flakspark, b.owner(), hitx, hity, b.angle() + Mathf.range(120f));
|
||||||
bullet.add();
|
bullet.add();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -255,7 +255,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
|||||||
//TODO remove translation() usage
|
//TODO remove translation() usage
|
||||||
Angles.circleVectors(30, 6f, (nx, ny) -> {
|
Angles.circleVectors(30, 6f, (nx, ny) -> {
|
||||||
float ang = Mathf.atan2(nx, ny);
|
float ang = Mathf.atan2(nx, ny);
|
||||||
Bullet o = new Bullet(blastshot, b.owner, b.x + nx, b.y + ny, ang).add();
|
Bullet o = new Bullet(blastshot, b.owner(), b.x + nx, b.y + ny, ang).add();
|
||||||
o.damage = b.damage/9;
|
o.damage = b.damage/9;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -419,7 +419,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
|||||||
|
|
||||||
public void hit(Bullet b, float hitx, float hity) {
|
public void hit(Bullet b, float hitx, float hity) {
|
||||||
for(int i = 0; i < 4; i ++){
|
for(int i = 0; i < 4; i ++){
|
||||||
Bullet bullet = new Bullet(scrap, b.owner, b.x, b.y, b.angle() + Mathf.range(80f));
|
Bullet bullet = new Bullet(scrap, b.owner(), b.x, b.y, b.angle() + Mathf.range(80f));
|
||||||
bullet.add();
|
bullet.add();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class Player extends Unit{
|
|||||||
|
|
||||||
float ft = Mathf.sin(walktime, 6f, 2f);
|
float ft = Mathf.sin(walktime, 6f, 2f);
|
||||||
|
|
||||||
//Draw.alpha(hitTime / hitDuration);
|
Draw.alpha(hitTime / hitDuration);
|
||||||
|
|
||||||
if(!mech.flying) {
|
if(!mech.flying) {
|
||||||
for (int i : Mathf.signs) {
|
for (int i : Mathf.signs) {
|
||||||
@@ -163,7 +163,7 @@ public class Player extends Unit{
|
|||||||
Draw.rect(weapon.name + "-equip", x + tr.x, y + tr.y, w, 8, rotation - 90);
|
Draw.rect(weapon.name + "-equip", x + tr.x, y + tr.y, w, 8, rotation - 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Draw.alpha(1f);
|
Draw.alpha(1f);
|
||||||
|
|
||||||
x = px;
|
x = px;
|
||||||
y = py;
|
y = py;
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class BaseUnit extends Unit {
|
|||||||
public void added(){
|
public void added(){
|
||||||
maxhealth = type.health;
|
maxhealth = type.health;
|
||||||
|
|
||||||
//hitbox.solid = true;
|
hitbox.solid = true;
|
||||||
hitbox.setSize(type.hitsize);
|
hitbox.setSize(type.hitsize);
|
||||||
hitboxTile.setSize(type.hitsizeTile);
|
hitboxTile.setSize(type.hitsizeTile);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.entities.units;
|
package io.anuke.mindustry.entities.units;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.entities.Unit;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Translator;
|
import io.anuke.ucore.util.Translator;
|
||||||
@@ -16,6 +17,8 @@ public abstract class GroundUnitType extends UnitType{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(BaseUnit unit) {
|
public void draw(BaseUnit unit) {
|
||||||
|
Draw.alpha(unit.hitTime / Unit.hitDuration);
|
||||||
|
|
||||||
float walktime = unit.walkTime; //TODO!
|
float walktime = unit.walkTime; //TODO!
|
||||||
|
|
||||||
float ft = Mathf.sin(walktime, 6f, 2f);
|
float ft = Mathf.sin(walktime, 6f, 2f);
|
||||||
@@ -28,6 +31,8 @@ public abstract class GroundUnitType extends UnitType{
|
|||||||
Draw.rect(name + "-base", unit.x, unit.y, unit.baseRotation- 90);
|
Draw.rect(name + "-base", unit.x, unit.y, unit.baseRotation- 90);
|
||||||
|
|
||||||
Draw.rect(name, unit.x, unit.y, unit.rotation -90);
|
Draw.rect(name, unit.x, unit.y, unit.rotation -90);
|
||||||
|
|
||||||
|
Draw.alpha(1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -48,6 +48,12 @@ public abstract class UnitType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void update(BaseUnit unit){
|
public void update(BaseUnit unit){
|
||||||
|
if(unit.hitTime > 0){
|
||||||
|
unit.hitTime -= Timers.delta();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(unit.hitTime < 0) unit.hitTime = 0;
|
||||||
|
|
||||||
if(Net.client()){
|
if(Net.client()){
|
||||||
unit.interpolate();
|
unit.interpolate();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Placement.validPlace(x, y, type);
|
return Placement.validPlace(player.team, x, y, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validBreak(int x, int y){
|
public boolean validBreak(int x, int y){
|
||||||
@@ -111,12 +111,12 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Placement.validBreak(x, y);
|
return Placement.validBreak(player.team, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void placeBlock(int x, int y, Block result, int rotation, boolean effects, boolean sound){
|
public void placeBlock(int x, int y, Block result, int rotation, boolean effects, boolean sound){
|
||||||
if(!Net.client()){
|
if(!Net.client()){
|
||||||
Placement.placeBlock(x, y, result, rotation, effects, sound);
|
Placement.placeBlock(player.team, x, y, result, rotation, effects, sound);
|
||||||
Tile tile = world.tile(x, y);
|
Tile tile = world.tile(x, y);
|
||||||
if(tile != null) result.placed(tile);
|
if(tile != null) result.placed(tile);
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void breakBlock(int x, int y, boolean sound){
|
public void breakBlock(int x, int y, boolean sound){
|
||||||
if(!Net.client()) Placement.breakBlock(x, y, true, sound);
|
if(!Net.client()) Placement.breakBlock(player.team, x, y, true, sound);
|
||||||
|
|
||||||
if(Net.active()){
|
if(Net.active()){
|
||||||
NetEvents.handleBreak(x, y);
|
NetEvents.handleBreak(x, y);
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ public class BlockLoader {
|
|||||||
DistributionBlocks.conduit,
|
DistributionBlocks.conduit,
|
||||||
ProductionBlocks.coaldrill,
|
ProductionBlocks.coaldrill,
|
||||||
WeaponBlocks.chainturret,
|
WeaponBlocks.chainturret,
|
||||||
SpecialBlocks.enemySpawn,
|
|
||||||
DebugBlocks.powerVoid
|
DebugBlocks.powerVoid
|
||||||
//add any new block sections here
|
//add any new block sections here
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ public class Item implements Comparable<Item>{
|
|||||||
private static final Array<Item> items = new Array<>();
|
private static final Array<Item> items = new Array<>();
|
||||||
|
|
||||||
public static final Item
|
public static final Item
|
||||||
stone = new Item("stone"),
|
stone = new Item("stone"){
|
||||||
|
{
|
||||||
|
material = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
iron = new Item("iron"),
|
iron = new Item("iron"),
|
||||||
coal = new Item("coal"){
|
coal = new Item("coal"){
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,33 +1,10 @@
|
|||||||
package io.anuke.mindustry.world;
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import com.badlogic.gdx.graphics.Pixmap;
|
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
|
||||||
import io.anuke.ucore.util.Bundles;
|
|
||||||
|
|
||||||
public class Map{
|
public class Map{
|
||||||
public int id = -1;
|
|
||||||
public String name;
|
public String name;
|
||||||
|
public String author;
|
||||||
|
public String description;
|
||||||
public boolean visible = true;
|
public boolean visible = true;
|
||||||
public boolean flipBase = false;
|
|
||||||
public boolean custom = false;
|
public boolean custom = false;
|
||||||
public boolean oreGen = true;
|
public boolean oreGen = true;
|
||||||
public Color backgroundColor = Color.valueOf("646464");
|
|
||||||
|
|
||||||
public transient Pixmap pixmap;
|
|
||||||
public transient Texture texture;
|
|
||||||
|
|
||||||
public Map(){}
|
|
||||||
|
|
||||||
public String localized(){
|
|
||||||
return Bundles.get("map."+name+".name", name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth(){
|
|
||||||
return pixmap.getWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight(){
|
|
||||||
return pixmap.getHeight();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.badlogic.gdx.utils.Array;
|
|||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.game.SpawnPoint;
|
import io.anuke.mindustry.game.SpawnPoint;
|
||||||
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
import io.anuke.mindustry.resource.Recipe;
|
import io.anuke.mindustry.resource.Recipe;
|
||||||
@@ -22,7 +23,7 @@ public class Placement {
|
|||||||
private static Array<Tile> tempTiles = new Array<>();
|
private static Array<Tile> tempTiles = new Array<>();
|
||||||
|
|
||||||
/**Returns block type that was broken, or null if unsuccesful.*/
|
/**Returns block type that was broken, or null if unsuccesful.*/
|
||||||
public static Block breakBlock(int x, int y, boolean effect, boolean sound){
|
public static Block breakBlock(Team team, int x, int y, boolean effect, boolean sound){
|
||||||
Tile tile = world.tile(x, y);
|
Tile tile = world.tile(x, y);
|
||||||
|
|
||||||
if(tile == null) return null;
|
if(tile == null) return null;
|
||||||
@@ -58,13 +59,14 @@ public class Placement {
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void placeBlock(int x, int y, Block result, int rotation, boolean effects, boolean sound){
|
public static void placeBlock(Team team, int x, int y, Block result, int rotation, boolean effects, boolean sound){
|
||||||
Tile tile = world.tile(x, y);
|
Tile tile = world.tile(x, y);
|
||||||
|
|
||||||
//just in case
|
//just in case
|
||||||
if(tile == null) return;
|
if(tile == null) return;
|
||||||
|
|
||||||
tile.setBlock(result, rotation);
|
tile.setBlock(result, rotation);
|
||||||
|
tile.setTeam(team);
|
||||||
|
|
||||||
if(result.isMultiblock()){
|
if(result.isMultiblock()){
|
||||||
int offsetx = -(result.size-1)/2;
|
int offsetx = -(result.size-1)/2;
|
||||||
@@ -76,8 +78,10 @@ public class Placement {
|
|||||||
int worldy = dy + offsety + y;
|
int worldy = dy + offsety + y;
|
||||||
if(!(worldx == x && worldy == y)){
|
if(!(worldx == x && worldy == y)){
|
||||||
Tile toplace = world.tile(worldx, worldy);
|
Tile toplace = world.tile(worldx, worldy);
|
||||||
if(toplace != null)
|
if(toplace != null) {
|
||||||
toplace.setLinked((byte)(dx + offsetx), (byte)(dy + offsety));
|
toplace.setLinked((byte) (dx + offsetx), (byte) (dy + offsety));
|
||||||
|
toplace.setTeam(team);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(effects) Effects.effect(Fx.place, worldx * tilesize, worldy * tilesize);
|
if(effects) Effects.effect(Fx.place, worldx * tilesize, worldy * tilesize);
|
||||||
@@ -88,7 +92,7 @@ public class Placement {
|
|||||||
if(effects && sound) threads.run(() -> Effects.sound("place", x * tilesize, y * tilesize));
|
if(effects && sound) threads.run(() -> Effects.sound("place", x * tilesize, y * tilesize));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean validPlace(int x, int y, Block type){
|
public static boolean validPlace(Team team, int x, int y, Block type){
|
||||||
for(int i = 0; i < world.getSpawns().size; i ++){
|
for(int i = 0; i < world.getSpawns().size; i ++){
|
||||||
SpawnPoint spawn = world.getSpawns().get(i);
|
SpawnPoint spawn = world.getSpawns().get(i);
|
||||||
if(Vector2.dst(x * tilesize, y * tilesize, spawn.start.worldx(), spawn.start.worldy()) < enemyspawnspace){
|
if(Vector2.dst(x * tilesize, y * tilesize, spawn.start.worldx(), spawn.start.worldy()) < enemyspawnspace){
|
||||||
@@ -147,7 +151,7 @@ public class Placement {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}else {
|
}else {
|
||||||
return tile.block() != type
|
return tile.block() != type && (tile.getTeam() == Team.none || tile.getTeam() == team)
|
||||||
&& (type.canReplace(tile.block()) || tile.block().alwaysReplace)
|
&& (type.canReplace(tile.block()) || tile.block().alwaysReplace)
|
||||||
&& tile.block().isMultiblock() == type.isMultiblock() || tile.block() == Blocks.air;
|
&& tile.block().isMultiblock() == type.isMultiblock() || tile.block() == Blocks.air;
|
||||||
}
|
}
|
||||||
@@ -157,7 +161,7 @@ public class Placement {
|
|||||||
return tile != null && tile.x == world.getCore().x && tile.y == world.getCore().y - 2;
|
return tile != null && tile.x == world.getCore().x && tile.y == world.getCore().y - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean validBreak(int x, int y){
|
public static boolean validBreak(Team team, int x, int y){
|
||||||
Tile tile = world.tile(x, y);
|
Tile tile = world.tile(x, y);
|
||||||
|
|
||||||
if(tile == null || tile.block() == ProductionBlocks.core) return false;
|
if(tile == null || tile.block() == ProductionBlocks.core) return false;
|
||||||
@@ -166,6 +170,6 @@ public class Placement {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tile.breakable();
|
return tile.breakable() && (tile.getTeam() == Team.none || tile.getTeam() == team);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,6 +298,8 @@ public class Tile{
|
|||||||
entity = null;
|
entity = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
team = 0;
|
||||||
|
|
||||||
Block block = block();
|
Block block = block();
|
||||||
|
|
||||||
if (block.destructible || block.update) {
|
if (block.destructible || block.update) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import io.anuke.ucore.util.Mathf;
|
|||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
public class WorldGenerator {
|
public class WorldGenerator {
|
||||||
public static final ObjectMap<Block, Block> rocks = new ObjectMap(){{
|
public static final ObjectMap<Block, Block> rocks = new ObjectMap<Block, Block>(){{
|
||||||
put(Blocks.stone, Blocks.rock);
|
put(Blocks.stone, Blocks.rock);
|
||||||
put(Blocks.snow, Blocks.icerock);
|
put(Blocks.snow, Blocks.icerock);
|
||||||
put(Blocks.grass, Blocks.shrub);
|
put(Blocks.grass, Blocks.shrub);
|
||||||
@@ -23,11 +23,9 @@ public class WorldGenerator {
|
|||||||
}};
|
}};
|
||||||
|
|
||||||
/**Returns the core (starting) block. Should fill spawns with the correct spawnpoints.*/
|
/**Returns the core (starting) block. Should fill spawns with the correct spawnpoints.*/
|
||||||
public static Tile generate(Pixmap pixmap, Tile[][] tiles, Array<SpawnPoint> spawns){
|
public static void generate(Tile[][] tiles, Map map){
|
||||||
Noise.setSeed(world.getSeed());
|
Noise.setSeed(world.getSeed());
|
||||||
|
|
||||||
Tile core = null;
|
|
||||||
|
|
||||||
for(int x = 0; x < pixmap.getWidth(); x ++){
|
for(int x = 0; x < pixmap.getWidth(); x ++){
|
||||||
for(int y = 0; y < pixmap.getHeight(); y ++){
|
for(int y = 0; y < pixmap.getHeight(); y ++){
|
||||||
Block floor = Blocks.stone;
|
Block floor = Blocks.stone;
|
||||||
@@ -88,7 +86,5 @@ public class WorldGenerator {
|
|||||||
tiles[x][y].updateOcclusion();
|
tiles[x][y].updateOcclusion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return core;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import io.anuke.mindustry.world.blocks.types.*;
|
|||||||
public class Blocks{
|
public class Blocks{
|
||||||
public static final Block
|
public static final Block
|
||||||
|
|
||||||
|
//player/enemy spawnpoint
|
||||||
|
spawn = new Block("spawn"){},
|
||||||
|
|
||||||
air = new Block("air"){
|
air = new Block("air"){
|
||||||
//no drawing here
|
//no drawing here
|
||||||
public void drawCache(Tile tile){}
|
public void drawCache(Tile tile){}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
package io.anuke.mindustry.world.blocks;
|
|
||||||
|
|
||||||
import io.anuke.mindustry.world.Block;
|
|
||||||
|
|
||||||
public class SpecialBlocks{
|
|
||||||
public static final Block
|
|
||||||
playerSpawn = new Block("playerspawn"){},
|
|
||||||
enemySpawn = new Block("enemyspawn"){};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user