Merge branches 'master' and 'mech-rework' of https://github.com/Anuken/Mindustry into mech-rework
# Conflicts: # core/assets/sprites/block_colors.png # core/assets/sprites/sprites.atlas # core/assets/sprites/sprites.png # core/assets/sprites/sprites3.png # core/assets/sprites/sprites5.png # core/src/mindustry/ai/BlockIndexer.java # core/src/mindustry/core/World.java # core/src/mindustry/entities/traits/Entity.java # core/src/mindustry/entities/type/BaseEntity.java # core/src/mindustry/entities/type/TileEntity.java # core/src/mindustry/world/blocks/defense/MendProjector.java # core/src/mindustry/world/blocks/defense/OverdriveProjector.java # core/src/mindustry/world/blocks/production/Drill.java # gradle.properties
This commit is contained in:
@@ -1,97 +0,0 @@
|
||||
package io.anuke.mindustry.content;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.ctype.ContentList;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.type.StatusEffect;
|
||||
|
||||
import static io.anuke.mindustry.Vars.waveTeam;
|
||||
|
||||
public class StatusEffects implements ContentList{
|
||||
public static StatusEffect none, burning, freezing, wet, melting, tarred, overdrive, shielded, shocked, corroded, boss;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
|
||||
none = new StatusEffect();
|
||||
|
||||
burning = new StatusEffect(){{
|
||||
damage = 0.06f;
|
||||
effect = Fx.burning;
|
||||
|
||||
opposite(() -> wet, () -> freezing);
|
||||
trans(() -> tarred, ((unit, time, newTime, result) -> {
|
||||
unit.damage(1f);
|
||||
Effects.effect(Fx.burning, unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f));
|
||||
result.set(this, Math.min(time + newTime, 300f));
|
||||
}));
|
||||
}};
|
||||
|
||||
freezing = new StatusEffect(){{
|
||||
speedMultiplier = 0.6f;
|
||||
armorMultiplier = 0.8f;
|
||||
effect = Fx.freezing;
|
||||
|
||||
opposite(() -> melting, () -> burning);
|
||||
}};
|
||||
|
||||
wet = new StatusEffect(){{
|
||||
speedMultiplier = 0.9f;
|
||||
effect = Fx.wet;
|
||||
|
||||
trans(() -> shocked, ((unit, time, newTime, result) -> {
|
||||
unit.damage(20f);
|
||||
if(unit.getTeam() == waveTeam){
|
||||
Events.fire(Trigger.shock);
|
||||
}
|
||||
result.set(this, time);
|
||||
}));
|
||||
opposite(() -> burning);
|
||||
}};
|
||||
|
||||
melting = new StatusEffect(){{
|
||||
speedMultiplier = 0.8f;
|
||||
armorMultiplier = 0.8f;
|
||||
damage = 0.3f;
|
||||
effect = Fx.melting;
|
||||
|
||||
trans(() -> tarred, ((unit, time, newTime, result) -> result.set(this, Math.min(time + newTime / 2f, 140f))));
|
||||
opposite(() -> wet, () -> freezing);
|
||||
}};
|
||||
|
||||
tarred = new StatusEffect(){{
|
||||
speedMultiplier = 0.6f;
|
||||
effect = Fx.oily;
|
||||
|
||||
trans(() -> melting, ((unit, time, newTime, result) -> result.set(burning, newTime + time)));
|
||||
trans(() -> burning, ((unit, time, newTime, result) -> result.set(burning, newTime + time)));
|
||||
}};
|
||||
|
||||
overdrive = new StatusEffect(){{
|
||||
armorMultiplier = 0.95f;
|
||||
speedMultiplier = 1.15f;
|
||||
damageMultiplier = 1.4f;
|
||||
damage = -0.01f;
|
||||
effect = Fx.overdriven;
|
||||
}};
|
||||
|
||||
shielded = new StatusEffect(){{
|
||||
armorMultiplier = 3f;
|
||||
}};
|
||||
|
||||
boss = new StatusEffect(){{
|
||||
armorMultiplier = 3f;
|
||||
damageMultiplier = 3f;
|
||||
speedMultiplier = 1.1f;
|
||||
}};
|
||||
|
||||
shocked = new StatusEffect();
|
||||
|
||||
//no effects, just small amounts of damage.
|
||||
corroded = new StatusEffect(){{
|
||||
damage = 0.1f;
|
||||
}};
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package io.anuke.mindustry.core;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.Files.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.io.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class Version{
|
||||
/** Build type. 'official' for official releases; 'custom' or 'bleeding edge' are also used. */
|
||||
public static String type;
|
||||
/** Build modifier, e.g. 'alpha' or 'release' */
|
||||
public static String modifier;
|
||||
/** Number specifying the major version, e.g. '4' */
|
||||
public static int number;
|
||||
/** Build number, e.g. '43'. set to '-1' for custom builds. */
|
||||
public static int build = 0;
|
||||
/** Revision number. Used for hotfixes. Does not affect server compatibility. */
|
||||
public static int revision = 0;
|
||||
/** Whether version loading is enabled. */
|
||||
public static boolean enabled = true;
|
||||
|
||||
public static void init(){
|
||||
if(!enabled) return;
|
||||
|
||||
try{
|
||||
FileHandle file = OS.isAndroid || OS.isIos ? Core.files.internal("version.properties") : new FileHandle("version.properties", FileType.Internal);
|
||||
|
||||
ObjectMap<String, String> map = new ObjectMap<>();
|
||||
PropertiesUtils.load(map, file.reader());
|
||||
|
||||
type = map.get("type");
|
||||
number = Integer.parseInt(map.get("number", "4"));
|
||||
modifier = map.get("modifier");
|
||||
if(map.get("build").contains(".")){
|
||||
String[] split = map.get("build").split("\\.");
|
||||
try{
|
||||
build = Integer.parseInt(split[0]);
|
||||
revision = Integer.parseInt(split[1]);
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace();
|
||||
build = -1;
|
||||
}
|
||||
}else{
|
||||
build = Strings.canParseInt(map.get("build")) ? Integer.parseInt(map.get("build")) : -1;
|
||||
}
|
||||
}catch(IOException e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package io.anuke.mindustry.ctype;
|
||||
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.util.ArcAnnotate.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.mod.Mods.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
|
||||
|
||||
/** Base class for a content type that is loaded in {@link io.anuke.mindustry.core.ContentLoader}. */
|
||||
public abstract class Content implements Comparable<Content>{
|
||||
public final short id;
|
||||
/** The mod that loaded this piece of content. */
|
||||
public @Nullable LoadedMod mod;
|
||||
/** File that this content was loaded from. */
|
||||
public @Nullable FileHandle sourceFile;
|
||||
|
||||
public Content(){
|
||||
this.id = (short)Vars.content.getBy(getContentType()).size;
|
||||
Vars.content.handleContent(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type name of this piece of content.
|
||||
* This should return the same value for all instances of this content type.
|
||||
*/
|
||||
public abstract ContentType getContentType();
|
||||
|
||||
/** Called after all content and modules are created. Do not use to load regions or texture data! */
|
||||
public void init(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after all content is created, only on non-headless versions.
|
||||
* Use for loading regions or other image data.
|
||||
*/
|
||||
public void load(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Content c){
|
||||
return Integer.compare(id, c.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return getContentType().name() + "#" + id;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package io.anuke.mindustry.ctype;
|
||||
|
||||
/** Interface for a list of content to be loaded in {@link io.anuke.mindustry.core.ContentLoader}. */
|
||||
public interface ContentList{
|
||||
/** This method should create all the content. */
|
||||
void load();
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package io.anuke.mindustry.entities.traits;
|
||||
|
||||
import io.anuke.mindustry.game.Team;
|
||||
|
||||
public interface TeamTrait extends Entity{
|
||||
Team getTeam();
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package io.anuke.mindustry.entities.type;
|
||||
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.mindustry.entities.traits.SolidTrait;
|
||||
|
||||
public abstract class SolidEntity extends BaseEntity implements SolidTrait{
|
||||
protected transient Vector2 velocity = new Vector2(0f, 0.0001f);
|
||||
private transient Vector2 lastPosition = new Vector2();
|
||||
|
||||
@Override
|
||||
public Vector2 lastPosition(){
|
||||
return lastPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2 velocity(){
|
||||
return velocity;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package io.anuke.mindustry.entities.type.base;
|
||||
|
||||
public class Crawler extends GroundUnit{
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package io.anuke.mindustry.entities.type.base;
|
||||
|
||||
public class Dagger extends GroundUnit{
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package io.anuke.mindustry.entities.type.base;
|
||||
|
||||
public class Draug extends MinerDrone{
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package io.anuke.mindustry.entities.type.base;
|
||||
|
||||
public class Eruptor extends GroundUnit{
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package io.anuke.mindustry.entities.type.base;
|
||||
|
||||
public class Fortress extends GroundUnit{
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package io.anuke.mindustry.entities.type.base;
|
||||
|
||||
public class Ghoul extends FlyingUnit{
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package io.anuke.mindustry.entities.type.base;
|
||||
|
||||
public class Phantom extends BuilderDrone{
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package io.anuke.mindustry.entities.type.base;
|
||||
|
||||
public class Spirit extends RepairDrone{
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package io.anuke.mindustry.entities.type.base;
|
||||
|
||||
public class Titan extends GroundUnit{
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package io.anuke.mindustry.entities.type.base;
|
||||
|
||||
public class Wraith extends FlyingUnit{
|
||||
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
|
||||
public enum Team{
|
||||
derelict(Color.valueOf("4d4e58")),
|
||||
sharded(Pal.accent),
|
||||
crux(Color.valueOf("e82d2d")),
|
||||
green(Color.valueOf("4dd98b")),
|
||||
purple(Color.valueOf("9a4bdf")),
|
||||
blue(Color.royal.cpy());
|
||||
|
||||
public final static Team[] all = values();
|
||||
public final Color color;
|
||||
public final int intColor;
|
||||
|
||||
Team(Color color){
|
||||
this.color = color;
|
||||
intColor = Color.rgba8888(color);
|
||||
}
|
||||
|
||||
public String localized(){
|
||||
return Core.bundle.get("team." + name() + ".name");
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
|
||||
/** Class for various team-based utilities. */
|
||||
public class Teams{
|
||||
private TeamData[] map = new TeamData[Team.all.length];
|
||||
|
||||
/**
|
||||
* Register a team.
|
||||
* @param team The team type enum.
|
||||
* @param enemies The array of enemies of this team. Any team not in this array is considered neutral.
|
||||
*/
|
||||
public void add(Team team, Team... enemies){
|
||||
map[team.ordinal()] = new TeamData(team, EnumSet.of(enemies));
|
||||
}
|
||||
|
||||
/** Returns team data by type. */
|
||||
public TeamData get(Team team){
|
||||
if(map[team.ordinal()] == null){
|
||||
add(team, Array.with(Team.all).select(t -> t != team).toArray(Team.class));
|
||||
}
|
||||
return map[team.ordinal()];
|
||||
}
|
||||
|
||||
/** Returns whether a team is active, e.g. whether it has any cores remaining. */
|
||||
public boolean isActive(Team team){
|
||||
//the enemy wave team is always active
|
||||
return team == Vars.waveTeam || get(team).cores.size > 0;
|
||||
}
|
||||
|
||||
/** Returns a set of all teams that are enemies of this team. */
|
||||
public EnumSet<Team> enemiesOf(Team team){
|
||||
return get(team).enemies;
|
||||
}
|
||||
|
||||
/** Returns whether {@param other} is an enemy of {@param #team}. */
|
||||
public boolean areEnemies(Team team, Team other){
|
||||
return enemiesOf(team).contains(other);
|
||||
}
|
||||
|
||||
/** Allocates a new array with the active teams.
|
||||
* Never call in the main game loop.*/
|
||||
public Array<TeamData> getActive(){
|
||||
return Array.select(map, t -> t != null);
|
||||
}
|
||||
|
||||
public static class TeamData{
|
||||
public final ObjectSet<Tile> cores = new ObjectSet<>();
|
||||
public final EnumSet<Team> enemies;
|
||||
public final Team team;
|
||||
public Queue<BrokenBlock> brokenBlocks = new Queue<>();
|
||||
|
||||
public TeamData(Team team, EnumSet<Team> enemies){
|
||||
this.team = team;
|
||||
this.enemies = enemies;
|
||||
}
|
||||
}
|
||||
|
||||
/** Represents a block made by this team that was destroyed somewhere on the map.
|
||||
* This does not include deconstructed blocks.*/
|
||||
public static class BrokenBlock{
|
||||
public final short x, y, rotation, block;
|
||||
public final int config;
|
||||
|
||||
public BrokenBlock(short x, short y, short rotation, short block, int config){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.rotation = rotation;
|
||||
this.block = block;
|
||||
this.config = config;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
enum PlaceMode{
|
||||
none, breaking, placing, schematicSelect
|
||||
}
|
||||
@@ -1,214 +0,0 @@
|
||||
package io.anuke.mindustry.io;
|
||||
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.serialization.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.io.MapIO.*;
|
||||
import io.anuke.mindustry.maps.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.LegacyColorMapper.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
/** Map IO for the "old" .mmap format.
|
||||
* Differentiate between legacy maps and new maps by checking the extension (or the header).*/
|
||||
public class LegacyMapIO{
|
||||
private static final ObjectMap<String, String> fallback = ObjectMap.of("alpha-dart-mech-pad", "dart-mech-pad");
|
||||
private static final Json json = new Json();
|
||||
|
||||
/* Convert a map from the old format to the new format. */
|
||||
public static void convertMap(FileHandle in, FileHandle out) throws IOException{
|
||||
Map map = readMap(in, true);
|
||||
|
||||
String waves = map.tags.get("waves", "[]");
|
||||
Array<SpawnGroup> groups = new Array<>(json.fromJson(SpawnGroup[].class, waves));
|
||||
|
||||
Tile[][] tiles = world.createTiles(map.width, map.height);
|
||||
for(int x = 0; x < map.width; x++){
|
||||
for(int y = 0; y < map.height; y++){
|
||||
tiles[x][y] = new CachedTile();
|
||||
tiles[x][y].x = (short)x;
|
||||
tiles[x][y].y = (short)y;
|
||||
}
|
||||
}
|
||||
state.rules.spawns = groups;
|
||||
readTiles(map, tiles);
|
||||
MapIO.writeMap(out, map);
|
||||
}
|
||||
|
||||
public static Map readMap(FileHandle file, boolean custom) throws IOException{
|
||||
try(DataInputStream stream = new DataInputStream(file.read(1024))){
|
||||
StringMap tags = new StringMap();
|
||||
|
||||
//meta is uncompressed
|
||||
int version = stream.readInt();
|
||||
if(version != 1){
|
||||
throw new IOException("Outdated legacy map format");
|
||||
}
|
||||
int build = stream.readInt();
|
||||
short width = stream.readShort(), height = stream.readShort();
|
||||
byte tagAmount = stream.readByte();
|
||||
|
||||
for(int i = 0; i < tagAmount; i++){
|
||||
String name = stream.readUTF();
|
||||
String value = stream.readUTF();
|
||||
tags.put(name, value);
|
||||
}
|
||||
|
||||
return new Map(file, width, height, tags, custom, version, build);
|
||||
}
|
||||
}
|
||||
|
||||
public static void readTiles(Map map, Tile[][] tiles) throws IOException{
|
||||
readTiles(map, (x, y) -> tiles[x][y]);
|
||||
}
|
||||
|
||||
public static void readTiles(Map map, TileProvider tiles) throws IOException{
|
||||
readTiles(map.file, map.width, map.height, tiles);
|
||||
}
|
||||
|
||||
private static void readTiles(FileHandle file, int width, int height, Tile[][] tiles) throws IOException{
|
||||
readTiles(file, width, height, (x, y) -> tiles[x][y]);
|
||||
}
|
||||
|
||||
private static void readTiles(FileHandle file, int width, int height, TileProvider tiles) throws IOException{
|
||||
try(BufferedInputStream input = file.read(bufferSize)){
|
||||
|
||||
//read map
|
||||
{
|
||||
DataInputStream stream = new DataInputStream(input);
|
||||
|
||||
stream.readInt(); //version
|
||||
stream.readInt(); //build
|
||||
stream.readInt(); //width + height
|
||||
byte tagAmount = stream.readByte();
|
||||
|
||||
for(int i = 0; i < tagAmount; i++){
|
||||
stream.readUTF(); //key
|
||||
stream.readUTF(); //val
|
||||
}
|
||||
}
|
||||
|
||||
try(DataInputStream stream = new DataInputStream(new InflaterInputStream(input))){
|
||||
|
||||
try{
|
||||
byte mapped = stream.readByte();
|
||||
IntMap<Block> idmap = new IntMap<>();
|
||||
IntMap<String> namemap = new IntMap<>();
|
||||
|
||||
for(int i = 0; i < mapped; i++){
|
||||
byte type = stream.readByte();
|
||||
short total = stream.readShort();
|
||||
|
||||
for(int j = 0; j < total; j++){
|
||||
String name = stream.readUTF();
|
||||
if(type == 1){
|
||||
Block res = content.getByName(ContentType.block, fallback.get(name, name));
|
||||
idmap.put(j, res == null ? Blocks.air : res);
|
||||
namemap.put(j, fallback.get(name, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//read floor and create tiles first
|
||||
for(int i = 0; i < width * height; i++){
|
||||
int x = i % width, y = i / width;
|
||||
int floorid = stream.readUnsignedByte();
|
||||
int oreid = stream.readUnsignedByte();
|
||||
int consecutives = stream.readUnsignedByte();
|
||||
|
||||
Tile tile = tiles.get(x, y);
|
||||
tile.setFloor((Floor)idmap.get(floorid));
|
||||
tile.setOverlay(idmap.get(oreid));
|
||||
|
||||
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||
int newx = j % width, newy = j / width;
|
||||
Tile newTile = tiles.get(newx, newy);
|
||||
newTile.setFloor((Floor)idmap.get(floorid));
|
||||
newTile.setOverlay(idmap.get(oreid));
|
||||
}
|
||||
|
||||
i += consecutives;
|
||||
}
|
||||
|
||||
//read blocks
|
||||
for(int i = 0; i < width * height; i++){
|
||||
int x = i % width, y = i / width;
|
||||
int id = stream.readUnsignedByte();
|
||||
Block block = idmap.get(id);
|
||||
if(block == null) block = Blocks.air;
|
||||
|
||||
Tile tile = tiles.get(x, y);
|
||||
//the spawn block is saved in the block tile layer in older maps, shift it to the overlay
|
||||
if(block != Blocks.spawn){
|
||||
tile.setBlock(block);
|
||||
}else{
|
||||
tile.setOverlay(block);
|
||||
}
|
||||
|
||||
if(namemap.get(id, "").equals("part")){
|
||||
stream.readByte(); //link
|
||||
}else if(tile.entity != null){
|
||||
byte tr = stream.readByte();
|
||||
stream.readShort(); //read health (which is actually irrelevant)
|
||||
|
||||
byte team = Pack.leftByte(tr);
|
||||
byte rotation = Pack.rightByte(tr);
|
||||
|
||||
tile.setTeam(Team.all[team]);
|
||||
tile.entity.health = tile.block().health;
|
||||
tile.rotation(rotation);
|
||||
|
||||
if(tile.block() == Blocks.liquidSource || tile.block() == Blocks.unloader || tile.block() == Blocks.sorter){
|
||||
stream.readByte(); //these blocks have an extra config byte, read it
|
||||
}
|
||||
}else{ //no entity/part, read consecutives
|
||||
int consecutives = stream.readUnsignedByte();
|
||||
|
||||
for(int j = i + 1; j < i + 1 + consecutives; j++){
|
||||
int newx = j % width, newy = j / width;
|
||||
tiles.get(newx, newy).setBlock(block);
|
||||
}
|
||||
|
||||
i += consecutives;
|
||||
}
|
||||
}
|
||||
|
||||
}finally{
|
||||
content.setTemporaryMapper(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads a pixmap in the 3.5 pixmap format. */
|
||||
public static void readPixmap(Pixmap pixmap, Tile[][] tiles){
|
||||
for(int x = 0; x < pixmap.getWidth(); x++){
|
||||
for(int y = 0; y < pixmap.getHeight(); y++){
|
||||
int color = pixmap.getPixel(x, pixmap.getHeight() - 1 - y);
|
||||
LegacyBlock block = LegacyColorMapper.get(color);
|
||||
Tile tile = tiles[x][y];
|
||||
|
||||
tile.setFloor(block.floor);
|
||||
tile.setBlock(block.wall);
|
||||
if(block.ore != null) tile.setOverlay(block.ore);
|
||||
|
||||
//place core
|
||||
if(color == Color.rgba8888(Color.green)){
|
||||
//actual core parts
|
||||
tile.setBlock(Blocks.coreShard);
|
||||
tile.setTeam(Team.sharded);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
package io.anuke.mindustry.io.versions;
|
||||
|
||||
import io.anuke.arc.func.Prov;
|
||||
import io.anuke.mindustry.entities.type.Bullet;
|
||||
import io.anuke.mindustry.entities.effect.*;
|
||||
import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.mindustry.entities.type.base.*;
|
||||
|
||||
/*
|
||||
Latest data: [build 81]
|
||||
|
||||
0 = Player
|
||||
1 = Fire
|
||||
2 = Puddle
|
||||
3 = Draug
|
||||
4 = Spirit
|
||||
5 = Phantom
|
||||
6 = Dagger
|
||||
7 = Crawler
|
||||
8 = Titan
|
||||
9 = Fortress
|
||||
10 = Eruptor
|
||||
11 = Wraith
|
||||
12 = Ghoul
|
||||
13 = Revenant
|
||||
|
||||
Before removal of lightining/bullet: [build 80]
|
||||
|
||||
0 = Player
|
||||
1 = Fire
|
||||
2 = Puddle
|
||||
3 = Bullet
|
||||
4 = Lightning
|
||||
5 = Draug
|
||||
6 = Spirit
|
||||
7 = Phantom
|
||||
8 = Dagger
|
||||
9 = Crawler
|
||||
10 = Titan
|
||||
11 = Fortress
|
||||
12 = Eruptor
|
||||
13 = Wraith
|
||||
14 = Ghoul
|
||||
15 = Revenant
|
||||
|
||||
Before addition of new units: [build 79 and below]
|
||||
|
||||
0 = Player
|
||||
1 = Fire
|
||||
2 = Puddle
|
||||
3 = Bullet
|
||||
4 = Lightning
|
||||
5 = Spirit
|
||||
6 = Dagger
|
||||
7 = Crawler
|
||||
8 = Titan
|
||||
9 = Fortress
|
||||
10 = Eruptor
|
||||
11 = Wraith
|
||||
12 = Ghoul
|
||||
13 = Phantom
|
||||
14 = Revenant
|
||||
*/
|
||||
public class LegacyTypeTable{
|
||||
private static final Prov[] build81Table = {
|
||||
Player::new,
|
||||
Fire::new,
|
||||
Puddle::new,
|
||||
Draug::new,
|
||||
Spirit::new,
|
||||
Phantom::new,
|
||||
Dagger::new,
|
||||
Crawler::new,
|
||||
Titan::new,
|
||||
Fortress::new,
|
||||
Eruptor::new,
|
||||
Wraith::new,
|
||||
Ghoul::new,
|
||||
Revenant::new
|
||||
};
|
||||
|
||||
private static final Prov[] build80Table = {
|
||||
Player::new,
|
||||
Fire::new,
|
||||
Puddle::new,
|
||||
Bullet::new, //TODO reading these may crash
|
||||
Lightning::new,
|
||||
Draug::new,
|
||||
Spirit::new,
|
||||
Phantom::new,
|
||||
Dagger::new,
|
||||
Crawler::new,
|
||||
Titan::new,
|
||||
Fortress::new,
|
||||
Eruptor::new,
|
||||
Wraith::new,
|
||||
Ghoul::new,
|
||||
Revenant::new
|
||||
};
|
||||
|
||||
private static final Prov[] build79Table = {
|
||||
Player::new,
|
||||
Fire::new,
|
||||
Puddle::new,
|
||||
Bullet::new, //TODO reading these may crash
|
||||
Lightning::new,
|
||||
Spirit::new,
|
||||
Dagger::new,
|
||||
Crawler::new,
|
||||
Titan::new,
|
||||
Fortress::new,
|
||||
Eruptor::new,
|
||||
Wraith::new,
|
||||
Ghoul::new,
|
||||
Phantom::new,
|
||||
Revenant::new
|
||||
};
|
||||
|
||||
public static Prov[] getTable(int build){
|
||||
if(build == -1 || build == 81){
|
||||
//return most recent one since that's probably it; not guaranteed
|
||||
return build81Table;
|
||||
}else if(build == 80){
|
||||
return build80Table;
|
||||
}else{
|
||||
return build79Table;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package io.anuke.mindustry.mod;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.mod.Mods.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
|
||||
public class ModCrashHandler{
|
||||
|
||||
public static void handle(Throwable t){
|
||||
Array<Throwable> list = Strings.getCauses(t);
|
||||
Throwable modCause = list.find(e -> e instanceof ModLoadException);
|
||||
|
||||
if(modCause != null && Fonts.outline != null){
|
||||
String text = "[scarlet][[A fatal crash has occured while loading a mod!][]\n\nReason:[accent] " + modCause.getMessage();
|
||||
String bottom = "[scarlet]The associated mod has been disabled. Swipe out of the app and launch it again.";
|
||||
GlyphLayout layout = new GlyphLayout();
|
||||
Core.atlas = TextureAtlas.blankAtlas();
|
||||
Colors.put("accent", Pal.accent);
|
||||
|
||||
Core.app.addListener(new ApplicationListener(){
|
||||
@Override
|
||||
public void update(){
|
||||
Core.graphics.clear(0.1f, 0.1f, 0.1f, 1f);
|
||||
float rad = Math.min(Core.graphics.getWidth(), Core.graphics.getHeight()) / 2f / 1.3f;
|
||||
Draw.color(Color.scarlet, Color.black, Mathf.absin(Core.graphics.getFrameId(), 15f, 0.6f));
|
||||
Lines.stroke(Scl.scl(40f));
|
||||
//Lines.poly2(Core.graphics.getWidth()/2f, Core.graphics.getHeight()/2f, 3, rad, 0f);
|
||||
float cx = Core.graphics.getWidth()/2f, cy = Core.graphics.getHeight()/2f;
|
||||
for(int i = 0; i < 3; i++){
|
||||
float angle1 = i * 120f + 90f;
|
||||
float angle2 = (i + 1) * 120f + 90f;
|
||||
Tmp.v1.trnsExact(angle1, rad - Lines.getStroke()/2f).add(cx, cy);
|
||||
Tmp.v2.trnsExact(angle2, rad - Lines.getStroke()/2f).add(cx, cy);
|
||||
Tmp.v3.trnsExact(angle1, rad + Lines.getStroke()/2f).add(cx, cy);
|
||||
Tmp.v4.trnsExact(angle2, rad + Lines.getStroke()/2f).add(cx, cy);
|
||||
Fill.quad(Tmp.v1.x, Tmp.v1.y, Tmp.v2.x, Tmp.v2.y, Tmp.v4.x, Tmp.v4.y, Tmp.v3.x, Tmp.v3.y);
|
||||
}
|
||||
Lines.lineAngleCenter(Core.graphics.getWidth()/2f, Core.graphics.getHeight()/2f - Scl.scl(5f), 90f, rad/3.1f);
|
||||
Fill.square(Core.graphics.getWidth()/2f, Core.graphics.getHeight()/2f + rad/2f - Scl.scl(15f), Lines.getStroke()/2f);
|
||||
Draw.reset();
|
||||
|
||||
Fonts.outline.getData().markupEnabled = true;
|
||||
layout.setText(Fonts.outline, text, Color.white, Core.graphics.getWidth(), Align.left, true);
|
||||
Fonts.outline.draw(text, Core.graphics.getWidth()/2f - layout.width/2f, Core.graphics.getHeight() - Scl.scl(50f), Core.graphics.getWidth(), Align.left, true);
|
||||
|
||||
layout.setText(Fonts.outline, bottom, Color.white, Core.graphics.getWidth(), Align.left, true);
|
||||
Fonts.outline.draw(bottom, Core.graphics.getWidth()/2f - layout.width/2f, layout.height + Scl.scl(10f), Core.graphics.getWidth(), Align.left, true);
|
||||
Draw.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height){
|
||||
Draw.proj().setOrtho(0, 0, width, height);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package io.anuke.mindustry.plugin;
|
||||
|
||||
import io.anuke.mindustry.mod.*;
|
||||
|
||||
public abstract class Plugin extends Mod{
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package io.anuke.mindustry.world.producers;
|
||||
|
||||
public class Produce{
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package io.anuke.mindustry.world.producers;
|
||||
|
||||
public class ProduceItem{
|
||||
}
|
||||
@@ -1,26 +1,26 @@
|
||||
package io.anuke.mindustry;
|
||||
package mindustry;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.assets.*;
|
||||
import io.anuke.arc.assets.loaders.*;
|
||||
import io.anuke.arc.audio.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.async.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.ctype.Content;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.maps.*;
|
||||
import io.anuke.mindustry.mod.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import arc.*;
|
||||
import arc.assets.*;
|
||||
import arc.assets.loaders.*;
|
||||
import arc.audio.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import arc.util.async.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.ctype.Content;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.mod.*;
|
||||
import mindustry.net.Net;
|
||||
|
||||
import static io.anuke.arc.Core.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public abstract class ClientLauncher extends ApplicationCore implements Platform{
|
||||
private static final int loadingFPS = 20;
|
||||
@@ -32,8 +32,8 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
||||
|
||||
@Override
|
||||
public void setup(){
|
||||
Vars.loadLogger();
|
||||
Vars.platform = this;
|
||||
Log.setUseColors(false);
|
||||
beginTime = Time.millis();
|
||||
|
||||
Time.setDeltaProvider(() -> {
|
||||
@@ -70,8 +70,11 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
||||
Sounds.load();
|
||||
|
||||
assets.loadRun("contentcreate", Content.class, () -> {
|
||||
content.createContent();
|
||||
content.createBaseContent();
|
||||
content.loadColors();
|
||||
}, () -> {
|
||||
mods.loadScripts();
|
||||
content.createModContent();
|
||||
});
|
||||
|
||||
add(logic = new Logic());
|
||||
@@ -120,7 +123,7 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
||||
for(ApplicationListener listener : modules){
|
||||
listener.init();
|
||||
}
|
||||
mods.each(Mod::init);
|
||||
mods.eachClass(Mod::init);
|
||||
finished = true;
|
||||
Events.fire(new ClientLoadEvent());
|
||||
super.resize(graphics.getWidth(), graphics.getHeight());
|
||||
@@ -193,7 +196,8 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
|
||||
|
||||
if(assets.getCurrentLoading() != null){
|
||||
String name = assets.getCurrentLoading().fileName.toLowerCase();
|
||||
String key = name.contains("content") ? "content" : name.contains("mod") ? "mods" : name.contains("msav") || name.contains("maps") ? "map" : name.contains("ogg") || name.contains("mp3") ? "sound" : name.contains("png") ? "image" : "system";
|
||||
String key = name.contains("script") ? "scripts" : name.contains("content") ? "content" : name.contains("mod") ? "mods" : name.contains("msav") ||
|
||||
name.contains("maps") ? "map" : name.contains("ogg") || name.contains("mp3") ? "sound" : name.contains("png") ? "image" : "system";
|
||||
font.draw(bundle.get("load." + key, ""), graphics.getWidth() / 2f, graphics.getHeight() / 2f - height / 2f - Scl.scl(10f), Align.center);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,40 @@
|
||||
package io.anuke.mindustry;
|
||||
package mindustry;
|
||||
|
||||
import io.anuke.arc.Application.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.assets.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.ai.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.effect.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.input.*;
|
||||
import io.anuke.mindustry.maps.*;
|
||||
import io.anuke.mindustry.mod.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.world.blocks.defense.ForceProjector.*;
|
||||
import arc.*;
|
||||
import arc.Application.*;
|
||||
import arc.assets.*;
|
||||
import arc.struct.*;
|
||||
import arc.files.*;
|
||||
import arc.graphics.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.ai.*;
|
||||
import mindustry.core.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.input.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.mod.*;
|
||||
import mindustry.net.Net;
|
||||
import mindustry.world.blocks.defense.ForceProjector.*;
|
||||
|
||||
import java.nio.charset.*;
|
||||
import java.util.*;
|
||||
|
||||
import static io.anuke.arc.Core.*;
|
||||
import static arc.Core.settings;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class Vars implements Loadable{
|
||||
/** Whether to load locales.*/
|
||||
public static boolean loadLocales = true;
|
||||
/** Whether the logger is loaded. */
|
||||
public static boolean loadedLogger = false;
|
||||
/** Maximum schematic size.*/
|
||||
public static final int maxSchematicSize = 32;
|
||||
/** All schematic base64 starts with this string.*/
|
||||
@@ -57,10 +61,6 @@ public class Vars implements Loadable{
|
||||
public static final Array<String> defaultServers = Array.with();
|
||||
/** maximum distance between mine and core that supports automatic transferring */
|
||||
public static final float mineTransferRange = 220f;
|
||||
/** team of the player by default */
|
||||
public static final Team defaultTeam = Team.sharded;
|
||||
/** team of the enemy in waves/sectors */
|
||||
public static final Team waveTeam = Team.crux;
|
||||
/** whether to enable editing of units in the editor */
|
||||
public static final boolean enableUnitEditing = false;
|
||||
/** max chat message length */
|
||||
@@ -118,22 +118,24 @@ public class Vars implements Loadable{
|
||||
public static boolean headless;
|
||||
/** whether steam is enabled for this game */
|
||||
public static boolean steam;
|
||||
/** application data directory, equivalent to {@link io.anuke.arc.Settings#getDataDirectory()} */
|
||||
public static FileHandle dataDirectory;
|
||||
/** whether typing into the console is enabled - developers only */
|
||||
public static boolean enableConsole = false;
|
||||
/** application data directory, equivalent to {@link Settings#getDataDirectory()} */
|
||||
public static Fi dataDirectory;
|
||||
/** data subdirectory used for screenshots */
|
||||
public static FileHandle screenshotDirectory;
|
||||
/** data subdirectory used for custom mmaps */
|
||||
public static FileHandle customMapDirectory;
|
||||
/** data subdirectory used for custom mmaps */
|
||||
public static FileHandle mapPreviewDirectory;
|
||||
public static Fi screenshotDirectory;
|
||||
/** data subdirectory used for custom maps */
|
||||
public static Fi customMapDirectory;
|
||||
/** data subdirectory used for custom map previews */
|
||||
public static Fi mapPreviewDirectory;
|
||||
/** tmp subdirectory for map conversion */
|
||||
public static FileHandle tmpDirectory;
|
||||
public static Fi tmpDirectory;
|
||||
/** data subdirectory used for saves */
|
||||
public static FileHandle saveDirectory;
|
||||
public static Fi saveDirectory;
|
||||
/** data subdirectory used for mods */
|
||||
public static FileHandle modDirectory;
|
||||
public static Fi modDirectory;
|
||||
/** data subdirectory used for schematics */
|
||||
public static FileHandle schematicDirectory;
|
||||
public static Fi schematicDirectory;
|
||||
/** map file extension */
|
||||
public static final String mapExtension = "msav";
|
||||
/** save file extension */
|
||||
@@ -178,7 +180,7 @@ public class Vars implements Loadable{
|
||||
public static EntityGroup<ShieldEntity> shieldGroup;
|
||||
public static EntityGroup<Puddle> puddleGroup;
|
||||
public static EntityGroup<Fire> fireGroup;
|
||||
public static EntityGroup<BaseUnit>[] unitGroups;
|
||||
public static EntityGroup<BaseUnit> unitGroup;
|
||||
|
||||
public static Player player;
|
||||
|
||||
@@ -190,6 +192,7 @@ public class Vars implements Loadable{
|
||||
|
||||
public static void init(){
|
||||
Serialization.init();
|
||||
DefaultSerializers.typeMappings.put("mindustry.type.ContentType", "mindustry.ctype.ContentType");
|
||||
|
||||
if(loadLocales){
|
||||
//load locales
|
||||
@@ -232,11 +235,7 @@ public class Vars implements Loadable{
|
||||
puddleGroup = entities.add(Puddle.class).enableMapping();
|
||||
shieldGroup = entities.add(ShieldEntity.class, false);
|
||||
fireGroup = entities.add(Fire.class).enableMapping();
|
||||
unitGroups = new EntityGroup[Team.all.length];
|
||||
|
||||
for(Team team : Team.all){
|
||||
unitGroups[team.ordinal()] = entities.add(BaseUnit.class).enableMapping();
|
||||
}
|
||||
unitGroup = entities.add(BaseUnit.class).enableMapping();
|
||||
|
||||
for(EntityGroup<?> group : entities.all()){
|
||||
group.setRemoveListener(entity -> {
|
||||
@@ -268,6 +267,31 @@ public class Vars implements Loadable{
|
||||
maps.load();
|
||||
}
|
||||
|
||||
public static void loadLogger(){
|
||||
if(loadedLogger) return;
|
||||
|
||||
String[] tags = {"[green][D][]", "[royal][I][]", "[yellow][W][]", "[scarlet][E][]", ""};
|
||||
String[] stags = {"&lc&fb[D]", "&lg&fb[I]", "&ly&fb[W]", "&lr&fb[E]", ""};
|
||||
|
||||
Array<String> logBuffer = new Array<>();
|
||||
Log.setLogger((level, text, args) -> {
|
||||
String result = Log.format(text, args);
|
||||
System.out.println(Log.format(stags[level.ordinal()] + "&fr " + text, args));
|
||||
|
||||
result = tags[level.ordinal()] + " " + result;
|
||||
|
||||
if(!headless && (ui == null || ui.scriptfrag == null)){
|
||||
logBuffer.add(result);
|
||||
}else if(!headless){
|
||||
ui.scriptfrag.addMessage(result);
|
||||
}
|
||||
});
|
||||
|
||||
Events.on(ClientLoadEvent.class, e -> logBuffer.each(ui.scriptfrag::addMessage));
|
||||
|
||||
loadedLogger = true;
|
||||
}
|
||||
|
||||
public static void loadSettings(){
|
||||
Core.settings.setAppName(appName);
|
||||
|
||||
@@ -275,7 +299,7 @@ public class Vars implements Loadable{
|
||||
Core.settings.setDataDirectory(Core.files.local("saves/"));
|
||||
}
|
||||
|
||||
Core.settings.defaults("locale", "default");
|
||||
Core.settings.defaults("locale", "default", "blocksync", true);
|
||||
Core.keybinds.setDefaults(Binding.values());
|
||||
Core.settings.load();
|
||||
|
||||
@@ -285,7 +309,7 @@ public class Vars implements Loadable{
|
||||
|
||||
try{
|
||||
//try loading external bundle
|
||||
FileHandle handle = Core.files.local("bundle");
|
||||
Fi handle = Core.files.local("bundle");
|
||||
|
||||
Locale locale = Locale.ENGLISH;
|
||||
Core.bundle = I18NBundle.createBundle(handle, locale);
|
||||
@@ -298,7 +322,7 @@ public class Vars implements Loadable{
|
||||
}catch(Throwable e){
|
||||
//no external bundle found
|
||||
|
||||
FileHandle handle = Core.files.internal("bundles/bundle");
|
||||
Fi handle = Core.files.internal("bundles/bundle");
|
||||
Locale locale;
|
||||
String loc = Core.settings.getString("locale");
|
||||
if(loc.equals("default")){
|
||||
@@ -1,22 +1,22 @@
|
||||
package io.anuke.mindustry.ai;
|
||||
package mindustry.ai;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.game.Teams.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
import arc.*;
|
||||
import arc.func.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.Teams.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
/** Class used for indexing special target blocks for AI. */
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -30,15 +30,15 @@ public class BlockIndexer{
|
||||
private final ObjectSet<Item> itemSet = new ObjectSet<>();
|
||||
/** Stores all ore quadtrants on the map. */
|
||||
private ObjectMap<Item, ObjectSet<Tile>> ores = new ObjectMap<>();
|
||||
/** Tags all quadrants. */
|
||||
/** Maps each team ID to a quarant. A quadrant is a grid of bits, where each bit is set if and only if there is a block of that team in that quadrant. */
|
||||
private GridBits[] structQuadrants;
|
||||
/** Stores all damaged tile entities by team. */
|
||||
private ObjectSet<Tile>[] damagedTiles = new ObjectSet[Team.all.length];
|
||||
private ObjectSet<Tile>[] damagedTiles = new ObjectSet[Team.all().length];
|
||||
/**All ores available on this map.*/
|
||||
private ObjectSet<Item> allOres = new ObjectSet<>();
|
||||
|
||||
/** Maps teams to a map of flagged tiles by type. */
|
||||
private ObjectSet<Tile>[][] flagMap = new ObjectSet[Team.all.length][BlockFlag.all.length];
|
||||
private ObjectSet<Tile>[][] flagMap = new ObjectSet[Team.all().length][BlockFlag.all.length];
|
||||
/** Maps tile positions to their last known tile index data. */
|
||||
private IntMap<TileIndex> typeMap = new IntMap<>();
|
||||
/** Empty set used for returning. */
|
||||
@@ -61,8 +61,8 @@ public class BlockIndexer{
|
||||
Events.on(WorldLoadEvent.class, event -> {
|
||||
scanOres.clear();
|
||||
scanOres.addAll(Item.getAllOres());
|
||||
damagedTiles = new ObjectSet[Team.all.length];
|
||||
flagMap = new ObjectSet[Team.all.length][BlockFlag.all.length];
|
||||
damagedTiles = new ObjectSet[Team.all().length];
|
||||
flagMap = new ObjectSet[Team.all().length][BlockFlag.all.length];
|
||||
|
||||
for(int i = 0; i < flagMap.length; i++){
|
||||
for(int j = 0; j < BlockFlag.all.length; j++){
|
||||
@@ -75,10 +75,7 @@ public class BlockIndexer{
|
||||
ores = null;
|
||||
|
||||
//create bitset for each team type that contains each quadrant
|
||||
structQuadrants = new GridBits[Team.all.length];
|
||||
for(int i = 0; i < Team.all.length; i++){
|
||||
structQuadrants[i] = new GridBits(Mathf.ceil(world.width() / (float)quadrantSize), Mathf.ceil(world.height() / (float)quadrantSize));
|
||||
}
|
||||
structQuadrants = new GridBits[Team.all().length];
|
||||
|
||||
for(int x = 0; x < world.width(); x++){
|
||||
for(int y = 0; y < world.height(); y++){
|
||||
@@ -105,7 +102,31 @@ public class BlockIndexer{
|
||||
}
|
||||
|
||||
private ObjectSet<Tile>[] getFlagged(Team team){
|
||||
return flagMap[team.ordinal()];
|
||||
return flagMap[team.id];
|
||||
}
|
||||
|
||||
private GridBits structQuadrant(Team t){
|
||||
if(structQuadrants[t.id] == null){
|
||||
structQuadrants[t.id] = new GridBits(Mathf.ceil(world.width() / (float)quadrantSize), Mathf.ceil(world.height() / (float)quadrantSize));
|
||||
}
|
||||
return structQuadrants[t.id];
|
||||
}
|
||||
|
||||
/** Updates all the structure quadrants for a newly activated team. */
|
||||
public void updateTeamIndex(Team team){
|
||||
if(structQuadrants == null) return;
|
||||
|
||||
//go through every tile... ouch
|
||||
for(int x = 0; x < world.width(); x++){
|
||||
for(int y = 0; y < world.height(); y++){
|
||||
Tile tile = world.tile(x, y);
|
||||
if(tile.getTeam() == team){
|
||||
int quadrantX = tile.x / quadrantSize;
|
||||
int quadrantY = tile.y / quadrantSize;
|
||||
structQuadrant(team).set(quadrantX, quadrantY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** @return whether this item is present on this map.*/
|
||||
@@ -117,11 +138,11 @@ public class BlockIndexer{
|
||||
public ObjectSet<Tile> getDamaged(Team team){
|
||||
returnArray.clear();
|
||||
|
||||
if(damagedTiles[team.ordinal()] == null){
|
||||
damagedTiles[team.ordinal()] = new ObjectSet<>();
|
||||
if(damagedTiles[team.id] == null){
|
||||
damagedTiles[team.id] = new ObjectSet<>();
|
||||
}
|
||||
|
||||
ObjectSet<Tile> set = damagedTiles[team.ordinal()];
|
||||
ObjectSet<Tile> set = damagedTiles[team.id];
|
||||
for(Tile tile : set){
|
||||
if((tile.entity == null || tile.entity.getTeam() != team || !tile.entity.damaged()) || tile.block() instanceof BuildBlock){
|
||||
returnArray.add(tile);
|
||||
@@ -137,7 +158,7 @@ public class BlockIndexer{
|
||||
|
||||
/** Get all allied blocks with a flag. */
|
||||
public ObjectSet<Tile> getAllied(Team team, BlockFlag type){
|
||||
return flagMap[team.ordinal()][type.ordinal()];
|
||||
return flagMap[team.id][type.ordinal()];
|
||||
}
|
||||
|
||||
public boolean eachBlock(TeamTrait trait, float range, Boolf<Tile> pred, Cons<Tile> cons){
|
||||
@@ -176,7 +197,7 @@ public class BlockIndexer{
|
||||
/** Get all enemy blocks with a flag. */
|
||||
public Array<Tile> getEnemy(Team team, BlockFlag type){
|
||||
returnArray.clear();
|
||||
for(Team enemy : state.teams.enemiesOf(team)){
|
||||
for(Team enemy : team.enemies()){
|
||||
if(state.teams.isActive(enemy)){
|
||||
ObjectSet<Tile> set = getFlagged(enemy)[type.ordinal()];
|
||||
if(set != null){
|
||||
@@ -190,11 +211,11 @@ public class BlockIndexer{
|
||||
}
|
||||
|
||||
public void notifyTileDamaged(TileEntity entity){
|
||||
if(damagedTiles[entity.getTeam().ordinal()] == null){
|
||||
damagedTiles[entity.getTeam().ordinal()] = new ObjectSet<>();
|
||||
if(damagedTiles[(int)entity.getTeam().id] == null){
|
||||
damagedTiles[(int)entity.getTeam().id] = new ObjectSet<>();
|
||||
}
|
||||
|
||||
ObjectSet<Tile> set = damagedTiles[entity.getTeam().ordinal()];
|
||||
ObjectSet<Tile> set = damagedTiles[(int)entity.getTeam().id];
|
||||
set.add(entity.tile);
|
||||
}
|
||||
|
||||
@@ -317,16 +338,16 @@ public class BlockIndexer{
|
||||
int quadrantY = tile.y / quadrantSize;
|
||||
int index = quadrantX + quadrantY * quadWidth();
|
||||
|
||||
for(Team team : Team.all){
|
||||
TeamData data = state.teams.get(team);
|
||||
for(TeamData data : state.teams.getActive()){
|
||||
GridBits bits = structQuadrant(data.team);
|
||||
|
||||
//fast-set this quadrant to 'occupied' if the tile just placed is already of this team
|
||||
if(tile.getTeam() == data.team && tile.entity != null && tile.block().targetable){
|
||||
structQuadrants[data.team.ordinal()].set(quadrantX, quadrantY);
|
||||
bits.set(quadrantX, quadrantY);
|
||||
continue; //no need to process futher
|
||||
}
|
||||
|
||||
structQuadrants[data.team.ordinal()].set(quadrantX, quadrantY, false);
|
||||
bits.set(quadrantX, quadrantY, false);
|
||||
|
||||
outer:
|
||||
for(int x = quadrantX * quadrantSize; x < world.width() && x < (quadrantX + 1) * quadrantSize; x++){
|
||||
@@ -334,7 +355,7 @@ public class BlockIndexer{
|
||||
Tile result = world.ltile(x, y);
|
||||
//when a targetable block is found, mark this quadrant as occupied and stop searching
|
||||
if(result.entity != null && result.getTeam() == data.team){
|
||||
structQuadrants[data.team.ordinal()].set(quadrantX, quadrantY);
|
||||
bits.set(quadrantX, quadrantY);
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
@@ -343,7 +364,7 @@ public class BlockIndexer{
|
||||
}
|
||||
|
||||
private boolean getQuad(Team team, int quadrantX, int quadrantY){
|
||||
return structQuadrants[team.ordinal()].get(quadrantX, quadrantY);
|
||||
return structQuadrant(team).get(quadrantX, quadrantY);
|
||||
}
|
||||
|
||||
private int quadWidth(){
|
||||
@@ -1,20 +1,20 @@
|
||||
package io.anuke.mindustry.ai;
|
||||
package mindustry.ai;
|
||||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.ArcAnnotate.*;
|
||||
import io.anuke.arc.util.async.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
import arc.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import arc.struct.*;
|
||||
import arc.func.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.async.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Pathfinder implements Runnable{
|
||||
private static final long maxUpdate = Time.millisToNanos(4);
|
||||
@@ -27,9 +27,9 @@ public class Pathfinder implements Runnable{
|
||||
/** unordered array of path data for iteration only. DO NOT iterate ot access this in the main thread.*/
|
||||
private Array<PathData> list = new Array<>();
|
||||
/** Maps teams + flags to a valid path to get to that flag for that team. */
|
||||
private PathData[][] pathMap = new PathData[Team.all.length][PathTarget.all.length];
|
||||
private PathData[][] pathMap = new PathData[Team.all().length][PathTarget.all.length];
|
||||
/** Grid map of created path data that should not be queued again. */
|
||||
private GridBits created = new GridBits(Team.all.length, PathTarget.all.length);
|
||||
private GridBits created = new GridBits(Team.all().length, PathTarget.all.length);
|
||||
/** handles task scheduling on the update thread. */
|
||||
private TaskQueue queue = new TaskQueue();
|
||||
/** current pathfinding thread */
|
||||
@@ -42,8 +42,8 @@ public class Pathfinder implements Runnable{
|
||||
|
||||
//reset and update internal tile array
|
||||
tiles = new int[world.width()][world.height()];
|
||||
pathMap = new PathData[Team.all.length][PathTarget.all.length];
|
||||
created = new GridBits(Team.all.length, PathTarget.all.length);
|
||||
pathMap = new PathData[Team.all().length][PathTarget.all.length];
|
||||
created = new GridBits(Team.all().length, PathTarget.all.length);
|
||||
list = new Array<>();
|
||||
|
||||
for(int x = 0; x < world.width(); x++){
|
||||
@@ -53,7 +53,7 @@ public class Pathfinder implements Runnable{
|
||||
}
|
||||
|
||||
//special preset which may help speed things up; this is optional
|
||||
preloadPath(waveTeam, PathTarget.enemyCores);
|
||||
preloadPath(state.rules.waveTeam, PathTarget.enemyCores);
|
||||
|
||||
start();
|
||||
});
|
||||
@@ -84,8 +84,8 @@ public class Pathfinder implements Runnable{
|
||||
}
|
||||
|
||||
public int debugValue(Team team, int x, int y){
|
||||
if(pathMap[team.ordinal()][PathTarget.enemyCores.ordinal()] == null) return 0;
|
||||
return pathMap[team.ordinal()][PathTarget.enemyCores.ordinal()].weights[x][y];
|
||||
if(pathMap[team.id][PathTarget.enemyCores.ordinal()] == null) return 0;
|
||||
return pathMap[team.id][PathTarget.enemyCores.ordinal()].weights[x][y];
|
||||
}
|
||||
|
||||
/** Update a tile in the internal pathfinding grid. Causes a complete pathfinding reclaculation. */
|
||||
@@ -149,12 +149,12 @@ public class Pathfinder implements Runnable{
|
||||
public Tile getTargetTile(Tile tile, Team team, PathTarget target){
|
||||
if(tile == null) return null;
|
||||
|
||||
PathData data = pathMap[team.ordinal()][target.ordinal()];
|
||||
PathData data = pathMap[team.id][target.ordinal()];
|
||||
|
||||
if(data == null){
|
||||
//if this combination is not found, create it on request
|
||||
if(!created.get(team.ordinal(), target.ordinal())){
|
||||
created.set(team.ordinal(), target.ordinal());
|
||||
if(!created.get(team.id, target.ordinal())){
|
||||
created.set(team.id, target.ordinal());
|
||||
//grab targets since this is run on main thread
|
||||
IntArray targets = target.getTargets(team, new IntArray());
|
||||
queue.post(() -> createPath(team, target, targets));
|
||||
@@ -188,7 +188,7 @@ public class Pathfinder implements Runnable{
|
||||
/** @return whether a tile can be passed through by this team. Pathfinding thread only.*/
|
||||
private boolean passable(int x, int y, Team team){
|
||||
int tile = tiles[x][y];
|
||||
return PathTile.passable(tile) || (PathTile.team(tile) != team.ordinal() && PathTile.team(tile) != Team.derelict.ordinal());
|
||||
return PathTile.passable(tile) || (PathTile.team(tile) != team.id && PathTile.team(tile) != (int)Team.derelict.id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,7 +238,7 @@ public class Pathfinder implements Runnable{
|
||||
PathData path = new PathData(team, target, world.width(), world.height());
|
||||
|
||||
list.add(path);
|
||||
pathMap[team.ordinal()][target.ordinal()] = path;
|
||||
pathMap[team.id][target.ordinal()] = path;
|
||||
|
||||
//grab targets from passed array
|
||||
synchronized(path.targets){
|
||||
@@ -303,7 +303,7 @@ public class Pathfinder implements Runnable{
|
||||
}
|
||||
|
||||
//spawn points are also enemies.
|
||||
if(state.rules.waves && team == defaultTeam){
|
||||
if(state.rules.waves && team == state.rules.defaultTeam){
|
||||
for(Tile other : spawner.getGroundSpawns()){
|
||||
out.add(other.pos());
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
package io.anuke.mindustry.ai;
|
||||
package mindustry.ai;
|
||||
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.func.Floatc2;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.Tmp;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
import io.anuke.mindustry.entities.Damage;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.type.BaseUnit;
|
||||
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
||||
import io.anuke.mindustry.game.SpawnGroup;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import arc.Events;
|
||||
import arc.struct.Array;
|
||||
import arc.func.Floatc2;
|
||||
import arc.math.Angles;
|
||||
import arc.math.Mathf;
|
||||
import arc.util.Time;
|
||||
import arc.util.Tmp;
|
||||
import mindustry.content.Blocks;
|
||||
import mindustry.content.Fx;
|
||||
import mindustry.entities.Damage;
|
||||
import mindustry.entities.Effects;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.EventType.WorldLoadEvent;
|
||||
import mindustry.game.SpawnGroup;
|
||||
import mindustry.world.Tile;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class WaveSpawner{
|
||||
private static final float margin = 40f, coreMargin = tilesize * 3; //how far away from the edge flying units spawn
|
||||
@@ -53,7 +53,7 @@ public class WaveSpawner{
|
||||
|
||||
eachFlyerSpawn((spawnX, spawnY) -> {
|
||||
for(int i = 0; i < spawned; i++){
|
||||
BaseUnit unit = group.createUnit(waveTeam);
|
||||
BaseUnit unit = group.createUnit(state.rules.waveTeam);
|
||||
unit.set(spawnX + Mathf.range(spread), spawnY + Mathf.range(spread));
|
||||
unit.add();
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class WaveSpawner{
|
||||
for(int i = 0; i < spawned; i++){
|
||||
Tmp.v1.rnd(spread);
|
||||
|
||||
BaseUnit unit = group.createUnit(waveTeam);
|
||||
BaseUnit unit = group.createUnit(state.rules.waveTeam);
|
||||
unit.set(spawnX + Tmp.v1.x, spawnY + Tmp.v1.y);
|
||||
|
||||
Time.run(Math.min(i * 5, 60 * 2), () -> spawnEffect(unit));
|
||||
@@ -78,7 +78,7 @@ public class WaveSpawner{
|
||||
eachGroundSpawn((spawnX, spawnY, doShockwave) -> {
|
||||
if(doShockwave){
|
||||
Time.run(20f, () -> Effects.effect(Fx.spawnShockwave, spawnX, spawnY, state.rules.dropZoneRadius));
|
||||
Time.run(40f, () -> Damage.damage(waveTeam, spawnX, spawnY, state.rules.dropZoneRadius, 99999999f, true));
|
||||
Time.run(40f, () -> Damage.damage(state.rules.waveTeam, spawnX, spawnY, state.rules.dropZoneRadius, 99999999f, true));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -90,11 +90,11 @@ public class WaveSpawner{
|
||||
cons.accept(spawn.worldx(), spawn.worldy(), true);
|
||||
}
|
||||
|
||||
if(state.rules.attackMode && state.teams.isActive(waveTeam) && !state.teams.get(defaultTeam).cores.isEmpty()){
|
||||
Tile firstCore = state.teams.get(defaultTeam).cores.first();
|
||||
for(Tile core : state.teams.get(waveTeam).cores){
|
||||
Tmp.v1.set(firstCore).sub(core.worldx(), core.worldy()).limit(coreMargin + core.block().size*tilesize);
|
||||
cons.accept(core.worldx() + Tmp.v1.x, core.worldy() + Tmp.v1.y, false);
|
||||
if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam) && !state.teams.playerCores().isEmpty()){
|
||||
TileEntity firstCore = state.teams.playerCores().first();
|
||||
for(TileEntity core : state.rules.waveTeam.cores()){
|
||||
Tmp.v1.set(firstCore).sub(core.x, core.y).limit(coreMargin + core.block.size*tilesize);
|
||||
cons.accept(core.x + Tmp.v1.x, core.y + Tmp.v1.y, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,9 +107,9 @@ public class WaveSpawner{
|
||||
cons.get(spawnX, spawnY);
|
||||
}
|
||||
|
||||
if(state.rules.attackMode && state.teams.isActive(waveTeam)){
|
||||
for(Tile core : state.teams.get(waveTeam).cores){
|
||||
cons.get(core.worldx(), core.worldy());
|
||||
if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam)){
|
||||
for(TileEntity core : state.teams.get(state.rules.waveTeam).cores){
|
||||
cons.get(core.x, core.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,34 @@
|
||||
package io.anuke.mindustry.content;
|
||||
package mindustry.content;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.ctype.ContentList;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.bullet.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.mindustry.world.blocks.defense.*;
|
||||
import io.anuke.mindustry.world.blocks.defense.turrets.*;
|
||||
import io.anuke.mindustry.world.blocks.distribution.*;
|
||||
import io.anuke.mindustry.world.blocks.liquid.Conduit;
|
||||
import io.anuke.mindustry.world.blocks.liquid.LiquidTank;
|
||||
import io.anuke.mindustry.world.blocks.logic.*;
|
||||
import io.anuke.mindustry.world.blocks.power.*;
|
||||
import io.anuke.mindustry.world.blocks.production.*;
|
||||
import io.anuke.mindustry.world.blocks.sandbox.*;
|
||||
import io.anuke.mindustry.world.blocks.storage.*;
|
||||
import io.anuke.mindustry.world.blocks.units.*;
|
||||
import io.anuke.mindustry.world.consumers.*;
|
||||
import io.anuke.mindustry.world.meta.*;
|
||||
import io.anuke.mindustry.world.modules.*;
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.blocks.defense.*;
|
||||
import mindustry.world.blocks.defense.turrets.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
import mindustry.world.blocks.liquid.*;
|
||||
import mindustry.world.blocks.logic.*;
|
||||
import mindustry.world.blocks.power.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.sandbox.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
import mindustry.world.blocks.units.*;
|
||||
import mindustry.world.consumers.*;
|
||||
import mindustry.world.meta.*;
|
||||
import mindustry.world.modules.*;
|
||||
|
||||
public class Blocks implements ContentList{
|
||||
public static Block
|
||||
@@ -485,7 +484,7 @@ public class Blocks implements ContentList{
|
||||
drawer = tile -> {
|
||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
GenericCrafterEntity entity = tile.ent();
|
||||
|
||||
Draw.alpha(Mathf.absin(entity.totalProgress, 3f, 0.9f) * entity.warmup);
|
||||
Draw.rect(reg(topRegion), tile.drawx(), tile.drawy());
|
||||
@@ -510,7 +509,7 @@ public class Blocks implements ContentList{
|
||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name + "-bottom"), Core.atlas.find(name), Core.atlas.find(name + "-weave")};
|
||||
|
||||
drawer = tile -> {
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
GenericCrafterEntity entity = tile.ent();
|
||||
|
||||
Draw.rect(reg(bottomRegion), tile.drawx(), tile.drawy());
|
||||
Draw.rect(reg(weaveRegion), tile.drawx(), tile.drawy(), entity.totalProgress);
|
||||
@@ -660,7 +659,7 @@ public class Blocks implements ContentList{
|
||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-top")};
|
||||
|
||||
drawer = tile -> {
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
GenericCrafterEntity entity = tile.ent();
|
||||
|
||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||
Draw.rect(reg(frameRegions[(int)Mathf.absin(entity.totalProgress, 5f, 2.999f)]), tile.drawx(), tile.drawy());
|
||||
@@ -687,7 +686,7 @@ public class Blocks implements ContentList{
|
||||
drawIcons = () -> new TextureRegion[]{Core.atlas.find(name), Core.atlas.find(name + "-rotator")};
|
||||
|
||||
drawer = tile -> {
|
||||
GenericCrafterEntity entity = tile.entity();
|
||||
GenericCrafterEntity entity = tile.ent();
|
||||
|
||||
Draw.rect(region, tile.drawx(), tile.drawy());
|
||||
Draw.rect(reg(rotatorRegion), tile.drawx(), tile.drawy(), entity.totalProgress * 2f);
|
||||
@@ -915,6 +914,7 @@ public class Blocks implements ContentList{
|
||||
phaseConveyor = new ItemBridge("phase-conveyor"){{
|
||||
requirements(Category.distribution, ItemStack.with(Items.phasefabric, 5, Items.silicon, 7, Items.lead, 10, Items.graphite, 10));
|
||||
range = 12;
|
||||
canOverdrive = false;
|
||||
hasPower = true;
|
||||
consumes.power(0.30f);
|
||||
}};
|
||||
@@ -977,7 +977,7 @@ public class Blocks implements ContentList{
|
||||
size = 3;
|
||||
}};
|
||||
|
||||
conduit = new io.anuke.mindustry.world.blocks.liquid.Conduit("conduit"){{
|
||||
conduit = new Conduit("conduit"){{
|
||||
requirements(Category.liquid, ItemStack.with(Items.metaglass, 1));
|
||||
health = 45;
|
||||
}};
|
||||
@@ -989,14 +989,14 @@ public class Blocks implements ContentList{
|
||||
health = 90;
|
||||
}};
|
||||
|
||||
platedConduit = new io.anuke.mindustry.world.blocks.liquid.ArmoredConduit("plated-conduit"){{
|
||||
requirements(Category.liquid, ItemStack.with(Items.thorium, 2, Items.metaglass, 1));
|
||||
platedConduit = new ArmoredConduit("plated-conduit"){{
|
||||
requirements(Category.liquid, ItemStack.with(Items.thorium, 2, Items.metaglass, 1, Items.plastanium, 1));
|
||||
liquidCapacity = 16f;
|
||||
liquidPressure = 1.025f;
|
||||
health = 220;
|
||||
}};
|
||||
|
||||
liquidRouter = new io.anuke.mindustry.world.blocks.liquid.LiquidRouter("liquid-router"){{
|
||||
liquidRouter = new LiquidRouter("liquid-router"){{
|
||||
requirements(Category.liquid, ItemStack.with(Items.graphite, 4, Items.metaglass, 2));
|
||||
liquidCapacity = 20f;
|
||||
}};
|
||||
@@ -1008,20 +1008,21 @@ public class Blocks implements ContentList{
|
||||
health = 500;
|
||||
}};
|
||||
|
||||
liquidJunction = new io.anuke.mindustry.world.blocks.liquid.LiquidJunction("liquid-junction"){{
|
||||
liquidJunction = new LiquidJunction("liquid-junction"){{
|
||||
requirements(Category.liquid, ItemStack.with(Items.graphite, 2, Items.metaglass, 2));
|
||||
}};
|
||||
|
||||
bridgeConduit = new io.anuke.mindustry.world.blocks.liquid.LiquidExtendingBridge("bridge-conduit"){{
|
||||
bridgeConduit = new LiquidExtendingBridge("bridge-conduit"){{
|
||||
requirements(Category.liquid, ItemStack.with(Items.graphite, 4, Items.metaglass, 8));
|
||||
range = 4;
|
||||
hasPower = false;
|
||||
}};
|
||||
|
||||
phaseConduit = new io.anuke.mindustry.world.blocks.liquid.LiquidBridge("phase-conduit"){{
|
||||
phaseConduit = new LiquidBridge("phase-conduit"){{
|
||||
requirements(Category.liquid, ItemStack.with(Items.phasefabric, 5, Items.silicon, 7, Items.metaglass, 20, Items.titanium, 10));
|
||||
range = 12;
|
||||
hasPower = true;
|
||||
canOverdrive = false;
|
||||
consumes.power(0.30f);
|
||||
}};
|
||||
|
||||
@@ -1362,7 +1363,7 @@ public class Blocks implements ContentList{
|
||||
ammo(
|
||||
Items.graphite, Bullets.artilleryDense,
|
||||
Items.silicon, Bullets.artilleryHoming,
|
||||
Items.pyratite, Bullets.artlleryIncendiary
|
||||
Items.pyratite, Bullets.artilleryIncendiary
|
||||
);
|
||||
reload = 60f;
|
||||
recoil = 2f;
|
||||
@@ -1390,15 +1391,6 @@ public class Blocks implements ContentList{
|
||||
range = 110f;
|
||||
health = 250 * size * size;
|
||||
shootSound = Sounds.splash;
|
||||
|
||||
drawer = (tile, entity) -> {
|
||||
Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||
|
||||
Draw.color(entity.liquids.current().color);
|
||||
Draw.alpha(entity.liquids.total() / liquidCapacity);
|
||||
Draw.rect(name + "-liquid", tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||
Draw.color();
|
||||
};
|
||||
}};
|
||||
|
||||
lancer = new ChargeTurret("lancer"){{
|
||||
@@ -1513,7 +1505,7 @@ public class Blocks implements ContentList{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(io.anuke.mindustry.entities.type.Bullet b){
|
||||
public void init(mindustry.entities.type.Bullet b){
|
||||
for(int i = 0; i < rays; i++){
|
||||
Damage.collideLine(b, b.getTeam(), hitEffect, b.x, b.y, b.rot(), rayLength - Math.abs(i - (rays / 2)) * 20f);
|
||||
}
|
||||
@@ -1542,9 +1534,9 @@ public class Blocks implements ContentList{
|
||||
ammo(
|
||||
Items.graphite, Bullets.artilleryDense,
|
||||
Items.silicon, Bullets.artilleryHoming,
|
||||
Items.pyratite, Bullets.artlleryIncendiary,
|
||||
Items.pyratite, Bullets.artilleryIncendiary,
|
||||
Items.blastCompound, Bullets.artilleryExplosive,
|
||||
Items.plastanium, Bullets.arilleryPlastic
|
||||
Items.plastanium, Bullets.artilleryPlastic
|
||||
);
|
||||
size = 3;
|
||||
shots = 4;
|
||||
@@ -1,24 +1,24 @@
|
||||
package io.anuke.mindustry.content;
|
||||
package mindustry.content;
|
||||
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.ctype.ContentList;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.bullet.*;
|
||||
import io.anuke.mindustry.entities.effect.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.ctype.ContentList;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Bullets implements ContentList{
|
||||
public static BulletType
|
||||
|
||||
//artillery
|
||||
artilleryDense, arilleryPlastic, artilleryPlasticFrag, artilleryHoming, artlleryIncendiary, artilleryExplosive, artilleryUnit,
|
||||
artilleryDense, artilleryPlastic, artilleryPlasticFrag, artilleryHoming, artilleryIncendiary, artilleryExplosive, artilleryUnit,
|
||||
|
||||
//flak
|
||||
flakScrap, flakLead, flakPlastic, flakExplosive, flakSurge, flakGlass, glassFrag,
|
||||
@@ -65,7 +65,7 @@ public class Bullets implements ContentList{
|
||||
despawnEffect = Fx.none;
|
||||
}};
|
||||
|
||||
arilleryPlastic = new ArtilleryBulletType(3.4f, 0, "shell"){{
|
||||
artilleryPlastic = new ArtilleryBulletType(3.4f, 0, "shell"){{
|
||||
hitEffect = Fx.plasticExplosion;
|
||||
knockback = 1f;
|
||||
lifetime = 55f;
|
||||
@@ -91,7 +91,7 @@ public class Bullets implements ContentList{
|
||||
homingRange = 50f;
|
||||
}};
|
||||
|
||||
artlleryIncendiary = new ArtilleryBulletType(3f, 0, "shell"){{
|
||||
artilleryIncendiary = new ArtilleryBulletType(3f, 0, "shell"){{
|
||||
hitEffect = Fx.blastExplosion;
|
||||
knockback = 0.8f;
|
||||
lifetime = 60f;
|
||||
@@ -1,19 +1,19 @@
|
||||
package io.anuke.mindustry.content;
|
||||
package mindustry.content;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.ctype.ContentList;
|
||||
import io.anuke.mindustry.entities.Effects.*;
|
||||
import io.anuke.mindustry.entities.effect.GroundEffectEntity.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.ui.Cicon;
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.ctype.ContentList;
|
||||
import mindustry.entities.Effects.*;
|
||||
import mindustry.entities.effect.GroundEffectEntity.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.Cicon;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Fx implements ContentList{
|
||||
public static Effect
|
||||
@@ -48,28 +48,24 @@ public class Fx implements ContentList{
|
||||
Draw.rect(unit.getIconRegion(), e.x, e.y,
|
||||
unit.getIconRegion().getWidth() * Draw.scl * scl, unit.getIconRegion().getWidth() * Draw.scl * scl, 180f);
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
commandSend = new Effect(28, e -> {
|
||||
Draw.color(Pal.command);
|
||||
Lines.stroke(e.fout() * 2f);
|
||||
Lines.circle(e.x, e.y, 4f + e.finpow() * 120f);
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
placeBlock = new Effect(16, e -> {
|
||||
Draw.color(Pal.accent);
|
||||
Lines.stroke(3f - e.fin() * 2f);
|
||||
Lines.square(e.x, e.y, tilesize / 2f * e.rotation + e.fin() * 3f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
tapBlock = new Effect(12, e -> {
|
||||
Draw.color(Pal.accent);
|
||||
Lines.stroke(3f - e.fin() * 2f);
|
||||
Lines.circle(e.x, e.y, 4f + (tilesize / 1.5f * e.rotation) * e.fin());
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
breakBlock = new Effect(12, e -> {
|
||||
@@ -80,41 +76,35 @@ public class Fx implements ContentList{
|
||||
Angles.randLenVectors(e.id, 3 + (int)(e.rotation * 3), e.rotation * 2f + (tilesize * e.rotation) * e.finpow(), (x, y) -> {
|
||||
Fill.square(e.x + x, e.y + y, 1f + e.fout() * (3f + e.rotation));
|
||||
});
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
select = new Effect(23, e -> {
|
||||
Draw.color(Pal.accent);
|
||||
Lines.stroke(e.fout() * 3f);
|
||||
Lines.circle(e.x, e.y, 3f + e.fin() * 14f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
smoke = new Effect(100, e -> {
|
||||
Draw.color(Color.gray, Pal.darkishGray, e.fin());
|
||||
float size = 7f - e.fin() * 7f;
|
||||
Draw.rect("circle", e.x, e.y, size, size);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
magmasmoke = new Effect(110, e -> {
|
||||
Draw.color(Color.gray);
|
||||
Fill.circle(e.x, e.y, e.fslope() * 6f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
spawn = new Effect(30, e -> {
|
||||
Lines.stroke(2f * e.fout());
|
||||
Draw.color(Pal.accent);
|
||||
Lines.poly(e.x, e.y, 4, 5f + e.fin() * 12f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
padlaunch = new Effect(10, e -> {
|
||||
Lines.stroke(4f * e.fout());
|
||||
Draw.color(Pal.accent);
|
||||
Lines.poly(e.x, e.y, 4, 5f + e.fin() * 60f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
vtolHover = new Effect(40f, e -> {
|
||||
@@ -122,7 +112,6 @@ public class Fx implements ContentList{
|
||||
float ang = e.rotation + Mathf.randomSeedRange(e.id, 30f);
|
||||
Draw.color(Pal.lightFlame, Pal.lightOrange, e.fin());
|
||||
Fill.circle(e.x + Angles.trnsx(ang, len), e.y + Angles.trnsy(ang, len), 2f * e.fout());
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
unitDrop = new GroundEffect(30, e -> {
|
||||
@@ -130,7 +119,6 @@ public class Fx implements ContentList{
|
||||
Angles.randLenVectors(e.id, 9, 3 + 20f * e.finpow(), (x, y) -> {
|
||||
Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.4f);
|
||||
});
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
unitLand = new GroundEffect(30, e -> {
|
||||
@@ -138,42 +126,36 @@ public class Fx implements ContentList{
|
||||
Angles.randLenVectors(e.id, 6, 17f * e.finpow(), (x, y) -> {
|
||||
Fill.circle(e.x + x, e.y + y, e.fout() * 4f + 0.3f);
|
||||
});
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
unitPickup = new GroundEffect(18, e -> {
|
||||
Draw.color(Pal.lightishGray);
|
||||
Lines.stroke(e.fin() * 2f);
|
||||
Lines.poly(e.x, e.y, 4, 13f * e.fout());
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
landShock = new GroundEffect(12, e -> {
|
||||
Draw.color(Pal.lancerLaser);
|
||||
Lines.stroke(e.fout() * 3f);
|
||||
Lines.poly(e.x, e.y, 12, 20f * e.fout());
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
pickup = new Effect(18, e -> {
|
||||
Draw.color(Pal.lightishGray);
|
||||
Lines.stroke(e.fout() * 2f);
|
||||
Lines.spikes(e.x, e.y, 1f + e.fin() * 6f, e.fout() * 4f, 6);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
healWave = new Effect(22, e -> {
|
||||
Draw.color(Pal.heal);
|
||||
Lines.stroke(e.fout() * 2f);
|
||||
Lines.circle(e.x, e.y, 4f + e.finpow() * 60f);
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
heal = new Effect(11, e -> {
|
||||
Draw.color(Pal.heal);
|
||||
Lines.stroke(e.fout() * 2f);
|
||||
Lines.circle(e.x, e.y, 2f + e.finpow() * 7f);
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
hitBulletSmall = new Effect(14, e -> {
|
||||
@@ -192,7 +174,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 3 + 1f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
hitFuse = new Effect(14, e -> {
|
||||
@@ -211,7 +192,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 3 + 1f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
hitBulletBig = new Effect(13, e -> {
|
||||
@@ -223,7 +203,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1.5f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
hitFlameSmall = new Effect(14, e -> {
|
||||
@@ -235,7 +214,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 3 + 1f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
hitLiquid = new Effect(16, e -> {
|
||||
@@ -245,7 +223,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, e.fout() * 2f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
hitLancer = new Effect(12, e -> {
|
||||
@@ -257,7 +234,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
hitMeltdown = new Effect(12, e -> {
|
||||
@@ -269,14 +245,12 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 4 + 1f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
hitLaser = new Effect(8, e -> {
|
||||
Draw.color(Color.white, Pal.heal, e.fin());
|
||||
Lines.stroke(0.5f + e.fout());
|
||||
Lines.circle(e.x, e.y, e.fin() * 5f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
hitYellowLaser = new Effect(8, e -> {
|
||||
@@ -295,7 +269,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, ang, e.fout() * 2 + 1f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
flakExplosion = new Effect(20, e -> {
|
||||
@@ -319,7 +292,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
plasticExplosion = new Effect(24, e -> {
|
||||
@@ -343,7 +315,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
plasticExplosionFlak = new Effect(28, e -> {
|
||||
@@ -367,7 +338,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
blastExplosion = new Effect(22, e -> {
|
||||
@@ -391,32 +361,27 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
artilleryTrail = new Effect(50, e -> {
|
||||
Draw.color(e.color);
|
||||
Fill.circle(e.x, e.y, e.rotation * e.fout());
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
incendTrail = new Effect(50, e -> {
|
||||
Draw.color(Pal.lightOrange);
|
||||
Fill.circle(e.x, e.y, e.rotation * e.fout());
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
missileTrail = new Effect(50, e -> {
|
||||
Draw.color(e.color);
|
||||
Fill.circle(e.x, e.y, e.rotation * e.fout());
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
absorb = new Effect(12, e -> {
|
||||
Draw.color(Pal.accent);
|
||||
Lines.stroke(2f * e.fout());
|
||||
Lines.circle(e.x, e.y, 5f * e.fout());
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
flakExplosionBig = new Effect(30, e -> {
|
||||
@@ -440,7 +405,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
|
||||
@@ -451,7 +415,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, 0.1f + e.fout() * 1.4f);
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
fire = new Effect(50f, e -> {
|
||||
@@ -473,7 +436,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f);
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
steam = new Effect(35f, e -> {
|
||||
@@ -483,7 +445,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, 0.2f + e.fslope() * 1.5f);
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
fireballsmoke = new Effect(25f, e -> {
|
||||
@@ -493,7 +454,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f);
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
ballfire = new Effect(25f, e -> {
|
||||
@@ -503,7 +463,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, 0.2f + e.fout() * 1.5f);
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
freezing = new Effect(40f, e -> {
|
||||
@@ -513,7 +472,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, e.fout() * 1.2f);
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
melting = new Effect(40f, e -> {
|
||||
@@ -523,7 +481,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, .2f + e.fout() * 1.2f);
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
wet = new Effect(40f, e -> {
|
||||
@@ -533,7 +490,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, e.fout() * 1f);
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
oily = new Effect(42f, e -> {
|
||||
@@ -543,7 +499,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, e.fout() * 1f);
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
overdriven = new Effect(20f, e -> {
|
||||
@@ -553,7 +508,6 @@ public class Fx implements ContentList{
|
||||
Fill.square(e.x + x, e.y + y, e.fout() * 2.3f + 0.5f);
|
||||
});
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
dropItem = new Effect(20f, e -> {
|
||||
@@ -568,35 +522,30 @@ public class Fx implements ContentList{
|
||||
Draw.color(Color.white, Color.lightGray, e.fin());
|
||||
Lines.stroke(e.fout() * 2f + 0.2f);
|
||||
Lines.circle(e.x, e.y, e.fin() * 28f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
bigShockwave = new Effect(10f, 80f, e -> {
|
||||
Draw.color(Color.white, Color.lightGray, e.fin());
|
||||
Lines.stroke(e.fout() * 3f);
|
||||
Lines.circle(e.x, e.y, e.fin() * 50f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
nuclearShockwave = new Effect(10f, 200f, e -> {
|
||||
Draw.color(Color.white, Color.lightGray, e.fin());
|
||||
Lines.stroke(e.fout() * 3f + 0.2f);
|
||||
Lines.circle(e.x, e.y, e.fin() * 140f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
impactShockwave = new Effect(13f, 300f, e -> {
|
||||
Draw.color(Pal.lighterOrange, Color.lightGray, e.fin());
|
||||
Lines.stroke(e.fout() * 4f + 0.2f);
|
||||
Lines.circle(e.x, e.y, e.fin() * 200f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
spawnShockwave = new Effect(20f, 400f, e -> {
|
||||
Draw.color(Color.white, Color.lightGray, e.fin());
|
||||
Lines.stroke(e.fout() * 3f + 0.5f);
|
||||
Lines.circle(e.x, e.y, e.fin() * (e.rotation + 50f));
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
explosion = new Effect(30, e -> {
|
||||
@@ -619,7 +568,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
dynamicExplosion = new Effect(30, e -> {
|
||||
@@ -644,7 +592,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + out * 4 * (3f + intensity));
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
blockExplosion = new Effect(30, e -> {
|
||||
@@ -667,7 +614,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), 1f + e.fout() * 3f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
blockExplosionSmoke = new Effect(30, e -> {
|
||||
@@ -678,7 +624,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x / 2f, e.y + y / 2f, e.fout() * 1f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
|
||||
@@ -687,7 +632,6 @@ public class Fx implements ContentList{
|
||||
float w = 1f + 5 * e.fout();
|
||||
Drawf.tri(e.x, e.y, w, 15f * e.fout(), e.rotation);
|
||||
Drawf.tri(e.x, e.y, w, 3f * e.fout(), e.rotation + 180f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
shootHeal = new Effect(8, e -> {
|
||||
@@ -695,7 +639,6 @@ public class Fx implements ContentList{
|
||||
float w = 1f + 5 * e.fout();
|
||||
Drawf.tri(e.x, e.y, w, 17f * e.fout(), e.rotation);
|
||||
Drawf.tri(e.x, e.y, w, 4f * e.fout(), e.rotation + 180f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
shootHealYellow = new Effect(8, e -> {
|
||||
@@ -713,7 +656,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, e.fout() * 1.5f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
shootBig = new Effect(9, e -> {
|
||||
@@ -721,7 +663,6 @@ public class Fx implements ContentList{
|
||||
float w = 1.2f + 7 * e.fout();
|
||||
Drawf.tri(e.x, e.y, w, 25f * e.fout(), e.rotation);
|
||||
Drawf.tri(e.x, e.y, w, 4f * e.fout(), e.rotation + 180f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
shootBig2 = new Effect(10, e -> {
|
||||
@@ -729,7 +670,6 @@ public class Fx implements ContentList{
|
||||
float w = 1.2f + 8 * e.fout();
|
||||
Drawf.tri(e.x, e.y, w, 29f * e.fout(), e.rotation);
|
||||
Drawf.tri(e.x, e.y, w, 5f * e.fout(), e.rotation + 180f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
shootBigSmoke = new Effect(17f, e -> {
|
||||
@@ -739,7 +679,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, e.fout() * 2f + 0.2f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
shootBigSmoke2 = new Effect(18f, e -> {
|
||||
@@ -749,7 +688,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, e.fout() * 2.4f + 0.2f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
shootSmallFlame = new Effect(32f, e -> {
|
||||
@@ -759,7 +697,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, 0.65f + e.fout() * 1.5f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
shootPyraFlame = new Effect(33f, e -> {
|
||||
@@ -769,7 +706,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, 0.65f + e.fout() * 1.6f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
shootLiquid = new Effect(40f, e -> {
|
||||
@@ -779,7 +715,6 @@ public class Fx implements ContentList{
|
||||
Fill.circle(e.x + x, e.y + y, 0.5f + e.fout() * 2.5f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
shellEjectSmall = new GroundEffect(30f, 400f, e -> {
|
||||
@@ -794,7 +729,6 @@ public class Fx implements ContentList{
|
||||
e.y + Angles.trnsy(lr, len) + Mathf.randomSeedRange(e.id + i + 8, 3f * e.fin()),
|
||||
1f, 2f, rot + e.fin() * 50f * i);
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
shellEjectMedium = new GroundEffect(34f, 400f, e -> {
|
||||
@@ -818,7 +752,6 @@ public class Fx implements ContentList{
|
||||
});
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
shellEjectBig = new GroundEffect(22f, 400f, e -> {
|
||||
@@ -843,7 +776,6 @@ public class Fx implements ContentList{
|
||||
});
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
lancerLaserShoot = new Effect(21f, e -> {
|
||||
@@ -853,7 +785,6 @@ public class Fx implements ContentList{
|
||||
Drawf.tri(e.x, e.y, 4f * e.fout(), 29f, e.rotation + 90f * i);
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
lancerLaserShootSmoke = new Effect(26f, e -> {
|
||||
@@ -863,7 +794,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fout() * 9f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
lancerLaserCharge = new Effect(38f, e -> {
|
||||
@@ -873,7 +803,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fslope() * 3f + 1f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
lancerLaserChargeBegin = new Effect(60f, e -> {
|
||||
@@ -891,7 +820,6 @@ public class Fx implements ContentList{
|
||||
Drawf.tri(e.x + x, e.y + y, e.fslope() * 3f + 1, e.fslope() * 3f + 1, Mathf.angle(x, y));
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
lightningShoot = new Effect(12f, e -> {
|
||||
@@ -902,7 +830,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fin() * 5f + 2f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
|
||||
@@ -911,7 +838,6 @@ public class Fx implements ContentList{
|
||||
float size = 1f + e.fout() * 5f;
|
||||
Draw.color(Color.lightGray, Color.gray, e.fin());
|
||||
Draw.rect("circle", e.x + x, e.y + y, size, size);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
nuclearsmoke = new Effect(40, e -> {
|
||||
@@ -919,7 +845,6 @@ public class Fx implements ContentList{
|
||||
float size = e.fslope() * 4f;
|
||||
Draw.color(Color.lightGray, Color.gray, e.fin());
|
||||
Draw.rect("circle", e.x + x, e.y + y, size, size);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
nuclearcloud = new Effect(90, 200f, e -> {
|
||||
@@ -927,7 +852,6 @@ public class Fx implements ContentList{
|
||||
float size = e.fout() * 14f;
|
||||
Draw.color(Color.lime, Color.gray, e.fin());
|
||||
Draw.rect("circle", e.x + x, e.y + y, size, size);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
impactsmoke = new Effect(60, e -> {
|
||||
@@ -935,7 +859,6 @@ public class Fx implements ContentList{
|
||||
float size = e.fslope() * 4f;
|
||||
Draw.color(Color.lightGray, Color.gray, e.fin());
|
||||
Draw.rect("circle", e.x + x, e.y + y, size, size);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
impactcloud = new Effect(140, 400f, e -> {
|
||||
@@ -943,7 +866,6 @@ public class Fx implements ContentList{
|
||||
float size = e.fout() * 15f;
|
||||
Draw.color(Pal.lighterOrange, Color.lightGray, e.fin());
|
||||
Draw.rect("circle", e.x + x, e.y + y, size, size);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
redgeneratespark = new Effect(18, e -> {
|
||||
@@ -951,7 +873,6 @@ public class Fx implements ContentList{
|
||||
float len = e.fout() * 4f;
|
||||
Draw.color(Pal.redSpark, Color.gray, e.fin());
|
||||
Draw.rect("circle", e.x + x, e.y + y, len, len);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
generatespark = new Effect(18, e -> {
|
||||
@@ -959,7 +880,6 @@ public class Fx implements ContentList{
|
||||
float len = e.fout() * 4f;
|
||||
Draw.color(Pal.orangeSpark, Color.gray, e.fin());
|
||||
Draw.rect("circle", e.x + x, e.y + y, len, len);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
fuelburn = new Effect(23, e -> {
|
||||
@@ -967,70 +887,60 @@ public class Fx implements ContentList{
|
||||
float len = e.fout() * 4f;
|
||||
Draw.color(Color.lightGray, Color.gray, e.fin());
|
||||
Draw.rect("circle", e.x + x, e.y + y, len, len);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
plasticburn = new Effect(40, e -> {
|
||||
Angles.randLenVectors(e.id, 5, 3f + e.fin() * 5f, (x, y) -> {
|
||||
Draw.color(Color.valueOf("e9ead3"), Color.gray, e.fin());
|
||||
Fill.circle(e.x + x, e.y + y, e.fout() * 1f);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
pulverize = new Effect(40, e -> {
|
||||
Angles.randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> {
|
||||
Draw.color(Pal.stoneGray);
|
||||
Fill.square(e.x + x, e.y + y, e.fout() * 2f + 0.5f, 45);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
pulverizeRed = new Effect(40, e -> {
|
||||
Angles.randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> {
|
||||
Draw.color(Pal.redDust, Pal.stoneGray, e.fin());
|
||||
Fill.square(e.x + x, e.y + y, e.fout() * 2f + 0.5f, 45);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
pulverizeRedder = new Effect(40, e -> {
|
||||
Angles.randLenVectors(e.id, 5, 3f + e.fin() * 9f, (x, y) -> {
|
||||
Draw.color(Pal.redderDust, Pal.stoneGray, e.fin());
|
||||
Fill.square(e.x + x, e.y + y, e.fout() * 2.5f + 0.5f, 45);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
pulverizeSmall = new Effect(30, e -> {
|
||||
Angles.randLenVectors(e.id, 3, e.fin() * 5f, (x, y) -> {
|
||||
Draw.color(Pal.stoneGray);
|
||||
Fill.square(e.x + x, e.y + y, e.fout() * 1f + 0.5f, 45);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
pulverizeMedium = new Effect(30, e -> {
|
||||
Angles.randLenVectors(e.id, 5, 3f + e.fin() * 8f, (x, y) -> {
|
||||
Draw.color(Pal.stoneGray);
|
||||
Fill.square(e.x + x, e.y + y, e.fout() * 1f + 0.5f, 45);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
producesmoke = new Effect(12, e -> {
|
||||
Angles.randLenVectors(e.id, 8, 4f + e.fin() * 18f, (x, y) -> {
|
||||
Draw.color(Color.white, Pal.accent, e.fin());
|
||||
Fill.square(e.x + x, e.y + y, 1f + e.fout() * 3f, 45);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
smeltsmoke = new Effect(15, e -> {
|
||||
Angles.randLenVectors(e.id, 6, 4f + e.fin() * 5f, (x, y) -> {
|
||||
Draw.color(Color.white, e.color, e.fin());
|
||||
Fill.square(e.x + x, e.y + y, 0.5f + e.fout() * 2f, 45);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
formsmoke = new Effect(40, e -> {
|
||||
Angles.randLenVectors(e.id, 6, 5f + e.fin() * 8f, (x, y) -> {
|
||||
Draw.color(Pal.plasticSmoke, Color.lightGray, e.fin());
|
||||
Fill.square(e.x + x, e.y + y, 0.2f + e.fout() * 2f, 45);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
blastsmoke = new Effect(26, e -> {
|
||||
@@ -1038,7 +948,6 @@ public class Fx implements ContentList{
|
||||
float size = 2f + e.fout() * 6f;
|
||||
Draw.color(Color.lightGray, Color.darkGray, e.fin());
|
||||
Draw.rect("circle", e.x + x, e.y + y, size, size);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
lava = new Effect(18, e -> {
|
||||
@@ -1046,79 +955,66 @@ public class Fx implements ContentList{
|
||||
float size = e.fslope() * 4f;
|
||||
Draw.color(Color.orange, Color.gray, e.fin());
|
||||
Draw.rect("circle", e.x + x, e.y + y, size, size);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
dooropen = new Effect(10, e -> {
|
||||
Lines.stroke(e.fout() * 1.6f);
|
||||
Lines.square(e.x, e.y, tilesize / 2f + e.fin() * 2f);
|
||||
Draw.reset();
|
||||
});
|
||||
doorclose = new Effect(10, e -> {
|
||||
Lines.stroke(e.fout() * 1.6f);
|
||||
Lines.square(e.x, e.y, tilesize / 2f + e.fout() * 2f);
|
||||
Draw.reset();
|
||||
});
|
||||
dooropenlarge = new Effect(10, e -> {
|
||||
Lines.stroke(e.fout() * 1.6f);
|
||||
Lines.square(e.x, e.y, tilesize + e.fin() * 2f);
|
||||
Draw.reset();
|
||||
});
|
||||
doorcloselarge = new Effect(10, e -> {
|
||||
Lines.stroke(e.fout() * 1.6f);
|
||||
Lines.square(e.x, e.y, tilesize + e.fout() * 2f);
|
||||
Draw.reset();
|
||||
});
|
||||
purify = new Effect(10, e -> {
|
||||
Draw.color(Color.royal, Color.gray, e.fin());
|
||||
Lines.stroke(2f);
|
||||
Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6);
|
||||
Draw.reset();
|
||||
});
|
||||
purifyoil = new Effect(10, e -> {
|
||||
Draw.color(Color.black, Color.gray, e.fin());
|
||||
Lines.stroke(2f);
|
||||
Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6);
|
||||
Draw.reset();
|
||||
});
|
||||
purifystone = new Effect(10, e -> {
|
||||
Draw.color(Color.orange, Color.gray, e.fin());
|
||||
Lines.stroke(2f);
|
||||
Lines.spikes(e.x, e.y, e.fin() * 4f, 2, 6);
|
||||
Draw.reset();
|
||||
});
|
||||
generate = new Effect(11, e -> {
|
||||
Draw.color(Color.orange, Color.yellow, e.fin());
|
||||
Lines.stroke(1f);
|
||||
Lines.spikes(e.x, e.y, e.fin() * 5f, 2, 8);
|
||||
Draw.reset();
|
||||
});
|
||||
mine = new Effect(20, e -> {
|
||||
Angles.randLenVectors(e.id, 6, 3f + e.fin() * 6f, (x, y) -> {
|
||||
Draw.color(e.color, Color.lightGray, e.fin());
|
||||
Fill.square(e.x + x, e.y + y, e.fout() * 2f, 45);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
mineBig = new Effect(30, e -> {
|
||||
Angles.randLenVectors(e.id, 6, 4f + e.fin() * 8f, (x, y) -> {
|
||||
Draw.color(e.color, Color.lightGray, e.fin());
|
||||
Fill.square(e.x + x, e.y + y, e.fout() * 2f + 0.2f, 45);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
mineHuge = new Effect(40, e -> {
|
||||
Angles.randLenVectors(e.id, 8, 5f + e.fin() * 10f, (x, y) -> {
|
||||
Draw.color(e.color, Color.lightGray, e.fin());
|
||||
Fill.square(e.x + x, e.y + y, e.fout() * 2f + 0.5f, 45);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
smelt = new Effect(20, e -> {
|
||||
Angles.randLenVectors(e.id, 6, 2f + e.fin() * 5f, (x, y) -> {
|
||||
Draw.color(Color.white, e.color, e.fin());
|
||||
Fill.square(e.x + x, e.y + y, 0.5f + e.fout() * 2f, 45);
|
||||
Draw.reset();
|
||||
});
|
||||
});
|
||||
teleportActivate = new Effect(50, e -> {
|
||||
@@ -1135,7 +1031,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fin() * 4f + 1f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
teleport = new Effect(60, e -> {
|
||||
Draw.color(e.color);
|
||||
@@ -1146,7 +1041,6 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fin() * 4f + 1f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
teleportOut = new Effect(20, e -> {
|
||||
Draw.color(e.color);
|
||||
@@ -1157,13 +1051,11 @@ public class Fx implements ContentList{
|
||||
Lines.lineAngle(e.x + x, e.y + y, Mathf.angle(x, y), e.fslope() * 4f + 1f);
|
||||
});
|
||||
|
||||
Draw.reset();
|
||||
});
|
||||
ripple = new GroundEffect(false, 30, e -> {
|
||||
Draw.color(Tmp.c1.set(e.color).mul(1.2f));
|
||||
Lines.stroke(e.fout() + 0.4f);
|
||||
Lines.circle(e.x, e.y, 2f + e.fin() * 4f);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
bubble = new Effect(20, e -> {
|
||||
@@ -1172,56 +1064,48 @@ public class Fx implements ContentList{
|
||||
Angles.randLenVectors(e.id, 2, 8f, (x, y) -> {
|
||||
Lines.circle(e.x + x, e.y + y, 1f + e.fin() * 3f);
|
||||
});
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
launch = new Effect(28, e -> {
|
||||
Draw.color(Pal.command);
|
||||
Lines.stroke(e.fout() * 2f);
|
||||
Lines.circle(e.x, e.y, 4f + e.finpow() * 120f);
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
healWaveMend = new Effect(40, e -> {
|
||||
Draw.color(e.color);
|
||||
Lines.stroke(e.fout() * 2f);
|
||||
Lines.circle(e.x, e.y, e.finpow() * e.rotation);
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
overdriveWave = new Effect(50, e -> {
|
||||
Draw.color(e.color);
|
||||
Lines.stroke(e.fout() * 1f);
|
||||
Lines.circle(e.x, e.y, e.finpow() * e.rotation);
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
healBlock = new Effect(20, e -> {
|
||||
Draw.color(Pal.heal);
|
||||
Lines.stroke(2f * e.fout() + 0.5f);
|
||||
Lines.square(e.x, e.y, 1f + (e.fin() * e.rotation * tilesize / 2f - 1f));
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
healBlockFull = new Effect(20, e -> {
|
||||
Draw.color(e.color);
|
||||
Draw.alpha(e.fout());
|
||||
Fill.square(e.x, e.y, e.rotation * tilesize / 2f);
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
overdriveBlockFull = new Effect(60, e -> {
|
||||
Draw.color(e.color);
|
||||
Draw.alpha(e.fslope() * 0.4f);
|
||||
Fill.square(e.x, e.y, e.rotation * tilesize);
|
||||
Draw.color();
|
||||
});
|
||||
|
||||
shieldBreak = new Effect(40, e -> {
|
||||
Draw.color(Pal.accent);
|
||||
Lines.stroke(3f * e.fout());
|
||||
Lines.poly(e.x, e.y, 6, e.rotation + e.fin(), 90);
|
||||
Draw.reset();
|
||||
});
|
||||
|
||||
coreLand = new Effect(120f, e -> {
|
||||
@@ -1,9 +1,9 @@
|
||||
package io.anuke.mindustry.content;
|
||||
package mindustry.content;
|
||||
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.mindustry.ctype.ContentList;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemType;
|
||||
import arc.graphics.Color;
|
||||
import mindustry.ctype.ContentList;
|
||||
import mindustry.type.Item;
|
||||
import mindustry.type.ItemType;
|
||||
|
||||
public class Items implements ContentList{
|
||||
public static Item scrap, copper, lead, graphite, coal, titanium, thorium, silicon, plastanium, phasefabric, surgealloy,
|
||||
@@ -1,8 +1,8 @@
|
||||
package io.anuke.mindustry.content;
|
||||
package mindustry.content;
|
||||
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.mindustry.ctype.ContentList;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import arc.graphics.Color;
|
||||
import mindustry.ctype.ContentList;
|
||||
import mindustry.type.Liquid;
|
||||
|
||||
public class Liquids implements ContentList{
|
||||
public static Liquid water, slag, oil, cryofluid;
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.anuke.mindustry.content;
|
||||
package mindustry.content;
|
||||
|
||||
import io.anuke.mindustry.ctype.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.game.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package io.anuke.mindustry.content;
|
||||
package mindustry.content;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.ctype.ContentList;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.bullet.*;
|
||||
import io.anuke.mindustry.entities.effect.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.indexer;
|
||||
import static mindustry.Vars.indexer;
|
||||
|
||||
public class Mechs implements ContentList{
|
||||
public static Mech vanguard, alpha, delta, tau, omega, dart, javelin, trident, glaive;
|
||||
106
core/src/mindustry/content/StatusEffects.java
Normal file
106
core/src/mindustry/content/StatusEffects.java
Normal file
@@ -0,0 +1,106 @@
|
||||
package mindustry.content;
|
||||
|
||||
import arc.*;
|
||||
import arc.math.Mathf;
|
||||
import mindustry.entities.Effects;
|
||||
import mindustry.ctype.ContentList;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.type.StatusEffect;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class StatusEffects implements ContentList{
|
||||
public static StatusEffect none, burning, freezing, wet, melting, tarred, overdrive, shielded, shocked, corroded, boss;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
|
||||
none = new StatusEffect("none");
|
||||
|
||||
burning = new StatusEffect("burning"){{
|
||||
damage = 0.06f;
|
||||
effect = Fx.burning;
|
||||
|
||||
init(() -> {
|
||||
opposite(wet,freezing);
|
||||
trans(tarred, ((unit, time, newTime, result) -> {
|
||||
unit.damage(1f);
|
||||
Effects.effect(Fx.burning, unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f));
|
||||
result.set(this, Math.min(time + newTime, 300f));
|
||||
}));
|
||||
});
|
||||
}};
|
||||
|
||||
freezing = new StatusEffect("freezing"){{
|
||||
speedMultiplier = 0.6f;
|
||||
armorMultiplier = 0.8f;
|
||||
effect = Fx.freezing;
|
||||
|
||||
init(() -> {
|
||||
opposite(melting, burning);
|
||||
});
|
||||
}};
|
||||
|
||||
wet = new StatusEffect("wet"){{
|
||||
speedMultiplier = 0.9f;
|
||||
effect = Fx.wet;
|
||||
|
||||
init(() -> {
|
||||
trans(shocked, ((unit, time, newTime, result) -> {
|
||||
unit.damage(20f);
|
||||
if(unit.getTeam() == state.rules.waveTeam){
|
||||
Events.fire(Trigger.shock);
|
||||
}
|
||||
result.set(this, time);
|
||||
}));
|
||||
opposite(burning);
|
||||
});
|
||||
}};
|
||||
|
||||
melting = new StatusEffect("melting"){{
|
||||
speedMultiplier = 0.8f;
|
||||
armorMultiplier = 0.8f;
|
||||
damage = 0.3f;
|
||||
effect = Fx.melting;
|
||||
|
||||
init(() -> {
|
||||
trans(tarred, ((unit, time, newTime, result) -> result.set(this, Math.min(time + newTime / 2f, 140f))));
|
||||
opposite(wet, freezing);
|
||||
});
|
||||
}};
|
||||
|
||||
tarred = new StatusEffect("tarred"){{
|
||||
speedMultiplier = 0.6f;
|
||||
effect = Fx.oily;
|
||||
|
||||
init(() -> {
|
||||
trans(melting, ((unit, time, newTime, result) -> result.set(burning, newTime + time)));
|
||||
trans(burning, ((unit, time, newTime, result) -> result.set(burning, newTime + time)));
|
||||
});
|
||||
}};
|
||||
|
||||
overdrive = new StatusEffect("overdrive"){{
|
||||
armorMultiplier = 0.95f;
|
||||
speedMultiplier = 1.15f;
|
||||
damageMultiplier = 1.4f;
|
||||
damage = -0.01f;
|
||||
effect = Fx.overdriven;
|
||||
}};
|
||||
|
||||
shielded = new StatusEffect("shielded"){{
|
||||
armorMultiplier = 3f;
|
||||
}};
|
||||
|
||||
boss = new StatusEffect("boss"){{
|
||||
armorMultiplier = 3f;
|
||||
damageMultiplier = 3f;
|
||||
speedMultiplier = 1.1f;
|
||||
}};
|
||||
|
||||
shocked = new StatusEffect("shocked");
|
||||
|
||||
//no effects, just small amounts of damage.
|
||||
corroded = new StatusEffect("corroded"){{
|
||||
damage = 0.1f;
|
||||
}};
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package io.anuke.mindustry.content;
|
||||
package mindustry.content;
|
||||
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.mindustry.ctype.ContentList;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import arc.struct.Array;
|
||||
import mindustry.ctype.ContentList;
|
||||
import mindustry.type.ItemStack;
|
||||
import mindustry.world.Block;
|
||||
|
||||
import static io.anuke.mindustry.content.Blocks.*;
|
||||
import static mindustry.content.Blocks.*;
|
||||
|
||||
public class TechTree implements ContentList{
|
||||
public static Array<TechNode> all;
|
||||
@@ -1,10 +1,10 @@
|
||||
package io.anuke.mindustry.content;
|
||||
package mindustry.content;
|
||||
|
||||
import io.anuke.mindustry.entities.effect.Fire;
|
||||
import io.anuke.mindustry.entities.effect.Puddle;
|
||||
import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.mindustry.ctype.ContentList;
|
||||
import io.anuke.mindustry.type.TypeID;
|
||||
import mindustry.entities.effect.Fire;
|
||||
import mindustry.entities.effect.Puddle;
|
||||
import mindustry.entities.type.Player;
|
||||
import mindustry.ctype.ContentList;
|
||||
import mindustry.type.TypeID;
|
||||
|
||||
public class TypeIDs implements ContentList{
|
||||
public static TypeID fire, puddle, player;
|
||||
@@ -1,13 +1,13 @@
|
||||
package io.anuke.mindustry.content;
|
||||
package mindustry.content;
|
||||
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.mindustry.ctype.ContentList;
|
||||
import io.anuke.mindustry.entities.bullet.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.entities.type.Bullet;
|
||||
import io.anuke.mindustry.entities.type.base.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.ctype.ContentList;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.entities.type.base.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
public class UnitTypes implements ContentList{
|
||||
public static UnitType
|
||||
@@ -17,7 +17,7 @@ public class UnitTypes implements ContentList{
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
draug = new UnitType("draug", Draug::new){{
|
||||
draug = new UnitType("draug", MinerDrone::new){{
|
||||
flying = true;
|
||||
drag = 0.01f;
|
||||
speed = 0.3f;
|
||||
@@ -32,7 +32,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
spirit = new UnitType("spirit", Spirit::new){{
|
||||
spirit = new UnitType("spirit", RepairDrone::new){{
|
||||
flying = true;
|
||||
drag = 0.01f;
|
||||
speed = 0.42f;
|
||||
@@ -53,7 +53,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
phantom = new UnitType("phantom", Phantom::new){{
|
||||
phantom = new UnitType("phantom", BuilderDrone::new){{
|
||||
flying = true;
|
||||
drag = 0.01f;
|
||||
mass = 2f;
|
||||
@@ -76,7 +76,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
dagger = new UnitType("dagger", Dagger::new){{
|
||||
dagger = new UnitType("dagger", GroundUnit::new){{
|
||||
maxVelocity = 1.1f;
|
||||
speed = 0.2f;
|
||||
drag = 0.4f;
|
||||
@@ -92,7 +92,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
crawler = new UnitType("crawler", Crawler::new){{
|
||||
crawler = new UnitType("crawler", GroundUnit::new){{
|
||||
maxVelocity = 1.27f;
|
||||
speed = 0.285f;
|
||||
drag = 0.4f;
|
||||
@@ -123,7 +123,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
titan = new UnitType("titan", Titan::new){{
|
||||
titan = new UnitType("titan", GroundUnit::new){{
|
||||
maxVelocity = 0.8f;
|
||||
speed = 0.22f;
|
||||
drag = 0.4f;
|
||||
@@ -145,7 +145,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
fortress = new UnitType("fortress", Fortress::new){{
|
||||
fortress = new UnitType("fortress", GroundUnit::new){{
|
||||
maxVelocity = 0.78f;
|
||||
speed = 0.15f;
|
||||
drag = 0.4f;
|
||||
@@ -167,7 +167,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
eruptor = new UnitType("eruptor", Eruptor::new){{
|
||||
eruptor = new UnitType("eruptor", GroundUnit::new){{
|
||||
maxVelocity = 0.81f;
|
||||
speed = 0.16f;
|
||||
drag = 0.4f;
|
||||
@@ -189,7 +189,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
chaosArray = new UnitType("chaos-array", Dagger::new){{
|
||||
chaosArray = new UnitType("chaos-array", GroundUnit::new){{
|
||||
maxVelocity = 0.68f;
|
||||
speed = 0.12f;
|
||||
drag = 0.4f;
|
||||
@@ -213,7 +213,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
eradicator = new UnitType("eradicator", Dagger::new){{
|
||||
eradicator = new UnitType("eradicator", GroundUnit::new){{
|
||||
maxVelocity = 0.68f;
|
||||
speed = 0.12f;
|
||||
drag = 0.4f;
|
||||
@@ -238,7 +238,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
wraith = new UnitType("wraith", Wraith::new){{
|
||||
wraith = new UnitType("wraith", FlyingUnit::new){{
|
||||
speed = 0.3f;
|
||||
maxVelocity = 1.9f;
|
||||
drag = 0.01f;
|
||||
@@ -257,7 +257,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
ghoul = new UnitType("ghoul", Ghoul::new){{
|
||||
ghoul = new UnitType("ghoul", FlyingUnit::new){{
|
||||
health = 220;
|
||||
speed = 0.2f;
|
||||
maxVelocity = 1.4f;
|
||||
@@ -281,7 +281,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
revenant = new UnitType("revenant", Revenant::new){{
|
||||
revenant = new UnitType("revenant", HoverUnit::new){{
|
||||
health = 1000;
|
||||
mass = 5f;
|
||||
hitsize = 20f;
|
||||
@@ -312,7 +312,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
lich = new UnitType("lich", Revenant::new){{
|
||||
lich = new UnitType("lich", HoverUnit::new){{
|
||||
health = 6000;
|
||||
mass = 20f;
|
||||
hitsize = 40f;
|
||||
@@ -345,7 +345,7 @@ public class UnitTypes implements ContentList{
|
||||
}};
|
||||
}};
|
||||
|
||||
reaper = new UnitType("reaper", Revenant::new){{
|
||||
reaper = new UnitType("reaper", HoverUnit::new){{
|
||||
health = 11000;
|
||||
mass = 30f;
|
||||
hitsize = 56f;
|
||||
@@ -1,16 +1,16 @@
|
||||
package io.anuke.mindustry.content;
|
||||
package mindustry.content;
|
||||
|
||||
import io.anuke.mindustry.ctype.ContentList;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.game.Objectives.*;
|
||||
import io.anuke.mindustry.maps.generators.*;
|
||||
import io.anuke.mindustry.maps.generators.MapGenerator.*;
|
||||
import io.anuke.mindustry.maps.zonegen.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import mindustry.ctype.ContentList;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.Objectives.*;
|
||||
import mindustry.maps.generators.*;
|
||||
import mindustry.maps.generators.MapGenerator.*;
|
||||
import mindustry.maps.zonegen.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
import static io.anuke.arc.collection.Array.with;
|
||||
import static io.anuke.mindustry.content.Items.*;
|
||||
import static io.anuke.mindustry.type.ItemStack.list;
|
||||
import static arc.struct.Array.with;
|
||||
import static mindustry.content.Items.*;
|
||||
import static mindustry.type.ItemStack.list;
|
||||
|
||||
public class Zones implements ContentList{
|
||||
public static Zone
|
||||
@@ -1,18 +1,20 @@
|
||||
package io.anuke.mindustry.core;
|
||||
package mindustry.core;
|
||||
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.ctype.*;
|
||||
import io.anuke.mindustry.entities.bullet.*;
|
||||
import io.anuke.mindustry.mod.Mods.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import arc.struct.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.ctype.ContentType;
|
||||
import mindustry.entities.bullet.*;
|
||||
import mindustry.mod.Mods.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static io.anuke.arc.Core.files;
|
||||
import static io.anuke.mindustry.Vars.mods;
|
||||
import static arc.Core.files;
|
||||
import static mindustry.Vars.mods;
|
||||
|
||||
/**
|
||||
* Loads all game content.
|
||||
@@ -20,10 +22,11 @@ import static io.anuke.mindustry.Vars.mods;
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ContentLoader{
|
||||
private boolean loaded = false;
|
||||
private ObjectMap<String, MappableContent>[] contentNameMap = new ObjectMap[ContentType.values().length];
|
||||
private Array<Content>[] contentMap = new Array[ContentType.values().length];
|
||||
private MappableContent[][] temporaryMapper;
|
||||
private @Nullable LoadedMod currentMod;
|
||||
private @Nullable Content lastAdded;
|
||||
private ObjectSet<Cons<Content>> initialization = new ObjectSet<>();
|
||||
private ContentList[] content = {
|
||||
new Fx(),
|
||||
@@ -43,35 +46,40 @@ public class ContentLoader{
|
||||
new LegacyColorMapper(),
|
||||
};
|
||||
|
||||
public ContentLoader(){
|
||||
clear();
|
||||
}
|
||||
|
||||
/** Clears all initialized content.*/
|
||||
public void clear(){
|
||||
contentNameMap = new ObjectMap[ContentType.values().length];
|
||||
contentMap = new Array[ContentType.values().length];
|
||||
initialization = new ObjectSet<>();
|
||||
loaded = false;
|
||||
}
|
||||
|
||||
/** Creates all content types. */
|
||||
public void createContent(){
|
||||
if(loaded){
|
||||
Log.info("Content already loaded, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
for(ContentType type : ContentType.values()){
|
||||
contentMap[type.ordinal()] = new Array<>();
|
||||
contentNameMap[type.ordinal()] = new ObjectMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Creates all base types. */
|
||||
public void createBaseContent(){
|
||||
for(ContentList list : content){
|
||||
list.load();
|
||||
}
|
||||
}
|
||||
|
||||
/** Creates mod content, if applicable. */
|
||||
public void createModContent(){
|
||||
if(mods != null){
|
||||
mods.loadContent();
|
||||
}
|
||||
}
|
||||
|
||||
//check up ID mapping, make sure it's linear
|
||||
/** Logs content statistics.*/
|
||||
public void logContent(){
|
||||
//check up ID mapping, make sure it's linear (debug only)
|
||||
for(Array<Content> arr : contentMap){
|
||||
for(int i = 0; i < arr.size; i++){
|
||||
int id = arr.get(i).id;
|
||||
@@ -81,17 +89,12 @@ public class ContentLoader{
|
||||
}
|
||||
}
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
/** Logs content statistics.*/
|
||||
public void logContent(){
|
||||
Log.info("--- CONTENT INFO ---");
|
||||
Log.debug("--- CONTENT INFO ---");
|
||||
for(int k = 0; k < contentMap.length; k++){
|
||||
Log.info("[{0}]: loaded {1}", ContentType.values()[k].name(), contentMap[k].size);
|
||||
Log.debug("[{0}]: loaded {1}", ContentType.values()[k].name(), contentMap[k].size);
|
||||
}
|
||||
Log.info("Total content loaded: {0}", Array.with(ContentType.values()).mapInt(c -> contentMap[c.ordinal()].size).sum());
|
||||
Log.info("-------------------");
|
||||
Log.debug("Total content loaded: {0}", Array.with(ContentType.values()).mapInt(c -> contentMap[c.ordinal()].size).sum());
|
||||
Log.debug("-------------------");
|
||||
}
|
||||
|
||||
/** Calls Content#init() on everything. Use only after all modules have been created.*/
|
||||
@@ -113,8 +116,8 @@ public class ContentLoader{
|
||||
try{
|
||||
callable.get(content);
|
||||
}catch(Throwable e){
|
||||
if(content.mod != null){
|
||||
mods.handleError(new ModLoadException(content, e), content.mod);
|
||||
if(content.minfo.mod != null){
|
||||
mods.handleContentError(content, e);
|
||||
}else{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -145,15 +148,41 @@ public class ContentLoader{
|
||||
//clear all content, currently not used
|
||||
}
|
||||
|
||||
public void handleContent(Content content){
|
||||
contentMap[content.getContentType().ordinal()].add(content);
|
||||
/** Get last piece of content created for error-handling purposes. */
|
||||
public @Nullable Content getLastAdded(){
|
||||
return lastAdded;
|
||||
}
|
||||
|
||||
/** Remove last content added in case of an exception. */
|
||||
public void removeLast(){
|
||||
if(lastAdded != null && contentMap[lastAdded.getContentType().ordinal()].peek() == lastAdded){
|
||||
contentMap[lastAdded.getContentType().ordinal()].pop();
|
||||
if(lastAdded instanceof MappableContent){
|
||||
contentNameMap[lastAdded.getContentType().ordinal()].remove(((MappableContent)lastAdded).name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleContent(Content content){
|
||||
this.lastAdded = content;
|
||||
contentMap[content.getContentType().ordinal()].add(content);
|
||||
}
|
||||
|
||||
public void setCurrentMod(@Nullable LoadedMod mod){
|
||||
this.currentMod = mod;
|
||||
}
|
||||
|
||||
public String transformName(String name){
|
||||
return currentMod == null ? name : currentMod.name + "-" + name;
|
||||
}
|
||||
|
||||
public void handleMappableContent(MappableContent content){
|
||||
if(contentNameMap[content.getContentType().ordinal()].containsKey(content.name)){
|
||||
throw new IllegalArgumentException("Two content objects cannot have the same name! (issue: '" + content.name + "')");
|
||||
}
|
||||
if(currentMod != null){
|
||||
content.minfo.mod = currentMod;
|
||||
}
|
||||
contentNameMap[content.getContentType().ordinal()].put(content.name, content);
|
||||
}
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
package io.anuke.mindustry.core;
|
||||
package mindustry.core;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.assets.*;
|
||||
import io.anuke.arc.audio.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.input.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.input.*;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.storage.*;
|
||||
import arc.*;
|
||||
import arc.assets.*;
|
||||
import arc.audio.*;
|
||||
import arc.struct.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.input.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.input.*;
|
||||
import mindustry.maps.Map;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
|
||||
import static io.anuke.arc.Core.*;
|
||||
import static io.anuke.mindustry.Vars.net;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.net;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
/**
|
||||
* Control module.
|
||||
@@ -63,7 +63,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
});
|
||||
|
||||
Events.on(PlayEvent.class, event -> {
|
||||
player.setTeam(state.rules.pvp ? netServer.assignTeam(player, playerGroup.all()) : defaultTeam);
|
||||
player.setTeam(netServer.assignTeam(player, playerGroup.all()));
|
||||
player.setDead(true);
|
||||
player.add();
|
||||
|
||||
@@ -256,12 +256,13 @@ public class Control implements ApplicationListener, Loadable{
|
||||
world.loadGenerator(zone.generator);
|
||||
zone.rules.get(state.rules);
|
||||
state.rules.zone = zone;
|
||||
for(Tile core : state.teams.get(defaultTeam).cores){
|
||||
for(TileEntity core : state.teams.playerCores()){
|
||||
for(ItemStack stack : zone.getStartingItems()){
|
||||
core.entity.items.add(stack.item, stack.amount);
|
||||
core.items.add(stack.item, stack.amount);
|
||||
}
|
||||
}
|
||||
state.set(State.playing);
|
||||
state.wavetime = state.rules.waveSpacing;
|
||||
control.saves.zoneSave();
|
||||
logic.play();
|
||||
Events.fire(Trigger.newGame);
|
||||
@@ -293,8 +294,8 @@ public class Control implements ApplicationListener, Loadable{
|
||||
|
||||
Geometry.circle(coreb.x, coreb.y, 10, (cx, cy) -> {
|
||||
Tile tile = world.ltile(cx, cy);
|
||||
if(tile != null && tile.getTeam() == defaultTeam && !(tile.block() instanceof CoreBlock)){
|
||||
world.removeBlock(tile);
|
||||
if(tile != null && tile.getTeam() == state.rules.defaultTeam && !(tile.block() instanceof CoreBlock)){
|
||||
tile.remove();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -304,13 +305,13 @@ public class Control implements ApplicationListener, Loadable{
|
||||
|
||||
zone.rules.get(state.rules);
|
||||
state.rules.zone = zone;
|
||||
for(Tile core : state.teams.get(defaultTeam).cores){
|
||||
for(TileEntity core : state.teams.playerCores()){
|
||||
for(ItemStack stack : zone.getStartingItems()){
|
||||
core.entity.items.add(stack.item, stack.amount);
|
||||
core.items.add(stack.item, stack.amount);
|
||||
}
|
||||
}
|
||||
Tile core = state.teams.get(defaultTeam).cores.first();
|
||||
core.entity.items.clear();
|
||||
TileEntity core = state.teams.playerCores().first();
|
||||
core.items.clear();
|
||||
|
||||
logic.play();
|
||||
state.rules.waveTimer = false;
|
||||
@@ -433,9 +434,9 @@ public class Control implements ApplicationListener, Loadable{
|
||||
input.update();
|
||||
|
||||
if(world.isZone()){
|
||||
for(Tile tile : state.teams.get(player.getTeam()).cores){
|
||||
for(TileEntity tile : state.teams.cores(player.getTeam())){
|
||||
for(Item item : content.items()){
|
||||
if(tile.entity != null && tile.entity.items.has(item)){
|
||||
if(tile.items.has(item)){
|
||||
data.unlockContent(item);
|
||||
}
|
||||
}
|
||||
@@ -451,12 +452,12 @@ public class Control implements ApplicationListener, Loadable{
|
||||
platform.updateRPC();
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.pause) && !scene.hasDialog() && !ui.restart.isShown() && (state.is(State.paused) || state.is(State.playing))){
|
||||
if(Core.input.keyTap(Binding.pause) && !scene.hasDialog() && !scene.hasKeyboard() && !ui.restart.isShown() && (state.is(State.paused) || state.is(State.playing))){
|
||||
state.set(state.is(State.playing) ? State.paused : State.playing);
|
||||
}
|
||||
|
||||
if(Core.input.keyTap(Binding.menu) && !ui.restart.isShown()){
|
||||
if(ui.chatfrag.chatOpen()){
|
||||
if(ui.chatfrag.shown()){
|
||||
ui.chatfrag.hide();
|
||||
}else if(!ui.paused.isShown() && !scene.hasDialog()){
|
||||
ui.paused.show();
|
||||
@@ -464,7 +465,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
}
|
||||
}
|
||||
|
||||
if(!mobile && Core.input.keyTap(Binding.screenshot) && !(scene.getKeyboardFocus() instanceof TextField) && !ui.chatfrag.chatOpen()){
|
||||
if(!mobile && Core.input.keyTap(Binding.screenshot) && !(scene.getKeyboardFocus() instanceof TextField) && !scene.hasKeyboard()){
|
||||
renderer.takeMapScreenshot();
|
||||
}
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
package io.anuke.mindustry.core;
|
||||
package mindustry.core;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.assets.loaders.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import arc.*;
|
||||
import arc.assets.loaders.*;
|
||||
import arc.struct.*;
|
||||
import arc.files.*;
|
||||
|
||||
/** Handles files in a modded context. */
|
||||
public class FileTree implements FileHandleResolver{
|
||||
private ObjectMap<String, FileHandle> files = new ObjectMap<>();
|
||||
private ObjectMap<String, Fi> files = new ObjectMap<>();
|
||||
|
||||
public void addFile(String path, FileHandle f){
|
||||
public void addFile(String path, Fi f){
|
||||
files.put(path, f);
|
||||
}
|
||||
|
||||
/** Gets an asset file.*/
|
||||
public FileHandle get(String path){
|
||||
public Fi get(String path){
|
||||
if(files.containsKey(path)){
|
||||
return files.get(path);
|
||||
}else if(files.containsKey("/" + path)){
|
||||
return files.get("/" + path);
|
||||
}else{
|
||||
return Core.files.internal(path);
|
||||
}
|
||||
@@ -28,7 +30,7 @@ public class FileTree implements FileHandleResolver{
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileHandle resolve(String fileName){
|
||||
public Fi resolve(String fileName){
|
||||
return get(fileName);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package io.anuke.mindustry.core;
|
||||
package mindustry.core;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.entities.type.base.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import arc.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class GameState{
|
||||
/** Current wave number, can be anything in non-wave modes. */
|
||||
@@ -26,12 +25,8 @@ public class GameState{
|
||||
/** Current game state. */
|
||||
private State state = State.menu;
|
||||
|
||||
public int enemies(){
|
||||
return net.client() ? enemies : unitGroups[waveTeam.ordinal()].count(b -> !(b instanceof BaseDrone));
|
||||
}
|
||||
|
||||
public BaseUnit boss(){
|
||||
return unitGroups[waveTeam.ordinal()].find(BaseUnit::isBoss);
|
||||
return unitGroup.find(u -> u.isBoss() && u.getTeam() == rules.waveTeam);
|
||||
}
|
||||
|
||||
public void set(State astate){
|
||||
@@ -1,26 +1,26 @@
|
||||
package io.anuke.mindustry.core;
|
||||
package mindustry.core;
|
||||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.ctype.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.game.Teams.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.mindustry.world.blocks.BuildBlock.*;
|
||||
import io.anuke.mindustry.world.blocks.power.*;
|
||||
import arc.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.Teams.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.blocks.BuildBlock.*;
|
||||
import mindustry.world.blocks.power.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
/**
|
||||
* Logic module.
|
||||
@@ -52,7 +52,7 @@ public class Logic implements ApplicationListener{
|
||||
|
||||
if(block instanceof BuildBlock){
|
||||
|
||||
BuildEntity entity = tile.entity();
|
||||
BuildEntity entity = tile.ent();
|
||||
|
||||
//update block to reflect the fact that something was being constructed
|
||||
if(entity.cblock != null && entity.cblock.synthetic()){
|
||||
@@ -107,9 +107,9 @@ public class Logic implements ApplicationListener{
|
||||
|
||||
//add starting items
|
||||
if(!world.isZone()){
|
||||
for(Team team : Team.all){
|
||||
if(!state.teams.get(team).cores.isEmpty()){
|
||||
TileEntity entity = state.teams.get(team).cores.first().entity;
|
||||
for(TeamData team : state.teams.getActive()){
|
||||
if(team.hasCore()){
|
||||
TileEntity entity = team.core();
|
||||
entity.items.clear();
|
||||
for(ItemStack stack : state.rules.loadout){
|
||||
entity.items.add(stack.item, stack.amount);
|
||||
@@ -143,23 +143,23 @@ public class Logic implements ApplicationListener{
|
||||
}
|
||||
|
||||
private void checkGameOver(){
|
||||
if(!state.rules.attackMode && state.teams.get(defaultTeam).cores.size == 0 && !state.gameOver){
|
||||
if(!state.rules.attackMode && state.teams.playerCores().size == 0 && !state.gameOver){
|
||||
state.gameOver = true;
|
||||
Events.fire(new GameOverEvent(waveTeam));
|
||||
Events.fire(new GameOverEvent(state.rules.waveTeam));
|
||||
}else if(state.rules.attackMode){
|
||||
Team alive = null;
|
||||
|
||||
for(Team team : Team.all){
|
||||
if(state.teams.get(team).cores.size > 0){
|
||||
for(TeamData team : state.teams.getActive()){
|
||||
if(team.hasCore()){
|
||||
if(alive != null){
|
||||
return;
|
||||
}
|
||||
alive = team;
|
||||
alive = team.team;
|
||||
}
|
||||
}
|
||||
|
||||
if(alive != null && !state.gameOver){
|
||||
if(world.isZone() && alive == defaultTeam){
|
||||
if(world.isZone() && alive == state.rules.defaultTeam){
|
||||
//in attack maps, a victorious game over is equivalent to a launch
|
||||
Call.launchZone();
|
||||
}else{
|
||||
@@ -176,7 +176,7 @@ public class Logic implements ApplicationListener{
|
||||
ui.hudfrag.showLaunch();
|
||||
}
|
||||
|
||||
for(Tile tile : state.teams.get(defaultTeam).cores){
|
||||
for(TileEntity tile : state.teams.playerCores()){
|
||||
Effects.effect(Fx.launch, tile);
|
||||
}
|
||||
|
||||
@@ -185,19 +185,18 @@ public class Logic implements ApplicationListener{
|
||||
}
|
||||
|
||||
Time.runTask(30f, () -> {
|
||||
for(Tile tile : state.teams.get(defaultTeam).cores){
|
||||
for(TileEntity entity : state.teams.playerCores()){
|
||||
for(Item item : content.items()){
|
||||
if(tile == null || tile.entity == null || tile.entity.items == null) continue;
|
||||
data.addItem(item, tile.entity.items.get(item));
|
||||
Events.fire(new LaunchItemEvent(item, tile.entity.items.get(item)));
|
||||
data.addItem(item, entity.items.get(item));
|
||||
Events.fire(new LaunchItemEvent(item, entity.items.get(item)));
|
||||
}
|
||||
world.removeBlock(tile);
|
||||
entity.tile.remove();
|
||||
}
|
||||
state.launched = true;
|
||||
state.gameOver = true;
|
||||
Events.fire(new LaunchEvent());
|
||||
//manually fire game over event now
|
||||
Events.fire(new GameOverEvent(defaultTeam));
|
||||
Events.fire(new GameOverEvent(state.rules.defaultTeam));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -212,12 +211,15 @@ public class Logic implements ApplicationListener{
|
||||
public void update(){
|
||||
|
||||
if(!state.is(State.menu)){
|
||||
if(!net.client()){
|
||||
state.enemies = unitGroup.count(b -> b.getTeam() == state.rules.waveTeam && b.countsAsEnemy());
|
||||
}
|
||||
|
||||
if(!state.isPaused()){
|
||||
Time.update();
|
||||
|
||||
if(state.rules.waves && state.rules.waveTimer && !state.gameOver){
|
||||
if(!state.rules.waitForWaveToEnd || unitGroups[waveTeam.ordinal()].size() == 0){
|
||||
if(!state.rules.waitForWaveToEnd || state.enemies == 0){
|
||||
state.wavetime = Math.max(state.wavetime - Time.delta(), 0);
|
||||
}
|
||||
}
|
||||
@@ -232,20 +234,15 @@ public class Logic implements ApplicationListener{
|
||||
}
|
||||
|
||||
if(!state.isEditor()){
|
||||
for(EntityGroup group : unitGroups){
|
||||
group.update();
|
||||
}
|
||||
|
||||
unitGroup.update();
|
||||
puddleGroup.update();
|
||||
shieldGroup.update();
|
||||
bulletGroup.update();
|
||||
tileGroup.update();
|
||||
fireGroup.update();
|
||||
}else{
|
||||
for(EntityGroup<?> group : unitGroups){
|
||||
group.updateEvents();
|
||||
collisions.updatePhysics(group);
|
||||
}
|
||||
unitGroup.updateEvents();
|
||||
collisions.updatePhysics(unitGroup);
|
||||
}
|
||||
|
||||
|
||||
@@ -257,12 +254,8 @@ public class Logic implements ApplicationListener{
|
||||
}
|
||||
|
||||
if(!state.isEditor()){
|
||||
|
||||
for(EntityGroup group : unitGroups){
|
||||
if(group.isEmpty()) continue;
|
||||
collisions.collideGroups(bulletGroup, group);
|
||||
}
|
||||
|
||||
//bulletGroup
|
||||
collisions.collideGroups(bulletGroup, unitGroup);
|
||||
collisions.collideGroups(bulletGroup, playerGroup);
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,36 @@
|
||||
package io.anuke.mindustry.core;
|
||||
package mindustry.core;
|
||||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.CommandHandler.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.io.*;
|
||||
import io.anuke.arc.util.serialization.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.traits.BuilderTrait.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.net.Administration.*;
|
||||
import io.anuke.mindustry.net.Net.*;
|
||||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.net.Packets.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.type.TypeID;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.modules.*;
|
||||
import arc.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import arc.struct.*;
|
||||
import arc.graphics.*;
|
||||
import arc.math.*;
|
||||
import arc.util.CommandHandler.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
import arc.util.serialization.*;
|
||||
import mindustry.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.ctype.ContentType;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.traits.BuilderTrait.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.net.Administration.*;
|
||||
import mindustry.net.Net.*;
|
||||
import mindustry.net.*;
|
||||
import mindustry.net.Packets.*;
|
||||
import mindustry.type.TypeID;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.modules.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class NetClient implements ApplicationListener{
|
||||
private final static float dataTimeout = 60 * 18;
|
||||
@@ -160,9 +160,17 @@ public class NetClient implements ApplicationListener{
|
||||
throw new ValidateException(player, "Player has sent a message above the text limit.");
|
||||
}
|
||||
|
||||
String original = message;
|
||||
|
||||
//check if it's a command
|
||||
CommandResponse response = netServer.clientCommands.handleMessage(message, player);
|
||||
if(response.type == ResponseType.noCommand){ //no command to handle
|
||||
message = netServer.admins.filterMessage(player, message);
|
||||
//supress chat message if it's filtered out
|
||||
if(message == null){
|
||||
return;
|
||||
}
|
||||
|
||||
//server console logging
|
||||
Log.info("&y{0}: &lb{1}", player.name, message);
|
||||
|
||||
@@ -190,7 +198,7 @@ public class NetClient implements ApplicationListener{
|
||||
}
|
||||
}
|
||||
|
||||
Events.fire(new PlayerChatEvent(player, message));
|
||||
Events.fire(new PlayerChatEvent(player, message, original));
|
||||
}
|
||||
|
||||
public static String colorizeName(int id, String name){
|
||||
@@ -342,6 +350,26 @@ public class NetClient implements ApplicationListener{
|
||||
}
|
||||
}
|
||||
|
||||
@Remote(variants = Variant.both, priority = PacketPriority.low, unreliable = true)
|
||||
public static void onBlockSnapshot(short amount, short dataLen, byte[] data){
|
||||
try{
|
||||
netClient.byteStream.setBytes(net.decompressSnapshot(data, dataLen));
|
||||
DataInputStream input = netClient.dataStream;
|
||||
|
||||
for(int i = 0; i < amount; i++){
|
||||
int pos = input.readInt();
|
||||
Tile tile = world.tile(pos);
|
||||
if(tile == null || tile.entity == null){
|
||||
Log.warn("Missing entity at {0}. Skipping block snapshot.", tile);
|
||||
break;
|
||||
}
|
||||
tile.entity.read(input, tile.entity.version());
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Remote(variants = Variant.one, priority = PacketPriority.low, unreliable = true)
|
||||
public static void onStateSnapshot(float waveTime, int wave, int enemies, short coreDataLen, byte[] coreData){
|
||||
try{
|
||||
@@ -471,7 +499,7 @@ public class NetClient implements ApplicationListener{
|
||||
player.pointerX, player.pointerY, player.rotation, player.baseRotation,
|
||||
player.velocity().x, player.velocity().y,
|
||||
player.getMineTile(),
|
||||
player.isBoosting, player.isShooting, ui.chatfrag.chatOpen(), player.isBuilding,
|
||||
player.isBoosting, player.isShooting, ui.chatfrag.shown(), player.isBuilding,
|
||||
requests,
|
||||
Core.camera.position.x, Core.camera.position.y,
|
||||
Core.camera.width * viewScale, Core.camera.height * viewScale);
|
||||
@@ -1,46 +1,66 @@
|
||||
package io.anuke.mindustry.core;
|
||||
package mindustry.core;
|
||||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.CommandHandler.*;
|
||||
import io.anuke.arc.util.io.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.traits.BuilderTrait.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.net.Administration.*;
|
||||
import io.anuke.mindustry.net.Packets.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import arc.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import arc.struct.*;
|
||||
import arc.graphics.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.CommandHandler.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.traits.BuilderTrait.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.Teams.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.net.*;
|
||||
import mindustry.net.Administration.*;
|
||||
import mindustry.net.Packets.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.storage.CoreBlock.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class NetServer implements ApplicationListener{
|
||||
public final static int maxSnapshotSize = 430;
|
||||
private final static float serverSyncTime = 12, kickDuration = 30 * 1000;
|
||||
private final static Vector2 vector = new Vector2();
|
||||
private final static Rectangle viewport = new Rectangle();
|
||||
private final static int maxSnapshotSize = 430, timerBlockSync = 0;
|
||||
private final static float serverSyncTime = 12, kickDuration = 30 * 1000, blockSyncTime = 60 * 8;
|
||||
private final static Vec2 vector = new Vec2();
|
||||
private final static Rect viewport = new Rect();
|
||||
/** If a player goes away of their server-side coordinates by this distance, they get teleported back. */
|
||||
private final static float correctDist = 16f;
|
||||
|
||||
public final Administration admins = new Administration();
|
||||
public final CommandHandler clientCommands = new CommandHandler("/");
|
||||
public TeamAssigner assigner = (player, players) -> {
|
||||
if(state.rules.pvp){
|
||||
//find team with minimum amount of players and auto-assign player to that.
|
||||
TeamData re = state.teams.getActive().min(data -> {
|
||||
int count = 0;
|
||||
for(Player other : players){
|
||||
if(other.getTeam() == data.team && other != player){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
});
|
||||
return re == null ? null : re.team;
|
||||
}
|
||||
|
||||
return state.rules.defaultTeam;
|
||||
};
|
||||
|
||||
private boolean closing = false;
|
||||
private Interval timer = new Interval();
|
||||
|
||||
private ByteBuffer writeBuffer = ByteBuffer.allocate(127);
|
||||
private ByteBufferOutput outputBuffer = new ByteBufferOutput(writeBuffer);
|
||||
@@ -65,6 +85,10 @@ public class NetServer implements ApplicationListener{
|
||||
});
|
||||
|
||||
net.handleServer(ConnectPacket.class, (con, packet) -> {
|
||||
if(con.address.startsWith("steam:")){
|
||||
packet.uuid = con.address.substring("steam:".length());
|
||||
}
|
||||
|
||||
String uuid = packet.uuid;
|
||||
|
||||
if(admins.isIPBanned(con.address)) return;
|
||||
@@ -192,10 +216,8 @@ public class NetServer implements ApplicationListener{
|
||||
con.player = player;
|
||||
|
||||
//playing in pvp mode automatically assigns players to teams
|
||||
if(state.rules.pvp){
|
||||
player.setTeam(assignTeam(player, playerGroup.all()));
|
||||
Log.info("Auto-assigned player {0} to team {1}.", player.name, player.getTeam());
|
||||
}
|
||||
player.setTeam(assignTeam(player, playerGroup.all()));
|
||||
Log.info("Auto-assigned player {0} to team {1}.", player.name, player.getTeam());
|
||||
|
||||
sendWorldData(player);
|
||||
|
||||
@@ -214,7 +236,7 @@ public class NetServer implements ApplicationListener{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
mods.each(mod -> mod.registerClientCommands(clientCommands));
|
||||
mods.eachClass(mod -> mod.registerClientCommands(clientCommands));
|
||||
}
|
||||
|
||||
private void registerCommands(){
|
||||
@@ -396,19 +418,7 @@ public class NetServer implements ApplicationListener{
|
||||
}
|
||||
|
||||
public Team assignTeam(Player current, Iterable<Player> players){
|
||||
//find team with minimum amount of players and auto-assign player to that.
|
||||
return Structs.findMin(Team.all, team -> {
|
||||
if(state.teams.isActive(team) && !state.teams.get(team).cores.isEmpty()){
|
||||
int count = 0;
|
||||
for(Player other : players){
|
||||
if(other.getTeam() == team && other != current){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
return Integer.MAX_VALUE;
|
||||
});
|
||||
return assigner.assign(current, players);
|
||||
}
|
||||
|
||||
public void sendWorldData(Player player){
|
||||
@@ -579,8 +589,8 @@ public class NetServer implements ApplicationListener{
|
||||
public boolean isWaitingForPlayers(){
|
||||
if(state.rules.pvp){
|
||||
int used = 0;
|
||||
for(Team t : Team.all){
|
||||
if(playerGroup.count(p -> p.getTeam() == t) > 0){
|
||||
for(TeamData t : state.teams.getActive()){
|
||||
if(playerGroup.count(p -> p.getTeam() == t.team) > 0){
|
||||
used++;
|
||||
}
|
||||
}
|
||||
@@ -612,22 +622,50 @@ public class NetServer implements ApplicationListener{
|
||||
}
|
||||
}
|
||||
|
||||
public void writeSnapshot(Player player) throws IOException{
|
||||
/** Sends a block snapshot to all players. */
|
||||
public void writeBlockSnapshots() throws IOException{
|
||||
syncStream.reset();
|
||||
ObjectSet<Tile> cores = state.teams.get(player.getTeam()).cores;
|
||||
|
||||
short sent = 0;
|
||||
for(TileEntity entity : tileGroup.all()){
|
||||
if(!entity.block.sync) continue;
|
||||
sent ++;
|
||||
|
||||
dataStream.writeInt(entity.tile.pos());
|
||||
entity.write(dataStream);
|
||||
|
||||
if(syncStream.size() > maxSnapshotSize){
|
||||
dataStream.close();
|
||||
byte[] stateBytes = syncStream.toByteArray();
|
||||
Call.onBlockSnapshot(sent, (short)stateBytes.length, net.compressSnapshot(stateBytes));
|
||||
sent = 0;
|
||||
syncStream.reset();
|
||||
}
|
||||
}
|
||||
|
||||
if(sent > 0){
|
||||
dataStream.close();
|
||||
byte[] stateBytes = syncStream.toByteArray();
|
||||
Call.onBlockSnapshot(sent, (short)stateBytes.length, net.compressSnapshot(stateBytes));
|
||||
}
|
||||
}
|
||||
|
||||
public void writeEntitySnapshot(Player player) throws IOException{
|
||||
syncStream.reset();
|
||||
Array<CoreEntity> cores = state.teams.cores(player.getTeam());
|
||||
|
||||
dataStream.writeByte(cores.size);
|
||||
|
||||
for(Tile tile : cores){
|
||||
dataStream.writeInt(tile.pos());
|
||||
tile.entity.items.write(dataStream);
|
||||
for(CoreEntity entity : cores){
|
||||
dataStream.writeInt(entity.tile.pos());
|
||||
entity.items.write(dataStream);
|
||||
}
|
||||
|
||||
dataStream.close();
|
||||
byte[] stateBytes = syncStream.toByteArray();
|
||||
|
||||
//write basic state data.
|
||||
Call.onStateSnapshot(player.con, state.wavetime, state.wave, state.enemies(), (short)stateBytes.length, net.compressSnapshot(stateBytes));
|
||||
Call.onStateSnapshot(player.con, state.wavetime, state.wave, state.enemies, (short)stateBytes.length, net.compressSnapshot(stateBytes));
|
||||
|
||||
viewport.setSize(player.con.viewWidth, player.con.viewHeight).setCenter(player.con.viewX, player.con.viewY);
|
||||
|
||||
@@ -726,7 +764,6 @@ public class NetServer implements ApplicationListener{
|
||||
void sync(){
|
||||
|
||||
try{
|
||||
|
||||
//iterate through each player
|
||||
for(int i = 0; i < playerGroup.size(); i++){
|
||||
Player player = playerGroup.all().get(i);
|
||||
@@ -741,11 +778,19 @@ public class NetServer implements ApplicationListener{
|
||||
|
||||
if(!player.timer.get(Player.timerSync, serverSyncTime) || !connection.hasConnected) continue;
|
||||
|
||||
writeSnapshot(player);
|
||||
writeEntitySnapshot(player);
|
||||
}
|
||||
|
||||
if(playerGroup.size() > 0 && Core.settings.getBool("blocksync") && timer.get(timerBlockSync, blockSyncTime)){
|
||||
writeBlockSnapshots();
|
||||
}
|
||||
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public interface TeamAssigner{
|
||||
Team assign(Player player, Iterable<Player> players);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,21 @@
|
||||
package io.anuke.mindustry.core;
|
||||
package mindustry.core;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.Input.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.util.serialization.*;
|
||||
import io.anuke.mindustry.net.*;
|
||||
import io.anuke.mindustry.net.Net.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
import arc.*;
|
||||
import arc.Input.*;
|
||||
import arc.struct.*;
|
||||
import arc.files.*;
|
||||
import arc.func.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.util.serialization.*;
|
||||
import mindustry.mod.*;
|
||||
import mindustry.net.*;
|
||||
import mindustry.net.Net.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import org.mozilla.javascript.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.mobile;
|
||||
import static mindustry.Vars.mobile;
|
||||
|
||||
public interface Platform{
|
||||
|
||||
@@ -33,7 +35,7 @@ public interface Platform{
|
||||
default void viewListingID(String mapid){}
|
||||
|
||||
/** Steam: Return external workshop maps to be loaded.*/
|
||||
default Array<FileHandle> getWorkshopContent(Class<? extends Publishable> type){
|
||||
default Array<Fi> getWorkshopContent(Class<? extends Publishable> type){
|
||||
return new Array<>(0);
|
||||
}
|
||||
|
||||
@@ -42,7 +44,18 @@ public interface Platform{
|
||||
|
||||
/** Get the networking implementation.*/
|
||||
default NetProvider getNet(){
|
||||
return new ArcNetImpl();
|
||||
return new ArcNetProvider();
|
||||
}
|
||||
|
||||
/** Gets the scripting implementation. */
|
||||
default Scripts createScripts(){
|
||||
return new Scripts();
|
||||
}
|
||||
|
||||
default Context getScriptContext(){
|
||||
Context c = Context.enter();
|
||||
c.setOptimizationLevel(9);
|
||||
return c;
|
||||
}
|
||||
|
||||
/** Add a text input dialog that should show up after the field is tapped. */
|
||||
@@ -87,7 +100,7 @@ public interface Platform{
|
||||
}
|
||||
|
||||
/** Only used for iOS or android: open the share menu for a map or save. */
|
||||
default void shareFile(FileHandle file){
|
||||
default void shareFile(Fi file){
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +109,7 @@ public interface Platform{
|
||||
* @param open Whether to open or save files
|
||||
* @param extension File extension to filter
|
||||
*/
|
||||
default void showFileChooser(boolean open, String extension, Cons<FileHandle> cons){
|
||||
default void showFileChooser(boolean open, String extension, Cons<Fi> cons){
|
||||
new FileChooser(open ? "$open" : "$save", file -> file.extension().toLowerCase().equals(extension), open, file -> {
|
||||
if(!open){
|
||||
cons.get(file.parent().child(file.nameWithoutExtension() + "." + extension));
|
||||
@@ -1,32 +1,31 @@
|
||||
package io.anuke.mindustry.core;
|
||||
package mindustry.core;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.graphics.glutils.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.pooling.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.effect.*;
|
||||
import io.anuke.mindustry.entities.effect.GroundEffectEntity.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.input.*;
|
||||
import io.anuke.mindustry.ui.Cicon;
|
||||
import io.anuke.mindustry.world.blocks.defense.ForceProjector.*;
|
||||
import arc.*;
|
||||
import arc.files.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.graphics.gl.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.effect.GroundEffectEntity.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.input.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.defense.ForceProjector.*;
|
||||
|
||||
import static io.anuke.arc.Core.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Renderer implements ApplicationListener{
|
||||
public final BlockRenderer blocks = new BlockRenderer();
|
||||
@@ -42,7 +41,7 @@ public class Renderer implements ApplicationListener{
|
||||
private float camerascale = targetscale;
|
||||
private float landscale = 0f, landTime;
|
||||
private float minZoomScl = Scl.scl(0.01f);
|
||||
private Rectangle rect = new Rectangle(), rect2 = new Rectangle();
|
||||
private Rect rect = new Rect(), rect2 = new Rect();
|
||||
private float shakeIntensity, shaketime;
|
||||
|
||||
public Renderer(){
|
||||
@@ -57,8 +56,8 @@ public class Renderer implements ApplicationListener{
|
||||
Effects.setEffectProvider((effect, color, x, y, rotation, data) -> {
|
||||
if(effect == Fx.none) return;
|
||||
if(Core.settings.getBool("effects")){
|
||||
Rectangle view = camera.bounds(rect);
|
||||
Rectangle pos = rect2.setSize(effect.size).setCenter(x, y);
|
||||
Rect view = camera.bounds(rect);
|
||||
Rect pos = rect2.setSize(effect.size).setCenter(x, y);
|
||||
|
||||
if(view.overlaps(pos)){
|
||||
|
||||
@@ -120,7 +119,7 @@ public class Renderer implements ApplicationListener{
|
||||
landTime = 0f;
|
||||
graphics.clear(Color.black);
|
||||
}else{
|
||||
Vector2 position = Tmp.v3.set(player);
|
||||
Vec2 position = Tmp.v3.set(player);
|
||||
|
||||
if(player.isDead()){
|
||||
TileEntity core = player.getClosestCore();
|
||||
@@ -344,11 +343,7 @@ public class Renderer implements ApplicationListener{
|
||||
Draw.rect("circle-shadow", u.x, u.y, size * rad, size * rad);
|
||||
};
|
||||
|
||||
for(EntityGroup<? extends BaseUnit> group : unitGroups){
|
||||
if(!group.isEmpty()){
|
||||
group.draw(unit -> !unit.isDead(), draw::get);
|
||||
}
|
||||
}
|
||||
unitGroup.draw(unit -> !unit.isDead(), draw::get);
|
||||
|
||||
if(!playerGroup.isEmpty()){
|
||||
playerGroup.draw(unit -> !unit.isDead(), draw::get);
|
||||
@@ -361,34 +356,21 @@ public class Renderer implements ApplicationListener{
|
||||
float trnsX = -12, trnsY = -13;
|
||||
Draw.color(0, 0, 0, 0.22f);
|
||||
|
||||
for(EntityGroup<? extends BaseUnit> group : unitGroups){
|
||||
if(!group.isEmpty()){
|
||||
group.draw(unit -> unit.isFlying() && !unit.isDead(), baseUnit -> baseUnit.drawShadow(trnsX, trnsY));
|
||||
}
|
||||
}
|
||||
|
||||
if(!playerGroup.isEmpty()){
|
||||
playerGroup.draw(unit -> unit.isFlying() && !unit.isDead(), player -> player.drawShadow(trnsX, trnsY));
|
||||
}
|
||||
unitGroup.draw(unit -> unit.isFlying() && !unit.isDead(), baseUnit -> baseUnit.drawShadow(trnsX, trnsY));
|
||||
playerGroup.draw(unit -> unit.isFlying() && !unit.isDead(), player -> player.drawShadow(trnsX, trnsY));
|
||||
|
||||
Draw.color();
|
||||
}
|
||||
|
||||
private void drawAllTeams(boolean flying){
|
||||
for(Team team : Team.all){
|
||||
EntityGroup<BaseUnit> group = unitGroups[team.ordinal()];
|
||||
unitGroup.draw(u -> u.isFlying() == flying && !u.isDead(), Unit::drawUnder);
|
||||
playerGroup.draw(p -> p.isFlying() == flying && !p.isDead(), Unit::drawUnder);
|
||||
|
||||
if(group.count(p -> p.isFlying() == flying) + playerGroup.count(p -> p.isFlying() == flying && p.getTeam() == team) == 0 && flying) continue;
|
||||
unitGroup.draw(u -> u.isFlying() == flying && !u.isDead(), Unit::drawAll);
|
||||
playerGroup.draw(p -> p.isFlying() == flying, Unit::drawAll);
|
||||
|
||||
unitGroups[team.ordinal()].draw(u -> u.isFlying() == flying && !u.isDead(), Unit::drawUnder);
|
||||
playerGroup.draw(p -> p.isFlying() == flying && p.getTeam() == team && !p.isDead(), Unit::drawUnder);
|
||||
|
||||
unitGroups[team.ordinal()].draw(u -> u.isFlying() == flying && !u.isDead(), Unit::drawAll);
|
||||
playerGroup.draw(p -> p.isFlying() == flying && p.getTeam() == team, Unit::drawAll);
|
||||
|
||||
unitGroups[team.ordinal()].draw(u -> u.isFlying() == flying && !u.isDead(), Unit::drawOver);
|
||||
playerGroup.draw(p -> p.isFlying() == flying && p.getTeam() == team, Unit::drawOver);
|
||||
}
|
||||
unitGroup.draw(u -> u.isFlying() == flying && !u.isDead(), Unit::drawOver);
|
||||
playerGroup.draw(p -> p.isFlying() == flying, Unit::drawOver);
|
||||
}
|
||||
|
||||
public void scaleCamera(float amount){
|
||||
@@ -456,7 +438,7 @@ public class Renderer implements ApplicationListener{
|
||||
buffer.end();
|
||||
Pixmap fullPixmap = new Pixmap(w, h, Pixmap.Format.RGBA8888);
|
||||
BufferUtils.copy(lines, 0, fullPixmap.getPixels(), lines.length);
|
||||
FileHandle file = screenshotDirectory.child("screenshot-" + Time.millis() + ".png");
|
||||
Fi file = screenshotDirectory.child("screenshot-" + Time.millis() + ".png");
|
||||
PixmapIO.writePNG(file, fullPixmap);
|
||||
fullPixmap.dispose();
|
||||
ui.showInfoFade(Core.bundle.format("screenshot", file.toString()));
|
||||
@@ -1,47 +1,48 @@
|
||||
package io.anuke.mindustry.core;
|
||||
package mindustry.core;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.Graphics.*;
|
||||
import io.anuke.arc.Graphics.Cursor.*;
|
||||
import io.anuke.arc.Input.*;
|
||||
import io.anuke.arc.assets.*;
|
||||
import io.anuke.arc.assets.loaders.*;
|
||||
import io.anuke.arc.assets.loaders.resolvers.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.freetype.*;
|
||||
import io.anuke.arc.freetype.FreeTypeFontGenerator.*;
|
||||
import io.anuke.arc.freetype.FreetypeFontLoader.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.Texture.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.input.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.scene.*;
|
||||
import io.anuke.arc.scene.actions.*;
|
||||
import io.anuke.arc.scene.event.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.TextField.*;
|
||||
import io.anuke.arc.scene.ui.Tooltip.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.editor.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
import io.anuke.mindustry.ui.fragments.*;
|
||||
import arc.*;
|
||||
import arc.Graphics.*;
|
||||
import arc.Graphics.Cursor.*;
|
||||
import arc.Input.*;
|
||||
import arc.assets.*;
|
||||
import arc.assets.loaders.*;
|
||||
import arc.assets.loaders.resolvers.*;
|
||||
import arc.struct.*;
|
||||
import arc.files.*;
|
||||
import arc.freetype.*;
|
||||
import arc.freetype.FreeTypeFontGenerator.*;
|
||||
import arc.freetype.FreetypeFontLoader.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.Texture.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.input.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.*;
|
||||
import arc.scene.actions.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.TextField.*;
|
||||
import arc.scene.ui.Tooltip.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.editor.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import mindustry.ui.fragments.*;
|
||||
|
||||
import static io.anuke.arc.scene.actions.Actions.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static arc.scene.actions.Actions.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class UI implements ApplicationListener, Loadable{
|
||||
public MenuFragment menufrag;
|
||||
public HudFragment hudfrag;
|
||||
public ChatFragment chatfrag;
|
||||
public ScriptConsoleFragment scriptfrag;
|
||||
public PlayerListFragment listfrag;
|
||||
public LoadingFragment loadfrag;
|
||||
|
||||
@@ -137,7 +138,7 @@ public class UI implements ApplicationListener, Loadable{
|
||||
Core.assets.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
|
||||
Core.assets.setLoader(BitmapFont.class, null, new FreetypeFontLoader(resolver){
|
||||
@Override
|
||||
public BitmapFont loadSync(AssetManager manager, String fileName, FileHandle file, FreeTypeFontLoaderParameter parameter){
|
||||
public BitmapFont loadSync(AssetManager manager, String fileName, Fi file, FreeTypeFontLoaderParameter parameter){
|
||||
if(fileName.equals("outline")){
|
||||
parameter.fontParameters.borderWidth = Scl.scl(2f);
|
||||
parameter.fontParameters.spaceX -= parameter.fontParameters.borderWidth;
|
||||
@@ -211,6 +212,7 @@ public class UI implements ApplicationListener, Loadable{
|
||||
chatfrag = new ChatFragment();
|
||||
listfrag = new PlayerListFragment();
|
||||
loadfrag = new LoadingFragment();
|
||||
scriptfrag = new ScriptConsoleFragment();
|
||||
|
||||
picker = new ColorPicker();
|
||||
editor = new MapEditorDialog();
|
||||
@@ -253,6 +255,7 @@ public class UI implements ApplicationListener, Loadable{
|
||||
menufrag.build(menuGroup);
|
||||
chatfrag.container().build(hudGroup);
|
||||
listfrag.build(hudGroup);
|
||||
scriptfrag.container().build(hudGroup);
|
||||
loadfrag.build(group);
|
||||
new FadeInFragment().build(group);
|
||||
}
|
||||
@@ -371,6 +374,37 @@ public class UI implements ApplicationListener, Loadable{
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showExceptions(String text, String... messages){
|
||||
loadfrag.hide();
|
||||
new Dialog(""){{
|
||||
|
||||
setFillParent(true);
|
||||
cont.margin(15);
|
||||
cont.add("$error.title").colspan(2);
|
||||
cont.row();
|
||||
cont.addImage().width(300f).pad(2).colspan(2).height(4f).color(Color.scarlet);
|
||||
cont.row();
|
||||
cont.add(text).colspan(2).wrap().growX().center().get().setAlignment(Align.center);
|
||||
cont.row();
|
||||
|
||||
//cont.pane(p -> {
|
||||
for(int i = 0; i < messages.length; i += 2){
|
||||
String btext = messages[i];
|
||||
String details = messages[i + 1];
|
||||
Collapser col = new Collapser(base -> base.pane(t -> t.margin(14f).add(details).color(Color.lightGray).left()), true);
|
||||
|
||||
cont.add(btext).right();
|
||||
cont.addButton("$details", Styles.togglet, col::toggle).size(180f, 50f).checked(b -> !col.isCollapsed()).fillX().left();
|
||||
cont.row();
|
||||
cont.add(col).colspan(2).pad(2);
|
||||
cont.row();
|
||||
}
|
||||
//}).colspan(2);
|
||||
|
||||
cont.addButton("$ok", this::hide).size(300, 50).fillX().colspan(2);
|
||||
}}.show();
|
||||
}
|
||||
|
||||
public void showText(String titleText, String text){
|
||||
showText(titleText, text, Align.center);
|
||||
}
|
||||
48
core/src/mindustry/core/Version.java
Normal file
48
core/src/mindustry/core/Version.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package mindustry.core;
|
||||
|
||||
import arc.*;
|
||||
import arc.Files.*;
|
||||
import arc.struct.*;
|
||||
import arc.files.*;
|
||||
import arc.util.*;
|
||||
import arc.util.io.*;
|
||||
|
||||
public class Version{
|
||||
/** Build type. 'official' for official releases; 'custom' or 'bleeding edge' are also used. */
|
||||
public static String type;
|
||||
/** Build modifier, e.g. 'alpha' or 'release' */
|
||||
public static String modifier;
|
||||
/** Number specifying the major version, e.g. '4' */
|
||||
public static int number;
|
||||
/** Build number, e.g. '43'. set to '-1' for custom builds. */
|
||||
public static int build = 0;
|
||||
/** Revision number. Used for hotfixes. Does not affect server compatibility. */
|
||||
public static int revision = 0;
|
||||
/** Whether version loading is enabled. */
|
||||
public static boolean enabled = true;
|
||||
|
||||
public static void init(){
|
||||
if(!enabled) return;
|
||||
|
||||
Fi file = OS.isAndroid || OS.isIos ? Core.files.internal("version.properties") : new Fi("version.properties", FileType.internal);
|
||||
|
||||
ObjectMap<String, String> map = new ObjectMap<>();
|
||||
PropertiesUtils.load(map, file.reader());
|
||||
|
||||
type = map.get("type");
|
||||
number = Integer.parseInt(map.get("number", "4"));
|
||||
modifier = map.get("modifier");
|
||||
if(map.get("build").contains(".")){
|
||||
String[] split = map.get("build").split("\\.");
|
||||
try{
|
||||
build = Integer.parseInt(split[0]);
|
||||
revision = Integer.parseInt(split[1]);
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace();
|
||||
build = -1;
|
||||
}
|
||||
}else{
|
||||
build = Strings.canParseInt(map.get("build")) ? Integer.parseInt(map.get("build")) : -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
package io.anuke.mindustry.core;
|
||||
package mindustry.core;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.ArcAnnotate.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.maps.*;
|
||||
import io.anuke.mindustry.maps.filters.*;
|
||||
import io.anuke.mindustry.maps.filters.GenerateFilter.*;
|
||||
import io.anuke.mindustry.maps.generators.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import arc.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import arc.util.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.Teams.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.maps.filters.*;
|
||||
import mindustry.maps.filters.GenerateFilter.*;
|
||||
import mindustry.maps.generators.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class World{
|
||||
public final Context context = new Context();
|
||||
@@ -233,33 +233,22 @@ public class World{
|
||||
invalidMap = false;
|
||||
|
||||
if(!headless){
|
||||
if(state.teams.get(defaultTeam).cores.size == 0 && !checkRules.pvp){
|
||||
if(state.teams.playerCores().size == 0 && !checkRules.pvp){
|
||||
ui.showErrorMessage("$map.nospawn");
|
||||
invalidMap = true;
|
||||
}else if(checkRules.pvp){ //pvp maps need two cores to be valid
|
||||
int teams = 0;
|
||||
for(Team team : Team.all){
|
||||
if(state.teams.get(team).cores.size != 0){
|
||||
teams ++;
|
||||
}
|
||||
}
|
||||
if(teams < 2){
|
||||
if(state.teams.getActive().count(TeamData::hasCore) < 2){
|
||||
invalidMap = true;
|
||||
ui.showErrorMessage("$map.nospawn.pvp");
|
||||
}
|
||||
}else if(checkRules.attackMode){ //attack maps need two cores to be valid
|
||||
invalidMap = state.teams.get(waveTeam).cores.isEmpty();
|
||||
invalidMap = state.teams.get(state.rules.waveTeam).noCores();
|
||||
if(invalidMap){
|
||||
ui.showErrorMessage("$map.nospawn.attack");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
invalidMap = true;
|
||||
for(Team team : Team.all){
|
||||
if(state.teams.get(team).cores.size != 0){
|
||||
invalidMap = false;
|
||||
}
|
||||
}
|
||||
invalidMap = !state.teams.getActive().contains(TeamData::hasCore);
|
||||
|
||||
if(invalidMap){
|
||||
throw new MapException(map, "Map has no cores!");
|
||||
@@ -275,36 +264,6 @@ public class World{
|
||||
}
|
||||
}
|
||||
|
||||
public void removeBlock(Tile tile){
|
||||
if(tile == null) return;
|
||||
tile.link().getLinkedTiles(other -> other.setBlock(Blocks.air));
|
||||
}
|
||||
|
||||
public void setBlock(Tile tile, Block block, Team team){
|
||||
setBlock(tile, block, team, 0);
|
||||
}
|
||||
|
||||
public void setBlock(Tile tile, Block block, Team team, int rotation){
|
||||
tile.setBlock(block, team, rotation);
|
||||
if(block.isMultiblock()){
|
||||
int offsetx = -(block.size - 1) / 2;
|
||||
int offsety = -(block.size - 1) / 2;
|
||||
|
||||
for(int dx = 0; dx < block.size; dx++){
|
||||
for(int dy = 0; dy < block.size; dy++){
|
||||
int worldx = dx + offsetx + tile.x;
|
||||
int worldy = dy + offsety + tile.y;
|
||||
if(!(worldx == tile.x && worldy == tile.y)){
|
||||
Tile toplace = world.tile(worldx, worldy);
|
||||
if(toplace != null){
|
||||
toplace.setBlock(BlockPart.get(dx + offsetx, dy + offsety), team);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void raycastEachWorld(float x0, float y0, float x1, float y1, Raycaster cons){
|
||||
raycastEach(toTile(x0), toTile(y0), toTile(x1), toTile(y1), cons);
|
||||
}
|
||||
63
core/src/mindustry/ctype/Content.java
Normal file
63
core/src/mindustry/ctype/Content.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package mindustry.ctype;
|
||||
|
||||
import arc.files.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.*;
|
||||
import mindustry.mod.Mods.*;
|
||||
|
||||
|
||||
/** Base class for a content type that is loaded in {@link mindustry.core.ContentLoader}. */
|
||||
public abstract class Content implements Comparable<Content>{
|
||||
public final short id;
|
||||
/** Info on which mod this content was loaded from. */
|
||||
public @NonNull ModContentInfo minfo = new ModContentInfo();
|
||||
|
||||
|
||||
public Content(){
|
||||
this.id = (short) Vars.content.getBy(getContentType()).size;
|
||||
Vars.content.handleContent(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type name of this piece of content.
|
||||
* This should return the same value for all instances of this content type.
|
||||
*/
|
||||
public abstract ContentType getContentType();
|
||||
|
||||
/** Called after all content and modules are created. Do not use to load regions or texture data! */
|
||||
public void init(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after all content is created, only on non-headless versions.
|
||||
* Use for loading regions or other image data.
|
||||
*/
|
||||
public void load(){
|
||||
}
|
||||
|
||||
/** @return whether an error ocurred during mod loading. */
|
||||
public boolean hasErrored(){
|
||||
return minfo.error != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Content c){
|
||||
return Integer.compare(id, c.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return getContentType().name() + "#" + id;
|
||||
}
|
||||
|
||||
public static class ModContentInfo{
|
||||
/** The mod that loaded this piece of content. */
|
||||
public @Nullable LoadedMod mod;
|
||||
/** File that this content was loaded from. */
|
||||
public @Nullable Fi sourceFile;
|
||||
/** The error that occurred during loading, if applicable. Null if no error occurred. */
|
||||
public @Nullable String error;
|
||||
/** Base throwable that caused the error. */
|
||||
public @Nullable Throwable baseError;
|
||||
}
|
||||
}
|
||||
7
core/src/mindustry/ctype/ContentList.java
Normal file
7
core/src/mindustry/ctype/ContentList.java
Normal file
@@ -0,0 +1,7 @@
|
||||
package mindustry.ctype;
|
||||
|
||||
/** Interface for a list of content to be loaded in {@link mindustry.core.ContentLoader}. */
|
||||
public interface ContentList{
|
||||
/** This method should create all the content. */
|
||||
void load();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.anuke.mindustry.type;
|
||||
package mindustry.ctype;
|
||||
|
||||
/** Do not rearrange, ever! */
|
||||
public enum ContentType{
|
||||
@@ -13,7 +13,8 @@ public enum ContentType{
|
||||
effect,
|
||||
zone,
|
||||
loadout,
|
||||
typeid;
|
||||
typeid,
|
||||
error;
|
||||
|
||||
public static final ContentType[] all = values();
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package io.anuke.mindustry.ctype;
|
||||
package mindustry.ctype;
|
||||
|
||||
import io.anuke.mindustry.*;
|
||||
import mindustry.*;
|
||||
|
||||
public abstract class MappableContent extends Content{
|
||||
public final String name;
|
||||
|
||||
public MappableContent(String name){
|
||||
this.name = name;
|
||||
this.name = Vars.content.transformName(name);
|
||||
Vars.content.handleMappableContent(this);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package io.anuke.mindustry.ctype;
|
||||
package mindustry.ctype;
|
||||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.ui.Cicon;
|
||||
import arc.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import mindustry.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.Cicon;
|
||||
|
||||
/** Base interface for an unlockable content type. */
|
||||
public abstract class UnlockableContent extends MappableContent{
|
||||
@@ -15,13 +15,13 @@ public abstract class UnlockableContent extends MappableContent{
|
||||
/** Localized description. May be null. */
|
||||
public String description;
|
||||
/** Icons by Cicon ID.*/
|
||||
protected TextureRegion[] cicons = new TextureRegion[io.anuke.mindustry.ui.Cicon.all.length];
|
||||
protected TextureRegion[] cicons = new TextureRegion[mindustry.ui.Cicon.all.length];
|
||||
|
||||
public UnlockableContent(String name){
|
||||
super(name);
|
||||
|
||||
this.localizedName = Core.bundle.get(getContentType() + "." + name + ".name", name);
|
||||
this.description = Core.bundle.getOrNull(getContentType() + "." + name + ".description");
|
||||
this.localizedName = Core.bundle.get(getContentType() + "." + this.name + ".name", this.name);
|
||||
this.description = Core.bundle.getOrNull(getContentType() + "." + this.name + ".description");
|
||||
}
|
||||
|
||||
/** Generate any special icons for this content. Called asynchronously.*/
|
||||
@@ -1,14 +1,14 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.annotations.Annotations.Struct;
|
||||
import io.anuke.arc.collection.LongArray;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.gen.TileOp;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import mindustry.annotations.Annotations.Struct;
|
||||
import arc.struct.LongArray;
|
||||
import mindustry.game.Team;
|
||||
import mindustry.gen.TileOp;
|
||||
import mindustry.world.Block;
|
||||
import mindustry.world.Tile;
|
||||
import mindustry.world.blocks.Floor;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static mindustry.Vars.content;
|
||||
|
||||
public class DrawOperation{
|
||||
private MapEditor editor;
|
||||
@@ -69,7 +69,7 @@ public class DrawOperation{
|
||||
}else if(type == OpType.rotation.ordinal()){
|
||||
tile.rotation(to);
|
||||
}else if(type == OpType.team.ordinal()){
|
||||
tile.setTeam(Team.all[to]);
|
||||
tile.setTeam(Team.get(to));
|
||||
}else if(type == OpType.overlay.ordinal()){
|
||||
tile.setOverlayID(to);
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.editor.DrawOperation.OpType;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.gen.TileOp;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.mindustry.world.modules.*;
|
||||
import mindustry.content.Blocks;
|
||||
import mindustry.core.GameState.State;
|
||||
import mindustry.editor.DrawOperation.OpType;
|
||||
import mindustry.game.Team;
|
||||
import mindustry.gen.TileOp;
|
||||
import mindustry.world.Block;
|
||||
import mindustry.world.Tile;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.modules.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
import static mindustry.Vars.state;
|
||||
import static mindustry.Vars.ui;
|
||||
|
||||
//TODO somehow remove or replace this class with a more flexible solution
|
||||
public class EditorTile extends Tile{
|
||||
@@ -74,7 +74,7 @@ public class EditorTile extends Tile{
|
||||
return;
|
||||
}
|
||||
|
||||
if(getTeamID() == team.ordinal()) return;
|
||||
if(getTeamID() == team.id) return;
|
||||
op(OpType.team, getTeamID());
|
||||
super.setTeam(team);
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.arc.collection.IntArray;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Bresenham2;
|
||||
import io.anuke.arc.util.Structs;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.BlockPart;
|
||||
import arc.func.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
public enum EditorTool{
|
||||
zoom,
|
||||
@@ -80,7 +79,7 @@ public enum EditorTool{
|
||||
editor.drawCircle(x, y, tile -> {
|
||||
if(mode == -1){
|
||||
//erase block
|
||||
Vars.world.removeBlock(tile);
|
||||
tile.remove();
|
||||
}else if(mode == 0){
|
||||
//erase ore
|
||||
tile.clearOverlay();
|
||||
@@ -141,7 +140,7 @@ public enum EditorTool{
|
||||
if(tile.link().synthetic()){
|
||||
Team dest = tile.getTeam();
|
||||
if(dest == editor.drawTeam) return;
|
||||
fill(editor, x, y, false, t -> t.getTeamID() == dest.ordinal() && t.link().synthetic(), t -> t.setTeam(editor.drawTeam));
|
||||
fill(editor, x, y, false, t -> t.getTeamID() == (int)dest.id && t.link().synthetic(), t -> t.setTeam(editor.drawTeam));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,21 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.arc.collection.StringMap;
|
||||
import io.anuke.arc.files.FileHandle;
|
||||
import io.anuke.arc.func.Cons;
|
||||
import io.anuke.arc.func.Boolf;
|
||||
import io.anuke.arc.graphics.Pixmap;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Structs;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.gen.TileOp;
|
||||
import io.anuke.mindustry.io.LegacyMapIO;
|
||||
import io.anuke.mindustry.io.MapIO;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.BlockPart;
|
||||
import arc.struct.StringMap;
|
||||
import arc.files.Fi;
|
||||
import arc.func.Cons;
|
||||
import arc.func.Boolf;
|
||||
import arc.graphics.Pixmap;
|
||||
import arc.math.Mathf;
|
||||
import arc.util.Structs;
|
||||
import mindustry.content.Blocks;
|
||||
import mindustry.game.Team;
|
||||
import mindustry.gen.TileOp;
|
||||
import mindustry.io.MapIO;
|
||||
import mindustry.maps.Map;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.BlockPart;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class MapEditor{
|
||||
public static final int[] brushSizes = {1, 2, 3, 4, 5, 9, 15, 20};
|
||||
@@ -65,7 +64,7 @@ public class MapEditor{
|
||||
reset();
|
||||
|
||||
createTiles(pixmap.getWidth(), pixmap.getHeight());
|
||||
load(() -> LegacyMapIO.readPixmap(pixmap, tiles()));
|
||||
load(() -> MapIO.readPixmap(pixmap, tiles()));
|
||||
renderer.resize(width(), height());
|
||||
}
|
||||
|
||||
@@ -86,7 +85,7 @@ public class MapEditor{
|
||||
for(int x = 0; x < width(); x++){
|
||||
for(int y = 0; y < height(); y++){
|
||||
if(tiles[x][y].block().isMultiblock()){
|
||||
world.setBlock(tiles[x][y], tiles[x][y].block(), tiles[x][y].getTeam());
|
||||
tiles[x][y].set(tiles[x][y].block(), tiles[x][y].getTeam());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +108,7 @@ public class MapEditor{
|
||||
}
|
||||
}
|
||||
|
||||
public Map createMap(FileHandle file){
|
||||
public Map createMap(Fi file){
|
||||
return new Map(file, width(), height(), new StringMap(tags), true);
|
||||
}
|
||||
|
||||
@@ -176,7 +175,7 @@ public class MapEditor{
|
||||
}
|
||||
}
|
||||
|
||||
world.setBlock(tile(x, y), drawBlock, drawTeam);
|
||||
tile(x, y).set(drawBlock, drawTeam);
|
||||
}else{
|
||||
boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air;
|
||||
|
||||
@@ -185,7 +184,7 @@ public class MapEditor{
|
||||
|
||||
//remove linked tiles blocking the way
|
||||
if(!isFloor && (tile.isLinked() || tile.block().isMultiblock())){
|
||||
world.removeBlock(tile.link());
|
||||
tile.link().remove();
|
||||
}
|
||||
|
||||
if(isFloor){
|
||||
@@ -1,37 +1,37 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.input.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.scene.actions.*;
|
||||
import io.anuke.arc.scene.event.*;
|
||||
import io.anuke.arc.scene.style.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.ArcAnnotate.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.maps.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import io.anuke.mindustry.ui.Cicon;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.mindustry.world.blocks.storage.*;
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.files.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.input.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.actions.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.style.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.Cicon;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.blocks.storage.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class MapEditorDialog extends Dialog implements Disposable{
|
||||
public final MapEditor editor;
|
||||
@@ -133,7 +133,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
}else{
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
FileHandle result = Core.files.local(editor.getTags().get("name", "unknown") + "." + mapExtension);
|
||||
Fi result = Core.files.local(editor.getTags().get("name", "unknown") + "." + mapExtension);
|
||||
MapIO.writeMap(result, editor.createMap(result));
|
||||
platform.shareFile(result);
|
||||
}catch(Exception e){
|
||||
@@ -381,7 +381,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
editor.renderer().dispose();
|
||||
}
|
||||
|
||||
public void beginEditMap(FileHandle file){
|
||||
public void beginEditMap(Fi file){
|
||||
ui.loadAnd(() -> {
|
||||
try{
|
||||
shownWithMap = true;
|
||||
@@ -475,7 +475,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
}
|
||||
|
||||
table.update(() -> {
|
||||
Vector2 v = button.localToStageCoordinates(Tmp.v1.setZero());
|
||||
Vec2 v = button.localToStageCoordinates(Tmp.v1.setZero());
|
||||
table.setPosition(v.x, v.y, Align.topLeft);
|
||||
if(!isShown()){
|
||||
table.remove();
|
||||
@@ -551,7 +551,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
|
||||
int i = 0;
|
||||
|
||||
for(Team team : Team.all){
|
||||
for(Team team : Team.base()){
|
||||
ImageButton button = new ImageButton(Tex.whiteui, Styles.clearTogglePartiali);
|
||||
button.margin(4f);
|
||||
button.getImageCell().grow();
|
||||
@@ -1,29 +1,29 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.Pixmap.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.ImageButton.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.async.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.maps.filters.*;
|
||||
import io.anuke.mindustry.maps.filters.GenerateFilter.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.Pixmap.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.ImageButton.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import arc.util.async.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.maps.filters.*;
|
||||
import mindustry.maps.filters.GenerateFilter.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class MapGenerateDialog extends FloatingDialog{
|
||||
@@ -138,7 +138,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
tile.rotation(write.rotation);
|
||||
tile.setFloor((Floor)content.block(write.floor));
|
||||
tile.setBlock(content.block(write.block));
|
||||
tile.setTeam(Team.all[write.team]);
|
||||
tile.setTeam(Team.get(write.team));
|
||||
tile.setOverlay(content.block(write.ore));
|
||||
}
|
||||
}
|
||||
@@ -187,7 +187,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 v = pane.stageToLocalCoordinates(Core.input.mouse());
|
||||
Vec2 v = pane.stageToLocalCoordinates(Core.input.mouse());
|
||||
|
||||
if(v.x >= 0 && v.y >= 0 && v.x <= pane.getWidth() && v.y <= pane.getHeight()){
|
||||
Core.scene.setScrollFocus(pane);
|
||||
@@ -367,7 +367,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
GenTile tile = buffer1[px][py];
|
||||
input.apply(x, y, content.block(tile.floor), content.block(tile.block), content.block(tile.ore));
|
||||
filter.apply(input);
|
||||
buffer2[px][py].set(input.floor, input.block, input.ore, Team.all[tile.team], tile.rotation);
|
||||
buffer2[px][py].set(input.floor, input.block, input.ore, Team.get(tile.team), tile.rotation);
|
||||
}
|
||||
}
|
||||
for(int px = 0; px < pixmap.getWidth(); px++){
|
||||
@@ -415,7 +415,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
this.floor = floor.id;
|
||||
this.block = wall.id;
|
||||
this.ore = ore.id;
|
||||
this.team = (byte)team.ordinal();
|
||||
this.team = (byte) team.id;
|
||||
this.rotation = (byte)rotation;
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
ctile.setBlock(content.block(block));
|
||||
ctile.setOverlay(content.block(ore));
|
||||
ctile.rotation(rotation);
|
||||
ctile.setTeam(Team.all[team]);
|
||||
ctile.setTeam(Team.get(team));
|
||||
return ctile;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.scene.ui.*;
|
||||
import mindustry.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
|
||||
public class MapInfoDialog extends FloatingDialog{
|
||||
private final MapEditor editor;
|
||||
@@ -1,14 +1,14 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.maps.*;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
import arc.func.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.maps;
|
||||
import static mindustry.Vars.maps;
|
||||
|
||||
public class MapLoadDialog extends FloatingDialog{
|
||||
private Map selected = null;
|
||||
@@ -1,23 +1,23 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.IntSet;
|
||||
import io.anuke.arc.collection.IntSet.IntSetIterator;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.Texture;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.graphics.IndexedRenderer;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.BlockPart;
|
||||
import arc.*;
|
||||
import arc.struct.IntSet;
|
||||
import arc.struct.IntSet.IntSetIterator;
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.Texture;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.TextureRegion;
|
||||
import arc.math.Mathf;
|
||||
import arc.util.*;
|
||||
import mindustry.content.Blocks;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.Team;
|
||||
import mindustry.graphics.IndexedRenderer;
|
||||
import mindustry.world.Block;
|
||||
import mindustry.world.Tile;
|
||||
import mindustry.world.blocks.BlockPart;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static mindustry.Vars.tilesize;
|
||||
|
||||
public class MapRenderer implements Disposable{
|
||||
private static final int chunkSize = 64;
|
||||
@@ -1,10 +1,10 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
import arc.func.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
|
||||
public class MapResizeDialog extends FloatingDialog{
|
||||
private static final int minSize = 50, maxSize = 500, increment = 50;
|
||||
@@ -1,12 +1,12 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.maps.*;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
import arc.func.*;
|
||||
import arc.scene.ui.*;
|
||||
import mindustry.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
import static mindustry.Vars.ui;
|
||||
|
||||
public class MapSaveDialog extends FloatingDialog{
|
||||
private TextField field;
|
||||
@@ -1,24 +1,24 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.input.GestureDetector;
|
||||
import io.anuke.arc.input.GestureDetector.GestureListener;
|
||||
import io.anuke.arc.input.KeyCode;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.scene.Element;
|
||||
import io.anuke.arc.scene.event.*;
|
||||
import io.anuke.arc.scene.ui.TextField;
|
||||
import io.anuke.arc.scene.ui.layout.Scl;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.input.Binding;
|
||||
import io.anuke.mindustry.ui.GridImage;
|
||||
import arc.Core;
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.input.GestureDetector;
|
||||
import arc.input.GestureDetector.GestureListener;
|
||||
import arc.input.KeyCode;
|
||||
import arc.math.Mathf;
|
||||
import arc.math.geom.*;
|
||||
import arc.scene.Element;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.ui.TextField;
|
||||
import arc.scene.ui.layout.Scl;
|
||||
import arc.util.*;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.input.Binding;
|
||||
import mindustry.ui.GridImage;
|
||||
|
||||
import static io.anuke.mindustry.Vars.mobile;
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
import static mindustry.Vars.mobile;
|
||||
import static mindustry.Vars.ui;
|
||||
|
||||
public class MapView extends Element implements GestureListener{
|
||||
private MapEditor editor;
|
||||
@@ -27,9 +27,9 @@ public class MapView extends Element implements GestureListener{
|
||||
private float zoom = 1f;
|
||||
private boolean grid = false;
|
||||
private GridImage image = new GridImage(0, 0);
|
||||
private Vector2 vec = new Vector2();
|
||||
private Rectangle rect = new Rectangle();
|
||||
private Vector2[][] brushPolygons = new Vector2[MapEditor.brushSizes.length][0];
|
||||
private Vec2 vec = new Vec2();
|
||||
private Rect rect = new Rect();
|
||||
private Vec2[][] brushPolygons = new Vec2[MapEditor.brushSizes.length][0];
|
||||
|
||||
private boolean drawing;
|
||||
private int lastx, lasty;
|
||||
@@ -214,7 +214,7 @@ public class MapView extends Element implements GestureListener{
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 unproject(int x, int y){
|
||||
private Vec2 unproject(int x, int y){
|
||||
float ratio = 1f / ((float)editor.width() / editor.height());
|
||||
float size = Math.min(width, height);
|
||||
float sclwidth = size * zoom;
|
||||
@@ -268,9 +268,9 @@ public class MapView extends Element implements GestureListener{
|
||||
|
||||
if((!editor.drawBlock.isMultiblock() || tool == EditorTool.eraser) && tool != EditorTool.fill){
|
||||
if(tool == EditorTool.line && drawing){
|
||||
Vector2 v1 = unproject(startx, starty).add(x, y);
|
||||
Vec2 v1 = unproject(startx, starty).add(x, y);
|
||||
float sx = v1.x, sy = v1.y;
|
||||
Vector2 v2 = unproject(lastx, lasty).add(x, y);
|
||||
Vec2 v2 = unproject(lastx, lasty).add(x, y);
|
||||
|
||||
Lines.poly(brushPolygons[index], sx, sy, scaling);
|
||||
Lines.poly(brushPolygons[index], v2.x, v2.y, scaling);
|
||||
@@ -278,7 +278,7 @@ public class MapView extends Element implements GestureListener{
|
||||
|
||||
if((tool.edit || (tool == EditorTool.line && !drawing)) && (!mobile || drawing)){
|
||||
Point2 p = project(mousex, mousey);
|
||||
Vector2 v = unproject(p.x, p.y).add(x, y);
|
||||
Vec2 v = unproject(p.x, p.y).add(x, y);
|
||||
|
||||
//pencil square outline
|
||||
if(tool == EditorTool.pencil && tool.mode == 1){
|
||||
@@ -290,7 +290,7 @@ public class MapView extends Element implements GestureListener{
|
||||
}else{
|
||||
if((tool.edit || tool == EditorTool.line) && (!mobile || drawing)){
|
||||
Point2 p = project(mousex, mousey);
|
||||
Vector2 v = unproject(p.x, p.y).add(x, y);
|
||||
Vec2 v = unproject(p.x, p.y).add(x, y);
|
||||
float offset = (editor.drawBlock.size % 2 == 0 ? scaling / 2f : 0f);
|
||||
Lines.square(
|
||||
v.x + scaling / 2f + offset,
|
||||
@@ -332,7 +332,7 @@ public class MapView extends Element implements GestureListener{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2){
|
||||
public boolean pinch(Vec2 initialPointer1, Vec2 initialPointer2, Vec2 pointer1, Vec2 pointer2){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.arc.collection.Array;
|
||||
import arc.struct.Array;
|
||||
|
||||
public class OperationStack{
|
||||
private final static int maxSize = 10;
|
||||
@@ -1,27 +1,28 @@
|
||||
package io.anuke.mindustry.editor;
|
||||
package mindustry.editor;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.input.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.scene.event.*;
|
||||
import io.anuke.arc.scene.ui.*;
|
||||
import io.anuke.arc.scene.ui.TextField.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.ui.Cicon;
|
||||
import io.anuke.mindustry.ui.dialogs.*;
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.graphics.*;
|
||||
import arc.input.*;
|
||||
import arc.math.*;
|
||||
import arc.scene.event.*;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.TextField.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.ctype.ContentType;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.Cicon;
|
||||
import mindustry.ui.dialogs.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.game.SpawnGroup.never;
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.game.SpawnGroup.never;
|
||||
|
||||
public class WaveInfoDialog extends FloatingDialog{
|
||||
private final static int displayed = 20;
|
||||
@@ -141,7 +142,7 @@ public class WaveInfoDialog extends FloatingDialog{
|
||||
t.margin(0).defaults().pad(3).padLeft(5f).growX().left();
|
||||
t.addButton(b -> {
|
||||
b.left();
|
||||
b.addImage(group.type.icon(io.anuke.mindustry.ui.Cicon.medium)).size(32f).padRight(3);
|
||||
b.addImage(group.type.icon(mindustry.ui.Cicon.medium)).size(32f).padRight(3);
|
||||
b.add(group.type.localizedName).color(Pal.accent);
|
||||
}, () -> showUpdate(group)).pad(-6f).padBottom(0f);
|
||||
|
||||
@@ -223,7 +224,7 @@ public class WaveInfoDialog extends FloatingDialog{
|
||||
for(UnitType type : content.units()){
|
||||
p.addButton(t -> {
|
||||
t.left();
|
||||
t.addImage(type.icon(io.anuke.mindustry.ui.Cicon.medium)).size(40f).padRight(2f);
|
||||
t.addImage(type.icon(mindustry.ui.Cicon.medium)).size(40f).padRight(2f);
|
||||
t.add(type.localizedName);
|
||||
}, () -> {
|
||||
lastType = type;
|
||||
@@ -1,30 +1,30 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
package mindustry.entities;
|
||||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.Effects.*;
|
||||
import io.anuke.mindustry.entities.effect.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import arc.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import arc.struct.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.Effects.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
/** Utility class for damaging in an area. */
|
||||
public class Damage{
|
||||
private static Rectangle rect = new Rectangle();
|
||||
private static Rectangle hitrect = new Rectangle();
|
||||
private static Vector2 tr = new Vector2();
|
||||
private static Rect rect = new Rect();
|
||||
private static Rect hitrect = new Rect();
|
||||
private static Vec2 tr = new Vec2();
|
||||
private static GridBits bits = new GridBits(30, 30);
|
||||
private static IntQueue propagation = new IntQueue();
|
||||
private static IntSet collidedBlocks = new IntSet();
|
||||
@@ -38,7 +38,7 @@ public class Damage{
|
||||
}
|
||||
|
||||
for(int i = 0; i < Mathf.clamp(flammability / 4, 0, 30); i++){
|
||||
Time.run(i / 2f, () -> Call.createBullet(Bullets.fireball, x, y, Mathf.random(360f)));
|
||||
Time.run(i / 2f, () -> Call.createBullet(Bullets.fireball, Team.derelict, x, y, Mathf.random(360f), 1, 1));
|
||||
}
|
||||
|
||||
int waves = Mathf.clamp((int)(explosiveness / 4), 0, 30);
|
||||
@@ -88,7 +88,7 @@ public class Damage{
|
||||
tr.trns(angle, length);
|
||||
Intc2 collider = (cx, cy) -> {
|
||||
Tile tile = world.ltile(cx, cy);
|
||||
if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.entity != null && tile.getTeamID() != team.ordinal() && tile.entity.collide(hitter)){
|
||||
if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.entity != null && tile.getTeamID() != team.id && tile.entity.collide(hitter)){
|
||||
tile.entity.collision(hitter);
|
||||
collidedBlocks.add(tile.pos());
|
||||
hitter.getBulletType().hit(hitter, tile.worldx(), tile.worldy());
|
||||
@@ -127,13 +127,13 @@ public class Damage{
|
||||
|
||||
Cons<Unit> cons = e -> {
|
||||
e.hitbox(hitrect);
|
||||
Rectangle other = hitrect;
|
||||
Rect other = hitrect;
|
||||
other.y -= expand;
|
||||
other.x -= expand;
|
||||
other.width += expand * 2;
|
||||
other.height += expand * 2;
|
||||
|
||||
Vector2 vec = Geometry.raycastRect(x, y, x2, y2, other);
|
||||
Vec2 vec = Geometry.raycastRect(x, y, x2, y2, other);
|
||||
|
||||
if(vec != null){
|
||||
Effects.effect(effect, vec.x, vec.y);
|
||||
@@ -259,7 +259,7 @@ public class Damage{
|
||||
for(int dx = -trad; dx <= trad; dx++){
|
||||
for(int dy = -trad; dy <= trad; dy++){
|
||||
Tile tile = world.tile(Math.round(x / tilesize) + dx, Math.round(y / tilesize) + dy);
|
||||
if(tile != null && tile.entity != null && (team == null || state.teams.areEnemies(team, tile.getTeam())) && Mathf.dst(dx, dy) <= trad){
|
||||
if(tile != null && tile.entity != null && (team == null ||team.isEnemy(tile.getTeam())) && Mathf.dst(dx, dy) <= trad){
|
||||
tile.entity.damage(damage);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
package mindustry.entities;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.func.Cons;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Position;
|
||||
import io.anuke.arc.util.pooling.Pools;
|
||||
import io.anuke.mindustry.entities.type.EffectEntity;
|
||||
import io.anuke.mindustry.entities.traits.ScaleTrait;
|
||||
import arc.Core;
|
||||
import arc.struct.Array;
|
||||
import arc.func.Cons;
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.Mathf;
|
||||
import arc.math.geom.Position;
|
||||
import arc.util.pooling.Pools;
|
||||
import mindustry.entities.type.EffectEntity;
|
||||
import mindustry.entities.traits.ScaleTrait;
|
||||
|
||||
public class Effects{
|
||||
private static final EffectContainer container = new EffectContainer();
|
||||
@@ -36,6 +37,7 @@ public class Effects{
|
||||
public static void renderEffect(int id, Effect render, Color color, float life, float rotation, float x, float y, Object data){
|
||||
container.set(id, color, life, render.lifetime, rotation, x, y, data);
|
||||
render.draw.render(container);
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
public static Effect getEffect(int id){
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
package mindustry.entities;
|
||||
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.entities.traits.*;
|
||||
|
||||
/** Simple container for managing entity groups.*/
|
||||
public class Entities{
|
||||
@@ -1,14 +1,14 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
package mindustry.entities;
|
||||
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.mindustry.entities.traits.Entity;
|
||||
import io.anuke.mindustry.entities.traits.SolidTrait;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import arc.struct.Array;
|
||||
import arc.math.Mathf;
|
||||
import arc.math.geom.*;
|
||||
import mindustry.entities.traits.Entity;
|
||||
import mindustry.entities.traits.SolidTrait;
|
||||
import mindustry.world.Tile;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static mindustry.Vars.tilesize;
|
||||
import static mindustry.Vars.world;
|
||||
|
||||
public class EntityCollisions{
|
||||
//range for tile collision scanning
|
||||
@@ -17,11 +17,11 @@ public class EntityCollisions{
|
||||
private static final float seg = 1f;
|
||||
|
||||
//tile collisions
|
||||
private Rectangle tmp = new Rectangle();
|
||||
private Vector2 vector = new Vector2();
|
||||
private Vector2 l1 = new Vector2();
|
||||
private Rectangle r1 = new Rectangle();
|
||||
private Rectangle r2 = new Rectangle();
|
||||
private Rect tmp = new Rect();
|
||||
private Vec2 vector = new Vec2();
|
||||
private Vec2 l1 = new Vec2();
|
||||
private Rect r1 = new Rect();
|
||||
private Rect r2 = new Rect();
|
||||
|
||||
//entity collisions
|
||||
private Array<SolidTrait> arrOut = new Array<>();
|
||||
@@ -57,7 +57,7 @@ public class EntityCollisions{
|
||||
|
||||
public void moveDelta(SolidTrait entity, float deltax, float deltay, boolean x){
|
||||
|
||||
Rectangle rect = r1;
|
||||
Rect rect = r1;
|
||||
entity.hitboxTile(rect);
|
||||
entity.hitboxTile(r2);
|
||||
rect.x += deltax;
|
||||
@@ -72,7 +72,7 @@ public class EntityCollisions{
|
||||
tmp.setSize(tilesize).setCenter(wx * tilesize, wy * tilesize);
|
||||
|
||||
if(tmp.overlaps(rect)){
|
||||
Vector2 v = Geometry.overlap(rect, tmp, x);
|
||||
Vec2 v = Geometry.overlap(rect, tmp, x);
|
||||
rect.x += v.x;
|
||||
rect.y += v.y;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class EntityCollisions{
|
||||
entity.setY(entity.getY() + rect.y - r2.y);
|
||||
}
|
||||
|
||||
public boolean overlapsTile(Rectangle rect){
|
||||
public boolean overlapsTile(Rect rect){
|
||||
rect.getCenter(vector);
|
||||
int r = 1;
|
||||
|
||||
@@ -157,7 +157,7 @@ public class EntityCollisions{
|
||||
}
|
||||
|
||||
private boolean collide(float x1, float y1, float w1, float h1, float vx1, float vy1,
|
||||
float x2, float y2, float w2, float h2, float vx2, float vy2, Vector2 out){
|
||||
float x2, float y2, float w2, float h2, float vx2, float vy2, Vec2 out){
|
||||
float px = vx1, py = vy1;
|
||||
|
||||
vx1 -= vx2;
|
||||
@@ -1,13 +1,13 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
package mindustry.entities;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.func.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.math.geom.*;
|
||||
import mindustry.entities.traits.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.collisions;
|
||||
import static mindustry.Vars.collisions;
|
||||
|
||||
/** Represents a group of a certain type of entity.*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -19,13 +19,13 @@ public class EntityGroup<T extends Entity>{
|
||||
private final Array<T> entitiesToRemove = new Array<>(false, 32);
|
||||
private final Array<T> entitiesToAdd = new Array<>(false, 32);
|
||||
private final Array<T> intersectArray = new Array<>();
|
||||
private final Rectangle intersectRect = new Rectangle();
|
||||
private final Rect intersectRect = new Rect();
|
||||
private IntMap<T> map;
|
||||
private QuadTree tree;
|
||||
private Cons<T> removeListener;
|
||||
private Cons<T> addListener;
|
||||
|
||||
private final Rectangle viewport = new Rectangle();
|
||||
private final Rect viewport = new Rect();
|
||||
private int count = 0;
|
||||
|
||||
public EntityGroup(int id, Class<T> type, boolean useTree){
|
||||
@@ -34,7 +34,7 @@ public class EntityGroup<T extends Entity>{
|
||||
this.type = type;
|
||||
|
||||
if(useTree){
|
||||
tree = new QuadTree<>(new Rectangle(0, 0, 0, 0));
|
||||
tree = new QuadTree<>(new Rect(0, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public class EntityGroup<T extends Entity>{
|
||||
/** Resizes the internal quadtree, if it is enabled.*/
|
||||
public void resize(float x, float y, float w, float h){
|
||||
if(useTree){
|
||||
tree = new QuadTree<>(new Rectangle(x, y, w, h));
|
||||
tree = new QuadTree<>(new Rect(x, y, w, h));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
package mindustry.entities;
|
||||
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.traits.*;
|
||||
|
||||
/**
|
||||
* Class for predicting shoot angles based on velocities of targets.
|
||||
*/
|
||||
public class Predict{
|
||||
private static Vector2 vec = new Vector2();
|
||||
private static Vector2 vresult = new Vector2();
|
||||
private static Vec2 vec = new Vec2();
|
||||
private static Vec2 vresult = new Vec2();
|
||||
|
||||
/**
|
||||
* Calculates of intercept of a stationary and moving target. Do not call from multiple threads!
|
||||
@@ -23,7 +23,7 @@ public class Predict{
|
||||
* @param v speed of bullet
|
||||
* @return the intercept location
|
||||
*/
|
||||
public static Vector2 intercept(float srcx, float srcy, float dstx, float dsty, float dstvx, float dstvy, float v){
|
||||
public static Vec2 intercept(float srcx, float srcy, float dstx, float dsty, float dstvx, float dstvy, float v){
|
||||
dstvx /= Time.delta();
|
||||
dstvy /= Time.delta();
|
||||
float tx = dstx - srcx,
|
||||
@@ -35,10 +35,10 @@ public class Predict{
|
||||
float c = tx * tx + ty * ty;
|
||||
|
||||
// Solve quadratic
|
||||
Vector2 ts = quad(a, b, c);
|
||||
Vec2 ts = quad(a, b, c);
|
||||
|
||||
// Find smallest positive solution
|
||||
Vector2 sol = vresult.set(dstx, dsty);
|
||||
Vec2 sol = vresult.set(dstx, dsty);
|
||||
if(ts != null){
|
||||
float t0 = ts.x, t1 = ts.y;
|
||||
float t = Math.min(t0, t1);
|
||||
@@ -54,12 +54,12 @@ public class Predict{
|
||||
/**
|
||||
* See {@link #intercept(float, float, float, float, float, float, float)}.
|
||||
*/
|
||||
public static Vector2 intercept(TargetTrait src, TargetTrait dst, float v){
|
||||
public static Vec2 intercept(TargetTrait src, TargetTrait dst, float v){
|
||||
return intercept(src.getX(), src.getY(), dst.getX(), dst.getY(), dst.getTargetVelocityX() - src.getTargetVelocityX()/2f, dst.getTargetVelocityY() - src.getTargetVelocityY()/2f, v);
|
||||
}
|
||||
|
||||
private static Vector2 quad(float a, float b, float c){
|
||||
Vector2 sol = null;
|
||||
private static Vec2 quad(float a, float b, float c){
|
||||
Vec2 sol = null;
|
||||
if(Math.abs(a) < 1e-6){
|
||||
if(Math.abs(b) < 1e-6){
|
||||
sol = Math.abs(c) < 1e-6 ? vec.set(0, 0) : null;
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
package mindustry.entities;
|
||||
|
||||
public enum TargetPriority{
|
||||
base,
|
||||
@@ -1,21 +1,18 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
package mindustry.entities;
|
||||
|
||||
import io.anuke.arc.collection.EnumSet;
|
||||
import io.anuke.arc.func.Cons;
|
||||
import io.anuke.arc.func.Boolf;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Geometry;
|
||||
import io.anuke.arc.math.geom.Rectangle;
|
||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import arc.func.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
/** Utility class for unit and team interactions.*/
|
||||
public class Units{
|
||||
private static Rectangle hitrect = new Rectangle();
|
||||
private static Rect hitrect = new Rect();
|
||||
private static Unit result;
|
||||
private static float cdist;
|
||||
private static boolean boolResult;
|
||||
@@ -86,7 +83,7 @@ public class Units{
|
||||
public static TileEntity findEnemyTile(Team team, float x, float y, float range, Boolf<Tile> pred){
|
||||
if(team == Team.derelict) return null;
|
||||
|
||||
for(Team enemy : state.teams.enemiesOf(team)){
|
||||
for(Team enemy : team.enemies()){
|
||||
TileEntity entity = indexer.findTile(enemy, x, y, range, pred, true);
|
||||
if(entity != null){
|
||||
return entity;
|
||||
@@ -157,7 +154,11 @@ public class Units{
|
||||
|
||||
/** Iterates over all units in a rectangle. */
|
||||
public static void nearby(Team team, float x, float y, float width, float height, Cons<Unit> cons){
|
||||
unitGroups[team.ordinal()].intersect(x, y, width, height, cons);
|
||||
unitGroup.intersect(x, y, width, height, u -> {
|
||||
if(u.getTeam() == team){
|
||||
cons.get(u);
|
||||
}
|
||||
});
|
||||
playerGroup.intersect(x, y, width, height, player -> {
|
||||
if(player.getTeam() == team){
|
||||
cons.get(player);
|
||||
@@ -167,8 +168,8 @@ public class Units{
|
||||
|
||||
/** Iterates over all units in a circle around this position. */
|
||||
public static void nearby(Team team, float x, float y, float radius, Cons<Unit> cons){
|
||||
unitGroups[team.ordinal()].intersect(x - radius, y - radius, radius*2f, radius*2f, unit -> {
|
||||
if(unit.withinDst(x, y, radius)){
|
||||
unitGroup.intersect(x - radius, y - radius, radius*2f, radius*2f, unit -> {
|
||||
if(unit.getTeam() == team && unit.withinDst(x, y, radius)){
|
||||
cons.get(unit);
|
||||
}
|
||||
});
|
||||
@@ -182,45 +183,43 @@ public class Units{
|
||||
|
||||
/** Iterates over all units in a rectangle. */
|
||||
public static void nearby(float x, float y, float width, float height, Cons<Unit> cons){
|
||||
for(Team team : Team.all){
|
||||
unitGroups[team.ordinal()].intersect(x, y, width, height, cons);
|
||||
}
|
||||
|
||||
unitGroup.intersect(x, y, width, height, cons);
|
||||
playerGroup.intersect(x, y, width, height, cons);
|
||||
}
|
||||
|
||||
/** Iterates over all units in a rectangle. */
|
||||
public static void nearby(Rectangle rect, Cons<Unit> cons){
|
||||
public static void nearby(Rect rect, Cons<Unit> cons){
|
||||
nearby(rect.x, rect.y, rect.width, rect.height, cons);
|
||||
}
|
||||
|
||||
/** Iterates over all units that are enemies of this team. */
|
||||
public static void nearbyEnemies(Team team, float x, float y, float width, float height, Cons<Unit> cons){
|
||||
EnumSet<Team> targets = state.teams.enemiesOf(team);
|
||||
|
||||
for(Team other : targets){
|
||||
unitGroups[other.ordinal()].intersect(x, y, width, height, cons);
|
||||
}
|
||||
unitGroup.intersect(x, y, width, height, u -> {
|
||||
if(team.isEnemy(u.getTeam())){
|
||||
cons.get(u);
|
||||
}
|
||||
});
|
||||
|
||||
playerGroup.intersect(x, y, width, height, player -> {
|
||||
if(targets.contains(player.getTeam())){
|
||||
if(team.isEnemy(player.getTeam())){
|
||||
cons.get(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Iterates over all units that are enemies of this team. */
|
||||
public static void nearbyEnemies(Team team, Rectangle rect, Cons<Unit> cons){
|
||||
public static void nearbyEnemies(Team team, Rect rect, Cons<Unit> cons){
|
||||
nearbyEnemies(team, rect.x, rect.y, rect.width, rect.height, cons);
|
||||
}
|
||||
|
||||
/** Iterates over all units. */
|
||||
public static void all(Cons<Unit> cons){
|
||||
for(Team team : Team.all){
|
||||
unitGroups[team.ordinal()].all().each(cons);
|
||||
}
|
||||
|
||||
unitGroup.all().each(cons);
|
||||
playerGroup.all().each(cons);
|
||||
}
|
||||
|
||||
public static void each(Team team, Cons<BaseUnit> cons){
|
||||
unitGroup.all().each(t -> t.getTeam() == team, cons);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.Effects.*;
|
||||
import io.anuke.mindustry.entities.type.Bullet;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.Effects.*;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.gen.*;
|
||||
|
||||
//TODO scale velocity depending on fslope()
|
||||
public class ArtilleryBulletType extends BasicBulletType{
|
||||
@@ -25,7 +25,7 @@ public class ArtilleryBulletType extends BasicBulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(io.anuke.mindustry.entities.type.Bullet b){
|
||||
public void update(Bullet b){
|
||||
super.update(b);
|
||||
|
||||
if(b.timer.get(0, 3 + b.fslope() * 2f)){
|
||||
@@ -1,11 +1,11 @@
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.entities.type.Bullet;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import arc.Core;
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.TextureRegion;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.graphics.Pal;
|
||||
|
||||
/** An extended BulletType for most ammo-based bullets shot from turrets and units. */
|
||||
public class BasicBulletType extends BulletType{
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class BombBulletType extends BasicBulletType{
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import io.anuke.arc.audio.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.ctype.Content;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.Effects.*;
|
||||
import io.anuke.mindustry.entities.effect.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import arc.audio.*;
|
||||
import arc.math.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.ctype.Content;
|
||||
import mindustry.ctype.ContentType;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.Effects.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public abstract class BulletType extends Content{
|
||||
public float lifetime;
|
||||
@@ -137,7 +138,7 @@ public abstract class BulletType extends Content{
|
||||
}
|
||||
|
||||
for(int i = 0; i < lightining; i++){
|
||||
Lightning.create(b.getTeam(), Pal.surge, damage, b.x, b.y, Mathf.random(360f), lightningLength);
|
||||
Lightning.createLighting(Lightning.nextSeed(), b.getTeam(), Pal.surge, damage, b.x, b.y, Mathf.random(360f), lightningLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +151,7 @@ public abstract class BulletType extends Content{
|
||||
public void update(Bullet b){
|
||||
|
||||
if(homingPower > 0.0001f){
|
||||
TargetTrait target = Units.closestTarget(b.getTeam(), b.x, b.y, homingRange);
|
||||
TargetTrait target = Units.closestTarget(b.getTeam(), b.x, b.y, homingRange, e -> !e.isFlying() || collidesAir);
|
||||
if(target != null){
|
||||
b.velocity().setAngle(Mathf.slerpDelta(b.velocity().angle(), b.angleTo(target), 0.08f));
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import io.anuke.arc.math.geom.Rectangle;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.type.Bullet;
|
||||
import arc.math.geom.Rect;
|
||||
import arc.util.Time;
|
||||
import mindustry.content.Fx;
|
||||
import mindustry.entities.Units;
|
||||
import mindustry.entities.type.Bullet;
|
||||
|
||||
public class FlakBulletType extends BasicBulletType{
|
||||
protected static Rectangle rect = new Rectangle();
|
||||
protected static Rect rect = new Rect();
|
||||
protected float explodeRange = 30f;
|
||||
|
||||
public FlakBulletType(float speed, float damage){
|
||||
@@ -1,13 +1,13 @@
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
|
||||
public class HealBulletType extends BulletType{
|
||||
protected float healPercent = 3f;
|
||||
@@ -1,13 +1,13 @@
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
public class LaserBulletType extends BulletType{
|
||||
protected Color[] colors = {Pal.lancerLaser.cpy().mul(1f, 1f, 1f, 0.4f), Pal.lancerLaser, Color.white};
|
||||
@@ -1,10 +1,10 @@
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.effect.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
import arc.graphics.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
public class LightningBulletType extends BulletType{
|
||||
protected Color lightningColor = Pal.lancerLaser;
|
||||
@@ -1,20 +1,21 @@
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.ArcAnnotate.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.effect.*;
|
||||
import io.anuke.mindustry.entities.type.Bullet;
|
||||
import io.anuke.mindustry.type.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.ArcAnnotate.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class LiquidBulletType extends BulletType{
|
||||
@NonNull Liquid liquid;
|
||||
public @NonNull Liquid liquid;
|
||||
public float puddleSize = 5f;
|
||||
|
||||
public LiquidBulletType(@Nullable Liquid liquid){
|
||||
super(3.5f, 0);
|
||||
@@ -67,7 +68,7 @@ public class LiquidBulletType extends BulletType{
|
||||
@Override
|
||||
public void hit(Bullet b, float hitx, float hity){
|
||||
Effects.effect(hitEffect, liquid.color, hitx, hity);
|
||||
Puddle.deposit(world.tileWorld(hitx, hity), liquid, 5f);
|
||||
Puddle.deposit(world.tileWorld(hitx, hity), liquid, puddleSize);
|
||||
|
||||
if(liquid.temperature <= 0.5f && liquid.flammability < 0.3f){
|
||||
float intensity = 400f;
|
||||
@@ -1,16 +1,16 @@
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.type.Bullet;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.world.blocks.distribution.MassDriver.DriverBulletData;
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.math.Angles;
|
||||
import arc.math.Mathf;
|
||||
import mindustry.content.Fx;
|
||||
import mindustry.entities.Effects;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.world.blocks.distribution.MassDriver.DriverBulletData;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static mindustry.Vars.content;
|
||||
|
||||
public class MassDriverBolt extends BulletType{
|
||||
|
||||
@@ -24,7 +24,7 @@ public class MassDriverBolt extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(io.anuke.mindustry.entities.type.Bullet b){
|
||||
public void draw(mindustry.entities.type.Bullet b){
|
||||
float w = 11f, h = 13f;
|
||||
|
||||
Draw.color(Pal.bulletYellowBack);
|
||||
@@ -37,7 +37,7 @@ public class MassDriverBolt extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(io.anuke.mindustry.entities.type.Bullet b){
|
||||
public void update(mindustry.entities.type.Bullet b){
|
||||
//data MUST be an instance of DriverBulletData
|
||||
if(!(b.getData() instanceof DriverBulletData)){
|
||||
hit(b);
|
||||
@@ -83,7 +83,7 @@ public class MassDriverBolt extends BulletType{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void despawned(io.anuke.mindustry.entities.type.Bullet b){
|
||||
public void despawned(mindustry.entities.type.Bullet b){
|
||||
super.despawned(b);
|
||||
|
||||
if(!(b.getData() instanceof DriverBulletData)) return;
|
||||
@@ -1,13 +1,13 @@
|
||||
package io.anuke.mindustry.entities.bullet;
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.content.Fx;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.type.Bullet;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import arc.graphics.Color;
|
||||
import arc.math.Mathf;
|
||||
import arc.util.Time;
|
||||
import mindustry.content.Fx;
|
||||
import mindustry.entities.Effects;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.Pal;
|
||||
|
||||
public class MissileBulletType extends BasicBulletType{
|
||||
protected Color trailColor = Pal.missileYellowBack;
|
||||
@@ -1,14 +1,14 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
package mindustry.entities.effect;
|
||||
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.mindustry.entities.EntityGroup;
|
||||
import io.anuke.mindustry.entities.type.TimedEntity;
|
||||
import io.anuke.mindustry.entities.traits.BelowLiquidTrait;
|
||||
import io.anuke.mindustry.entities.traits.DrawTrait;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.math.Mathf;
|
||||
import mindustry.entities.EntityGroup;
|
||||
import mindustry.entities.type.TimedEntity;
|
||||
import mindustry.entities.traits.BelowLiquidTrait;
|
||||
import mindustry.entities.traits.DrawTrait;
|
||||
import mindustry.graphics.Pal;
|
||||
|
||||
import static io.anuke.mindustry.Vars.groundEffectGroup;
|
||||
import static mindustry.Vars.groundEffectGroup;
|
||||
|
||||
/**
|
||||
* Class for creating block rubble on the ground.
|
||||
@@ -1,24 +1,24 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
package mindustry.entities.effect;
|
||||
|
||||
import io.anuke.annotations.Annotations.*;
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.entities.type.TimedEntity;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.type.TypeID;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import arc.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import arc.struct.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Fire extends TimedEntity implements SaveTrait, SyncTrait{
|
||||
private static final IntMap<Fire> map = new IntMap<>();
|
||||
@@ -144,7 +144,7 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait{
|
||||
create(other);
|
||||
|
||||
if(Mathf.chance(fireballChance * Time.delta() * Mathf.clamp(flammability / 10f))){
|
||||
Call.createBullet(Bullets.fireball, x, y, Mathf.random(360f));
|
||||
Call.createBullet(Bullets.fireball, Team.derelict, x, y, Mathf.random(360f), 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
package mindustry.entities.effect;
|
||||
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.Effects.Effect;
|
||||
import io.anuke.mindustry.entities.Effects.EffectRenderer;
|
||||
import io.anuke.mindustry.entities.type.EffectEntity;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import arc.math.Mathf;
|
||||
import arc.util.Time;
|
||||
import mindustry.Vars;
|
||||
import mindustry.entities.Effects;
|
||||
import mindustry.entities.Effects.Effect;
|
||||
import mindustry.entities.Effects.EffectRenderer;
|
||||
import mindustry.entities.type.EffectEntity;
|
||||
import mindustry.world.Tile;
|
||||
|
||||
/**
|
||||
* A ground effect contains an effect that is rendered on the ground layer as opposed to the top layer.
|
||||
@@ -1,28 +1,28 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
package mindustry.entities.effect;
|
||||
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.Interpolation;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Position;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.pooling.Pools;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.type.TimedEntity;
|
||||
import io.anuke.mindustry.entities.traits.DrawTrait;
|
||||
import io.anuke.mindustry.entities.type.Unit;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import mindustry.annotations.Annotations.Loc;
|
||||
import mindustry.annotations.Annotations.Remote;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.Interpolation;
|
||||
import arc.math.Mathf;
|
||||
import arc.math.geom.Position;
|
||||
import arc.math.geom.Vec2;
|
||||
import arc.util.Time;
|
||||
import arc.util.pooling.Pools;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.type.TimedEntity;
|
||||
import mindustry.entities.traits.DrawTrait;
|
||||
import mindustry.entities.type.Unit;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.type.Item;
|
||||
import mindustry.world.Tile;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class ItemTransfer extends TimedEntity implements DrawTrait{
|
||||
private Vector2 from = new Vector2();
|
||||
private Vector2 current = new Vector2();
|
||||
private Vector2 tovec = new Vector2();
|
||||
private Vec2 from = new Vec2();
|
||||
private Vec2 current = new Vec2();
|
||||
private Vec2 tovec = new Vec2();
|
||||
private Item item;
|
||||
private float seed;
|
||||
private Position to;
|
||||
@@ -1,41 +1,41 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
package mindustry.entities.effect;
|
||||
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.collection.IntSet;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.pooling.Pools;
|
||||
import io.anuke.mindustry.content.Bullets;
|
||||
import io.anuke.mindustry.entities.EntityGroup;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.type.Bullet;
|
||||
import io.anuke.mindustry.entities.type.TimedEntity;
|
||||
import io.anuke.mindustry.entities.traits.DrawTrait;
|
||||
import io.anuke.mindustry.entities.traits.TimeTrait;
|
||||
import io.anuke.mindustry.entities.type.Unit;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.graphics.Pal;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import mindustry.annotations.Annotations.Loc;
|
||||
import mindustry.annotations.Annotations.Remote;
|
||||
import arc.struct.Array;
|
||||
import arc.struct.IntSet;
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.pooling.Pools;
|
||||
import mindustry.content.Bullets;
|
||||
import mindustry.entities.EntityGroup;
|
||||
import mindustry.entities.Units;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.entities.type.TimedEntity;
|
||||
import mindustry.entities.traits.DrawTrait;
|
||||
import mindustry.entities.traits.TimeTrait;
|
||||
import mindustry.entities.type.Unit;
|
||||
import mindustry.game.Team;
|
||||
import mindustry.gen.Call;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.world.Tile;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{
|
||||
public static final float lifetime = 10f;
|
||||
|
||||
private static final RandomXS128 random = new RandomXS128();
|
||||
private static final Rectangle rect = new Rectangle();
|
||||
private static final Rect rect = new Rect();
|
||||
private static final Array<Unit> entities = new Array<>();
|
||||
private static final IntSet hit = new IntSet();
|
||||
private static final int maxChain = 8;
|
||||
private static final float hitRange = 30f;
|
||||
private static int lastSeed = 0;
|
||||
|
||||
private Array<Vector2> lines = new Array<>();
|
||||
private Array<Vec2> lines = new Array<>();
|
||||
private Color color = Pal.lancerLaser;
|
||||
|
||||
/** For pooling use only. Do not call directly! */
|
||||
@@ -44,7 +44,11 @@ public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{
|
||||
|
||||
/** Create a lighting branch at a location. Use Team.none to damage everyone. */
|
||||
public static void create(Team team, Color color, float damage, float x, float y, float targetAngle, int length){
|
||||
Call.createLighting(lastSeed++, team, color, damage, x, y, targetAngle, length);
|
||||
Call.createLighting(nextSeed(), team, color, damage, x, y, targetAngle, length);
|
||||
}
|
||||
|
||||
public static int nextSeed(){
|
||||
return lastSeed++;
|
||||
}
|
||||
|
||||
/** Do not invoke! */
|
||||
@@ -66,7 +70,7 @@ public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{
|
||||
|
||||
for(int i = 0; i < length / 2; i++){
|
||||
Bullet.create(Bullets.damageLightning, l, team, x, y, 0f, 1f, 1f, dmg);
|
||||
l.lines.add(new Vector2(x + Mathf.range(3f), y + Mathf.range(3f)));
|
||||
l.lines.add(new Vec2(x + Mathf.range(3f), y + Mathf.range(3f)));
|
||||
|
||||
if(l.lines.size > 1){
|
||||
bhit[0] = false;
|
||||
@@ -1,37 +1,34 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
package mindustry.entities.effect;
|
||||
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.arc.collection.IntMap;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Fill;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.pooling.Pool.Poolable;
|
||||
import io.anuke.arc.util.pooling.Pools;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.type.SolidEntity;
|
||||
import io.anuke.mindustry.entities.traits.*;
|
||||
import io.anuke.mindustry.type.TypeID;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import arc.struct.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import arc.util.pooling.Pool.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrait, SyncTrait{
|
||||
private static final IntMap<Puddle> map = new IntMap<>();
|
||||
private static final float maxLiquid = 70f;
|
||||
private static final int maxGeneration = 2;
|
||||
private static final Color tmp = new Color();
|
||||
private static final Rectangle rect = new Rectangle();
|
||||
private static final Rectangle rect2 = new Rectangle();
|
||||
private static final Rect rect = new Rect();
|
||||
private static final Rect rect2 = new Rect();
|
||||
private static int seeds;
|
||||
|
||||
private int loadedPosition = -1;
|
||||
@@ -118,7 +115,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
||||
(liquid.flammability > 0.3f && dest.temperature > 0.7f)){ //flammable liquid + hot liquid
|
||||
Fire.create(tile);
|
||||
if(Mathf.chance(0.006 * amount)){
|
||||
Call.createBullet(Bullets.fireball, x, y, Mathf.random(360f));
|
||||
Call.createBullet(Bullets.fireball, Team.derelict, x, y, Mathf.random(360f), 1f, 1f);
|
||||
}
|
||||
}else if(dest.temperature > 0.7f && liquid.temperature < 0.55f){ //cold liquid poured onto hot puddle
|
||||
if(Mathf.chance(0.5f * amount)){
|
||||
@@ -154,13 +151,13 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitbox(Rectangle rectangle){
|
||||
rectangle.setCenter(x, y).setSize(tilesize);
|
||||
public void hitbox(Rect rect){
|
||||
rect.setCenter(x, y).setSize(tilesize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hitboxTile(Rectangle rectangle){
|
||||
rectangle.setCenter(x, y).setSize(0f);
|
||||
public void hitboxTile(Rect rect){
|
||||
rect.setCenter(x, y).setSize(0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,11 +1,11 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
package mindustry.entities.effect;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import arc.Core;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.TextureRegion;
|
||||
import arc.math.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.headless;
|
||||
import static mindustry.Vars.headless;
|
||||
|
||||
public class RubbleDecal extends Decal{
|
||||
private TextureRegion region;
|
||||
@@ -1,14 +1,14 @@
|
||||
package io.anuke.mindustry.entities.effect;
|
||||
package mindustry.entities.effect;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import arc.Core;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.TextureRegion;
|
||||
import arc.math.Angles;
|
||||
import arc.math.Mathf;
|
||||
import mindustry.world.Tile;
|
||||
|
||||
import static io.anuke.mindustry.Vars.headless;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static mindustry.Vars.headless;
|
||||
import static mindustry.Vars.world;
|
||||
|
||||
public class ScorchDecal extends Decal{
|
||||
private static final int scorches = 5;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user