This commit is contained in:
Anuken
2019-10-22 18:55:15 -04:00
parent ae4ec55abe
commit b98b9a98e3
12 changed files with 89 additions and 79 deletions
@@ -5,7 +5,7 @@ import io.anuke.arc.function.*;
import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
import io.anuke.mindustry.content.*; import io.anuke.mindustry.content.*;
import io.anuke.mindustry.ctype.MappableContent; import io.anuke.mindustry.ctype.*;
import io.anuke.mindustry.entities.bullet.*; import io.anuke.mindustry.entities.bullet.*;
import io.anuke.mindustry.type.*; import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.*;
@@ -20,11 +20,11 @@ import static io.anuke.mindustry.Vars.mods;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class ContentLoader{ public class ContentLoader{
private boolean loaded = false; private boolean loaded = false;
private ObjectMap<String, io.anuke.mindustry.ctype.MappableContent>[] contentNameMap = new ObjectMap[ContentType.values().length]; private ObjectMap<String, MappableContent>[] contentNameMap = new ObjectMap[ContentType.values().length];
private Array<io.anuke.mindustry.ctype.Content>[] contentMap = new Array[ContentType.values().length]; private Array<Content>[] contentMap = new Array[ContentType.values().length];
private io.anuke.mindustry.ctype.MappableContent[][] temporaryMapper; private MappableContent[][] temporaryMapper;
private ObjectSet<Consumer<io.anuke.mindustry.ctype.Content>> initialization = new ObjectSet<>(); private ObjectSet<Consumer<Content>> initialization = new ObjectSet<>();
private io.anuke.mindustry.ctype.ContentList[] content = { private ContentList[] content = {
new Fx(), new Fx(),
new Items(), new Items(),
new StatusEffects(), new StatusEffects(),
@@ -62,7 +62,7 @@ public class ContentLoader{
contentNameMap[type.ordinal()] = new ObjectMap<>(); contentNameMap[type.ordinal()] = new ObjectMap<>();
} }
for(io.anuke.mindustry.ctype.ContentList list : content){ for(ContentList list : content){
list.load(); list.load();
} }
@@ -71,7 +71,7 @@ public class ContentLoader{
} }
//check up ID mapping, make sure it's linear //check up ID mapping, make sure it's linear
for(Array<io.anuke.mindustry.ctype.Content> arr : contentMap){ for(Array<Content> arr : contentMap){
for(int i = 0; i < arr.size; i++){ for(int i = 0; i < arr.size; i++){
int id = arr.get(i).id; int id = arr.get(i).id;
if(id != i){ if(id != i){
@@ -95,20 +95,20 @@ public class ContentLoader{
/** Calls Content#init() on everything. Use only after all modules have been created.*/ /** Calls Content#init() on everything. Use only after all modules have been created.*/
public void init(){ public void init(){
initialize(io.anuke.mindustry.ctype.Content::init); initialize(Content::init);
} }
/** Calls Content#load() on everything. Use only after all modules have been created on the client.*/ /** Calls Content#load() on everything. Use only after all modules have been created on the client.*/
public void load(){ public void load(){
initialize(io.anuke.mindustry.ctype.Content::load); initialize(Content::load);
} }
/** Initializes all content with the specified function. */ /** Initializes all content with the specified function. */
private void initialize(Consumer<io.anuke.mindustry.ctype.Content> callable){ private void initialize(Consumer<Content> callable){
if(initialization.contains(callable)) return; if(initialization.contains(callable)) return;
for(ContentType type : ContentType.values()){ for(ContentType type : ContentType.values()){
for(io.anuke.mindustry.ctype.Content content : contentMap[type.ordinal()]){ for(Content content : contentMap[type.ordinal()]){
try{ try{
callable.accept(content); callable.accept(content);
}catch(Throwable e){ }catch(Throwable e){
@@ -144,23 +144,23 @@ public class ContentLoader{
//clear all content, currently not used //clear all content, currently not used
} }
public void handleContent(io.anuke.mindustry.ctype.Content content){ public void handleContent(Content content){
contentMap[content.getContentType().ordinal()].add(content); contentMap[content.getContentType().ordinal()].add(content);
} }
public void handleMappableContent(io.anuke.mindustry.ctype.MappableContent content){ public void handleMappableContent(MappableContent content){
if(contentNameMap[content.getContentType().ordinal()].containsKey(content.name)){ if(contentNameMap[content.getContentType().ordinal()].containsKey(content.name)){
throw new IllegalArgumentException("Two content objects cannot have the same name! (issue: '" + content.name + "')"); throw new IllegalArgumentException("Two content objects cannot have the same name! (issue: '" + content.name + "')");
} }
contentNameMap[content.getContentType().ordinal()].put(content.name, content); contentNameMap[content.getContentType().ordinal()].put(content.name, content);
} }
public void setTemporaryMapper(io.anuke.mindustry.ctype.MappableContent[][] temporaryMapper){ public void setTemporaryMapper(MappableContent[][] temporaryMapper){
this.temporaryMapper = temporaryMapper; this.temporaryMapper = temporaryMapper;
} }
public Array<io.anuke.mindustry.ctype.Content>[] getContentMap(){ public Array<Content>[] getContentMap(){
return contentMap; return contentMap;
} }
@@ -171,7 +171,7 @@ public class ContentLoader{
return (T)contentNameMap[type.ordinal()].get(name); return (T)contentNameMap[type.ordinal()].get(name);
} }
public <T extends io.anuke.mindustry.ctype.Content> T getByID(ContentType type, int id){ public <T extends Content> T getByID(ContentType type, int id){
if(temporaryMapper != null && temporaryMapper[type.ordinal()] != null && temporaryMapper[type.ordinal()].length != 0){ if(temporaryMapper != null && temporaryMapper[type.ordinal()] != null && temporaryMapper[type.ordinal()].length != 0){
//-1 = invalid content //-1 = invalid content
@@ -190,7 +190,7 @@ public class ContentLoader{
return (T)contentMap[type.ordinal()].get(id); return (T)contentMap[type.ordinal()].get(id);
} }
public <T extends io.anuke.mindustry.ctype.Content> Array<T> getBy(ContentType type){ public <T extends Content> Array<T> getBy(ContentType type){
return (Array<T>)contentMap[type.ordinal()]; return (Array<T>)contentMap[type.ordinal()];
} }
@@ -174,15 +174,15 @@ public class EventType{
} }
public static class UnlockEvent{ public static class UnlockEvent{
public final io.anuke.mindustry.ctype.UnlockableContent content; public final UnlockableContent content;
public UnlockEvent(io.anuke.mindustry.ctype.UnlockableContent content){ public UnlockEvent(UnlockableContent content){
this.content = content; this.content = content;
} }
} }
public static class ResearchEvent{ public static class ResearchEvent{
public final io.anuke.mindustry.ctype.UnlockableContent content; public final UnlockableContent content;
public ResearchEvent(UnlockableContent content){ public ResearchEvent(UnlockableContent content){
this.content = content; this.content = content;
@@ -132,7 +132,7 @@ public class GlobalData{
} }
/** Returns whether or not this piece of content is unlocked yet. */ /** Returns whether or not this piece of content is unlocked yet. */
public boolean isUnlocked(io.anuke.mindustry.ctype.UnlockableContent content){ public boolean isUnlocked(UnlockableContent content){
return content.alwaysUnlocked() || unlocked.getOr(content.getContentType(), ObjectSet::new).contains(content.name); return content.alwaysUnlocked() || unlocked.getOr(content.getContentType(), ObjectSet::new).contains(content.name);
} }
+10 -11
View File
@@ -3,15 +3,14 @@ package io.anuke.mindustry.io;
import io.anuke.arc.collection.*; import io.anuke.arc.collection.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
import io.anuke.arc.util.io.*; import io.anuke.arc.util.io.*;
import io.anuke.mindustry.core.Version; import io.anuke.mindustry.core.*;
import io.anuke.mindustry.ctype.MappableContent; import io.anuke.mindustry.ctype.*;
import io.anuke.mindustry.entities.*; import io.anuke.mindustry.entities.*;
import io.anuke.mindustry.entities.traits.*; import io.anuke.mindustry.entities.traits.*;
import io.anuke.mindustry.game.*; import io.anuke.mindustry.game.*;
import io.anuke.mindustry.game.Teams.*; import io.anuke.mindustry.game.Teams.*;
import io.anuke.mindustry.maps.*; import io.anuke.mindustry.maps.*;
import io.anuke.mindustry.type.*; import io.anuke.mindustry.type.*;
import io.anuke.mindustry.type.TypeID;
import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.*;
import java.io.*; import java.io.*;
@@ -283,12 +282,12 @@ public abstract class SaveVersion extends SaveFileReader{
public void readContentHeader(DataInput stream) throws IOException{ public void readContentHeader(DataInput stream) throws IOException{
byte mapped = stream.readByte(); byte mapped = stream.readByte();
io.anuke.mindustry.ctype.MappableContent[][] map = new io.anuke.mindustry.ctype.MappableContent[ContentType.values().length][0]; MappableContent[][] map = new MappableContent[ContentType.values().length][0];
for(int i = 0; i < mapped; i++){ for(int i = 0; i < mapped; i++){
ContentType type = ContentType.values()[stream.readByte()]; ContentType type = ContentType.values()[stream.readByte()];
short total = stream.readShort(); short total = stream.readShort();
map[type.ordinal()] = new io.anuke.mindustry.ctype.MappableContent[total]; map[type.ordinal()] = new MappableContent[total];
for(int j = 0; j < total; j++){ for(int j = 0; j < total; j++){
String name = stream.readUTF(); String name = stream.readUTF();
@@ -300,21 +299,21 @@ public abstract class SaveVersion extends SaveFileReader{
} }
public void writeContentHeader(DataOutput stream) throws IOException{ public void writeContentHeader(DataOutput stream) throws IOException{
Array<io.anuke.mindustry.ctype.Content>[] map = content.getContentMap(); Array<Content>[] map = content.getContentMap();
int mappable = 0; int mappable = 0;
for(Array<io.anuke.mindustry.ctype.Content> arr : map){ for(Array<Content> arr : map){
if(arr.size > 0 && arr.first() instanceof io.anuke.mindustry.ctype.MappableContent){ if(arr.size > 0 && arr.first() instanceof MappableContent){
mappable++; mappable++;
} }
} }
stream.writeByte(mappable); stream.writeByte(mappable);
for(Array<io.anuke.mindustry.ctype.Content> arr : map){ for(Array<Content> arr : map){
if(arr.size > 0 && arr.first() instanceof io.anuke.mindustry.ctype.MappableContent){ if(arr.size > 0 && arr.first() instanceof MappableContent){
stream.writeByte(arr.first().getContentType().ordinal()); stream.writeByte(arr.first().getContentType().ordinal());
stream.writeShort(arr.size); stream.writeShort(arr.size);
for(io.anuke.mindustry.ctype.Content c : arr){ for(Content c : arr){
stream.writeUTF(((MappableContent)c).name); stream.writeUTF(((MappableContent)c).name);
} }
} }
@@ -39,6 +39,9 @@ public class MapGenerator extends Generator{
this.decorations.addAll(decor); this.decorations.addAll(decor);
return this; return this;
} }
public void removePrefix(String name){
this.mapName = name.substring(name.length() + 1);
}
{ {
decor(new Decoration(Blocks.snow, Blocks.snowrock, 0.01), new Decoration(Blocks.ignarock, Blocks.pebbles, 0.03f)); decor(new Decoration(Blocks.snow, Blocks.snowrock, 0.01), new Decoration(Blocks.ignarock, Blocks.pebbles, 0.03f));
@@ -16,7 +16,7 @@ import io.anuke.arc.util.serialization.Json.*;
import io.anuke.mindustry.*; import io.anuke.mindustry.*;
import io.anuke.mindustry.content.*; import io.anuke.mindustry.content.*;
import io.anuke.mindustry.content.TechTree.*; import io.anuke.mindustry.content.TechTree.*;
import io.anuke.mindustry.ctype.UnlockableContent; import io.anuke.mindustry.ctype.*;
import io.anuke.mindustry.entities.Effects.*; import io.anuke.mindustry.entities.Effects.*;
import io.anuke.mindustry.entities.bullet.*; import io.anuke.mindustry.entities.bullet.*;
import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.entities.type.*;
@@ -54,7 +54,7 @@ public class ContentParser{
if(fieldOpt(Sounds.class, data) != null) return fieldOpt(Sounds.class, data); if(fieldOpt(Sounds.class, data) != null) return fieldOpt(Sounds.class, data);
String path = "sounds/" + data.asString() + (Vars.ios ? ".mp3" : ".ogg"); String path = "sounds/" + data.asString() + (Vars.ios ? ".mp3" : ".ogg");
ProxySound sound = new ProxySound(); ModLoadingSound sound = new ModLoadingSound();
Core.assets.load(path, Sound.class).loaded = result -> { Core.assets.load(path, Sound.class).loaded = result -> {
sound.sound = (Sound)result; sound.sound = (Sound)result;
}; };
@@ -67,13 +67,19 @@ public class ContentParser{
readFields(obj, data); readFields(obj, data);
return obj; return obj;
}); });
put(Weapon.class, (type, data) -> {
Weapon weapon = new Weapon();
readFields(weapon, data);
weapon.name = currentMod.name + "-" + weapon.name;
return weapon;
});
}}; }};
/** Stores things that need to be parsed fully, e.g. reading fields of content. /** Stores things that need to be parsed fully, e.g. reading fields of content.
* This is done to accomodate binding of content names first.*/ * This is done to accomodate binding of content names first.*/
private Array<Runnable> reads = new Array<>(); private Array<Runnable> reads = new Array<>();
private Array<Runnable> postreads = new Array<>(); private Array<Runnable> postreads = new Array<>();
private LoadedMod currentMod; private LoadedMod currentMod;
private io.anuke.mindustry.ctype.Content currentContent; private Content currentContent;
private Json parser = new Json(){ private Json parser = new Json(){
@Override @Override
@@ -93,7 +99,7 @@ public class ContentParser{
} }
} }
if(io.anuke.mindustry.ctype.Content.class.isAssignableFrom(type)){ if(Content.class.isAssignableFrom(type)){
ContentType ctype = contentTypes.getThrow(type, () -> new IllegalArgumentException("No content type for class: " + type.getSimpleName())); ContentType ctype = contentTypes.getThrow(type, () -> new IllegalArgumentException("No content type for class: " + type.getSimpleName()));
String prefix = currentMod != null ? currentMod.name + "-" : ""; String prefix = currentMod != null ? currentMod.name + "-" : "";
T one = (T)Vars.content.getByName(ctype, prefix + jsonData.asString()); T one = (T)Vars.content.getByName(ctype, prefix + jsonData.asString());
@@ -213,14 +219,14 @@ public class ContentParser{
ContentType.zone, parser(ContentType.zone, Zone::new) ContentType.zone, parser(ContentType.zone, Zone::new)
); );
private <T extends io.anuke.mindustry.ctype.Content> T find(ContentType type, String name){ private <T extends Content> T find(ContentType type, String name){
io.anuke.mindustry.ctype.Content c = Vars.content.getByName(type, name); Content c = Vars.content.getByName(type, name);
if(c == null) c = Vars.content.getByName(type, currentMod.name + "-" + name); if(c == null) c = Vars.content.getByName(type, currentMod.name + "-" + name);
if(c == null) throw new IllegalArgumentException("No " + type + " found with name '" + name + "'"); if(c == null) throw new IllegalArgumentException("No " + type + " found with name '" + name + "'");
return (T)c; return (T)c;
} }
private <T extends io.anuke.mindustry.ctype.Content> TypeParser<T> parser(ContentType type, Function<String, T> constructor){ private <T extends Content> TypeParser<T> parser(ContentType type, Function<String, T> constructor){
return (mod, name, value) -> { return (mod, name, value) -> {
T item; T item;
if(Vars.content.getByName(type, name) != null){ if(Vars.content.getByName(type, name) != null){
@@ -237,7 +243,7 @@ public class ContentParser{
} }
private void readBundle(ContentType type, String name, JsonValue value){ private void readBundle(ContentType type, String name, JsonValue value){
io.anuke.mindustry.ctype.UnlockableContent cont = Vars.content.getByName(type, name) instanceof io.anuke.mindustry.ctype.UnlockableContent ? UnlockableContent cont = Vars.content.getByName(type, name) instanceof UnlockableContent ?
Vars.content.getByName(type, name) : null; Vars.content.getByName(type, name) : null;
String entryName = cont == null ? type + "." + currentMod.name + "-" + name + "." : type + "." + cont.name + "."; String entryName = cont == null ? type + "." + currentMod.name + "-" + name + "." : type + "." + cont.name + ".";
@@ -259,7 +265,7 @@ public class ContentParser{
/** Call to read a content's extra info later.*/ /** Call to read a content's extra info later.*/
private void read(Runnable run){ private void read(Runnable run){
io.anuke.mindustry.ctype.Content cont = currentContent; Content cont = currentContent;
LoadedMod mod = currentMod; LoadedMod mod = currentMod;
reads.add(() -> { reads.add(() -> {
this.currentMod = mod; this.currentMod = mod;
@@ -270,11 +276,11 @@ public class ContentParser{
private void init(){ private void init(){
for(ContentType type : ContentType.all){ for(ContentType type : ContentType.all){
Array<io.anuke.mindustry.ctype.Content> arr = Vars.content.getBy(type); Array<Content> arr = Vars.content.getBy(type);
if(!arr.isEmpty()){ if(!arr.isEmpty()){
Class<?> c = arr.first().getClass(); Class<?> c = arr.first().getClass();
//get base content class, skipping intermediates //get base content class, skipping intermediates
while(!(c.getSuperclass() == io.anuke.mindustry.ctype.Content.class || c.getSuperclass() == UnlockableContent.class || Modifier.isAbstract(c.getSuperclass().getModifiers()))){ while(!(c.getSuperclass() == Content.class || c.getSuperclass() == UnlockableContent.class || Modifier.isAbstract(c.getSuperclass().getModifiers()))){
c = c.getSuperclass(); c = c.getSuperclass();
} }
@@ -302,7 +308,7 @@ public class ContentParser{
* @param file file that this content is being parsed from * @param file file that this content is being parsed from
* @return the content that was parsed * @return the content that was parsed
*/ */
public io.anuke.mindustry.ctype.Content parse(LoadedMod mod, String name, String json, FileHandle file, ContentType type) throws Exception{ public Content parse(LoadedMod mod, String name, String json, FileHandle file, ContentType type) throws Exception{
if(contentTypes.isEmpty()){ if(contentTypes.isEmpty()){
init(); init();
} }
@@ -314,7 +320,7 @@ public class ContentParser{
currentMod = mod; currentMod = mod;
boolean exists = Vars.content.getByName(type, name) != null; boolean exists = Vars.content.getByName(type, name) != null;
io.anuke.mindustry.ctype.Content c = parsers.get(type).parse(mod.name, name, value); Content c = parsers.get(type).parse(mod.name, name, value);
if(!exists){ if(!exists){
c.sourceFile = file; c.sourceFile = file;
c.mod = mod; c.mod = mod;
@@ -454,7 +460,7 @@ public class ContentParser{
Object parse(Class<?> type, JsonValue value) throws Exception; Object parse(Class<?> type, JsonValue value) throws Exception;
} }
private interface TypeParser<T extends io.anuke.mindustry.ctype.Content>{ private interface TypeParser<T extends Content>{
T parse(String mod, String name, JsonValue value) throws Exception; T parse(String mod, String name, JsonValue value) throws Exception;
} }
@@ -5,7 +5,7 @@ import io.anuke.arc.audio.mock.*;
import io.anuke.arc.math.geom.*; import io.anuke.arc.math.geom.*;
import io.anuke.arc.util.ArcAnnotate.*; import io.anuke.arc.util.ArcAnnotate.*;
public class ProxySound implements Sound{ public class ModLoadingSound implements Sound{
public @NonNull Sound sound = new MockSound(); public @NonNull Sound sound = new MockSound();
@Override @Override
+10 -10
View File
@@ -14,8 +14,8 @@ import io.anuke.arc.util.ArcAnnotate.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
import io.anuke.arc.util.io.*; import io.anuke.arc.util.io.*;
import io.anuke.arc.util.serialization.*; import io.anuke.arc.util.serialization.*;
import io.anuke.mindustry.core.Version; import io.anuke.mindustry.core.*;
import io.anuke.mindustry.ctype.UnlockableContent; import io.anuke.mindustry.ctype.*;
import io.anuke.mindustry.game.EventType.*; import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.gen.*; import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.plugin.*; import io.anuke.mindustry.plugin.*;
@@ -130,10 +130,10 @@ public class Mods implements Loadable{
packer.updateTextureAtlas(Core.atlas, filter, filter, false); packer.updateTextureAtlas(Core.atlas, filter, filter, false);
//generate new icons //generate new icons
for(Array<io.anuke.mindustry.ctype.Content> arr : content.getContentMap()){ for(Array<Content> arr : content.getContentMap()){
arr.each(c -> { arr.each(c -> {
if(c instanceof io.anuke.mindustry.ctype.UnlockableContent && c.mod != null){ if(c instanceof UnlockableContent && c.mod != null){
io.anuke.mindustry.ctype.UnlockableContent u = (io.anuke.mindustry.ctype.UnlockableContent)c; UnlockableContent u = (UnlockableContent)c;
u.createIcons(packer, editorPacker); u.createIcons(packer, editorPacker);
} }
}); });
@@ -285,9 +285,9 @@ public class Mods implements Loadable{
if(file.extension().equals("json")){ if(file.extension().equals("json")){
try{ try{
//this binds the content but does not load it entirely //this binds the content but does not load it entirely
io.anuke.mindustry.ctype.Content loaded = parser.parse(mod, file.nameWithoutExtension(), file.readString("UTF-8"), file, type); Content loaded = parser.parse(mod, file.nameWithoutExtension(), file.readString("UTF-8"), file, type);
Log.info("[{0}] Loaded '{1}'.", mod.meta.name, Log.info("[{0}] Loaded '{1}'.", mod.meta.name,
(loaded instanceof io.anuke.mindustry.ctype.UnlockableContent ? ((UnlockableContent)loaded).localizedName : loaded)); (loaded instanceof UnlockableContent ? ((UnlockableContent)loaded).localizedName : loaded));
}catch(Exception e){ }catch(Exception e){
throw new RuntimeException("Failed to parse content file '" + file + "' for mod '" + mod.meta.name + "'.", e); throw new RuntimeException("Failed to parse content file '" + file + "' for mod '" + mod.meta.name + "'.", e);
} }
@@ -362,7 +362,7 @@ public class Mods implements Loadable{
public void handleError(Throwable t, LoadedMod mod){ public void handleError(Throwable t, LoadedMod mod){
Array<Throwable> causes = Strings.getCauses(t); Array<Throwable> causes = Strings.getCauses(t);
io.anuke.mindustry.ctype.Content content = null; Content content = null;
for(Throwable e : causes){ for(Throwable e : causes){
if(e instanceof ModLoadException && ((ModLoadException) e).content != null){ if(e instanceof ModLoadException && ((ModLoadException) e).content != null){
content = ((ModLoadException) e).content; content = ((ModLoadException) e).content;
@@ -553,14 +553,14 @@ public class Mods implements Loadable{
/** Thrown when an error occurs while loading a mod.*/ /** Thrown when an error occurs while loading a mod.*/
public static class ModLoadException extends RuntimeException{ public static class ModLoadException extends RuntimeException{
public io.anuke.mindustry.ctype.Content content; public Content content;
public LoadedMod mod; public LoadedMod mod;
public ModLoadException(String message, Throwable cause){ public ModLoadException(String message, Throwable cause){
super(message, cause); super(message, cause);
} }
public ModLoadException(String message, @Nullable io.anuke.mindustry.ctype.Content content, Throwable cause){ public ModLoadException(String message, @Nullable Content content, Throwable cause){
super(message, cause); super(message, cause);
this.content = content; this.content = content;
if(content != null){ if(content != null){
+2 -2
View File
@@ -20,7 +20,7 @@ import io.anuke.mindustry.gen.*;
import static io.anuke.mindustry.Vars.net; import static io.anuke.mindustry.Vars.net;
public class Weapon{ public class Weapon{
public final String name; public String name;
/** minimum cursor distance from player, fixes 'cross-eyed' shooting. */ /** minimum cursor distance from player, fixes 'cross-eyed' shooting. */
protected static float minPlayerDist = 20f; protected static float minPlayerDist = 20f;
@@ -64,7 +64,7 @@ public class Weapon{
this.name = name; this.name = name;
} }
protected Weapon(){ public Weapon(){
//no region //no region
this.name = ""; this.name = "";
} }
@@ -172,6 +172,10 @@ public class Zone extends UnlockableContent{
@Override @Override
public void init(){ public void init(){
if(generator instanceof MapGenerator && mod != null){
((MapGenerator)generator).removePrefix(mod.name);
}
generator.init(loadout); generator.init(loadout);
resources.sort(); resources.sort();
@@ -1,20 +1,19 @@
package io.anuke.mindustry.ui.dialogs; package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.Core; import io.anuke.arc.*;
import io.anuke.arc.collection.Array; import io.anuke.arc.collection.*;
import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.*;
import io.anuke.arc.scene.event.ClickListener; import io.anuke.arc.scene.event.*;
import io.anuke.arc.scene.event.HandCursorListener;
import io.anuke.arc.scene.ui.*; import io.anuke.arc.scene.ui.*;
import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.Time; import io.anuke.arc.util.*;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.*;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.*;
import io.anuke.mindustry.ctype.UnlockableContent; import io.anuke.mindustry.ctype.*;
import io.anuke.mindustry.gen.*; import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.type.ContentType; import io.anuke.mindustry.type.*;
import io.anuke.mindustry.ui.Cicon; import io.anuke.mindustry.ui.*;
public class DatabaseDialog extends FloatingDialog{ public class DatabaseDialog extends FloatingDialog{
@@ -34,12 +33,12 @@ public class DatabaseDialog extends FloatingDialog{
table.margin(20); table.margin(20);
ScrollPane pane = new ScrollPane(table); ScrollPane pane = new ScrollPane(table);
Array<io.anuke.mindustry.ctype.Content>[] allContent = Vars.content.getContentMap(); Array<Content>[] allContent = Vars.content.getContentMap();
for(int j = 0; j < allContent.length; j++){ for(int j = 0; j < allContent.length; j++){
ContentType type = ContentType.values()[j]; ContentType type = ContentType.values()[j];
Array<io.anuke.mindustry.ctype.Content> array = allContent[j].select(c -> c instanceof io.anuke.mindustry.ctype.UnlockableContent && !((io.anuke.mindustry.ctype.UnlockableContent)c).isHidden()); Array<Content> array = allContent[j].select(c -> c instanceof UnlockableContent && !((UnlockableContent)c).isHidden());
if(array.size == 0) continue; if(array.size == 0) continue;
table.add("$content." + type.name() + ".name").growX().left().color(Pal.accent); table.add("$content." + type.name() + ".name").growX().left().color(Pal.accent);
@@ -54,7 +53,7 @@ public class DatabaseDialog extends FloatingDialog{
int count = 0; int count = 0;
for(int i = 0; i < array.size; i++){ for(int i = 0; i < array.size; i++){
io.anuke.mindustry.ctype.UnlockableContent unlock = (io.anuke.mindustry.ctype.UnlockableContent)array.get(i); UnlockableContent unlock = (UnlockableContent)array.get(i);
Image image = unlocked(unlock) ? new Image(unlock.icon(Cicon.medium)) : new Image(Icon.lockedSmall, Pal.gray); Image image = unlocked(unlock) ? new Image(unlock.icon(Cicon.medium)) : new Image(Icon.lockedSmall, Pal.gray);
list.add(image).size(8*4).pad(3); list.add(image).size(8*4).pad(3);
+2 -3
View File
@@ -17,7 +17,7 @@ import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
import io.anuke.arc.util.ArcAnnotate.*; import io.anuke.arc.util.ArcAnnotate.*;
import io.anuke.arc.util.pooling.*; import io.anuke.arc.util.pooling.*;
import io.anuke.mindustry.ctype.UnlockableContent; import io.anuke.mindustry.ctype.*;
import io.anuke.mindustry.entities.*; import io.anuke.mindustry.entities.*;
import io.anuke.mindustry.entities.effect.*; import io.anuke.mindustry.entities.effect.*;
import io.anuke.mindustry.entities.traits.BuilderTrait.*; import io.anuke.mindustry.entities.traits.BuilderTrait.*;
@@ -26,7 +26,6 @@ import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.type.*; import io.anuke.mindustry.type.*;
import io.anuke.mindustry.ui.*; import io.anuke.mindustry.ui.*;
import io.anuke.mindustry.ui.Cicon;
import io.anuke.mindustry.world.blocks.*; import io.anuke.mindustry.world.blocks.*;
import io.anuke.mindustry.world.blocks.power.*; import io.anuke.mindustry.world.blocks.power.*;
import io.anuke.mindustry.world.consumers.*; import io.anuke.mindustry.world.consumers.*;
@@ -697,7 +696,7 @@ public class Block extends BlockStorage{
} }
public void drawRequestConfigCenter(BuildRequest req, io.anuke.mindustry.ctype.Content content, String region){ public void drawRequestConfigCenter(BuildRequest req, Content content, String region){
Color color = content instanceof Item ? ((Item)content).color : content instanceof Liquid ? ((Liquid)content).color : null; Color color = content instanceof Item ? ((Item)content).color : content instanceof Liquid ? ((Liquid)content).color : null;
if(color == null) return; if(color == null) return;