pain and suffering of various kinds
This commit is contained in:
@@ -1,34 +1,37 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
|
||||
/**
|
||||
* Base interface for a content type that is loaded in {@link io.anuke.mindustry.core.ContentLoader}.
|
||||
*/
|
||||
public interface Content{
|
||||
|
||||
/**Base class for a content type that is loaded in {@link io.anuke.mindustry.core.ContentLoader}.*/
|
||||
public abstract class Content{
|
||||
public final byte id;
|
||||
|
||||
public Content(){
|
||||
this.id = (byte)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.
|
||||
*/
|
||||
ContentType getContentType();
|
||||
public abstract ContentType getContentType();
|
||||
|
||||
/**
|
||||
* Returns a list of all instances of this content.
|
||||
*/
|
||||
Array<? extends Content> getAll();
|
||||
|
||||
/**
|
||||
* Called after all content is created. Do not use to load regions or texture data!
|
||||
*/
|
||||
default void init(){
|
||||
/**Called after all content is 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.
|
||||
*/
|
||||
default void load(){
|
||||
public void load(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return getContentType().name() + "#" + id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.type.ContentType;
|
||||
|
||||
/**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();
|
||||
|
||||
/**This method should return the list of the content of this type, for further loading.*/
|
||||
Array<? extends Content> getAll();
|
||||
/**This method should return the type of content being loaded.*/
|
||||
ContentType type();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
public interface MappableContent extends Content {
|
||||
public abstract class MappableContent extends Content {
|
||||
/**
|
||||
* Returns the unqiue name of this piece of content.
|
||||
* The name only needs to be unique for all content of this type.
|
||||
* Do not use IDs for names! Make sure this string stays constant with each update unless removed.
|
||||
* (e.g. having a recipe and a block, both with name "wall" is fine, as they are different types).
|
||||
*/
|
||||
String getContentName();
|
||||
public abstract String getContentName();
|
||||
|
||||
int getID();
|
||||
@Override
|
||||
public String toString(){
|
||||
return getContentName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,31 +6,31 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
|
||||
/**Base interface for an unlockable content type.*/
|
||||
public interface UnlockableContent extends MappableContent{
|
||||
public abstract class UnlockableContent extends MappableContent{
|
||||
/**Returns the localized name of this content.*/
|
||||
String localizedName();
|
||||
public abstract String localizedName();
|
||||
|
||||
TextureRegion getContentIcon();
|
||||
public abstract TextureRegion getContentIcon();
|
||||
|
||||
/**This should show all necessary info about this content in the specified table.*/
|
||||
void displayInfo(Table table);
|
||||
public abstract void displayInfo(Table table);
|
||||
|
||||
/**Called when this content is unlocked. Use this to unlock other related content.*/
|
||||
default void onUnlock(){
|
||||
public void onUnlock(){
|
||||
}
|
||||
|
||||
/**Whether this content is always hidden in the content info dialog.*/
|
||||
default boolean isHidden(){
|
||||
public boolean isHidden(){
|
||||
return false;
|
||||
}
|
||||
|
||||
/**Lists the content that must be unlocked in order for this specific content to become unlocked. May return null.*/
|
||||
default UnlockableContent[] getDependencies(){
|
||||
public UnlockableContent[] getDependencies(){
|
||||
return null;
|
||||
}
|
||||
|
||||
/**Returns whether dependencies are satisfied for unlocking this content.*/
|
||||
default boolean canBeUnlocked(){
|
||||
public boolean canBeUnlocked(){
|
||||
UnlockableContent[] depend = getDependencies();
|
||||
if(depend == null){
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user