Documentation, added Content/ContentDatabase classes
This commit is contained in:
14
core/src/io/anuke/mindustry/game/Content.java
Normal file
14
core/src/io/anuke/mindustry/game/Content.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
/**Base interface for an unlockable content type.*/
|
||||
public interface 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();
|
||||
|
||||
/**Returns the type name of this piece of content.
|
||||
* This should return the same value for all instances of this content type.*/
|
||||
String getContentTypeName();
|
||||
}
|
||||
27
core/src/io/anuke/mindustry/game/ContentDatabase.java
Normal file
27
core/src/io/anuke/mindustry/game/ContentDatabase.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package io.anuke.mindustry.game;
|
||||
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
|
||||
public class ContentDatabase {
|
||||
private ObjectMap<String, ObjectSet<String>> unlocked = new ObjectMap<>();
|
||||
|
||||
public boolean isUnlocked(Content content){
|
||||
if(!unlocked.containsKey(content.getContentTypeName())){
|
||||
unlocked.put(content.getContentTypeName(), new ObjectSet<>());
|
||||
}
|
||||
|
||||
ObjectSet<String> set = unlocked.get(content.getContentTypeName());
|
||||
|
||||
return set.contains(content.getContentName());
|
||||
}
|
||||
|
||||
private void load(){
|
||||
|
||||
}
|
||||
|
||||
private void save(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user