Documentation, added Content/ContentDatabase classes

This commit is contained in:
Anuken
2018-05-28 15:20:46 -04:00
parent 857f36e01a
commit ce68c2a3e9
28 changed files with 207 additions and 75 deletions

View 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();
}

View 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(){
}
}