oh no it's broken

This commit is contained in:
Anuken
2019-07-02 22:44:55 -04:00
parent a7480ae656
commit 4e873f8bf3
4 changed files with 30 additions and 9 deletions

View File

@@ -1,17 +1,14 @@
package io.anuke.mindustry.entities.traits;
import io.anuke.arc.collection.Array;
import io.anuke.arc.collection.ObjectIntMap;
import io.anuke.arc.function.Supplier;
public interface TypeTrait{
/*
int[] lastRegisteredID = {0};
Array<Supplier<? extends TypeTrait>> registeredTypes = new Array<>();
ObjectIntMap<Class<? extends TypeTrait>> typeToID = new ObjectIntMap<>();
/**
* Register and return a type ID. The supplier should return a fresh instace of that type.
*/
static <T extends TypeTrait> void registerType(Class<T> type, Supplier<T> supplier){
if(typeToID.get(type, -1) != -1){
return; //already registered
@@ -23,7 +20,7 @@ public interface TypeTrait{
lastRegisteredID[0]++;
}
/**Gets a syncable type by ID.*/
/**Gets a syncable type by ID.
static Supplier<? extends TypeTrait> getTypeByID(int id){
if(id == -1){
throw new IllegalArgumentException("Attempt to retrieve invalid entity type ID! Did you forget to set it in ContentLoader.registerTypes()?");
@@ -34,11 +31,11 @@ public interface TypeTrait{
/**
* Returns the type ID of this entity used for intstantiation. Should be < BYTE_MAX.
* Do not override!
*/
default int getTypeID(){
int id = typeToID.get(getClass(), -1);
if(id == -1)
throw new RuntimeException("Class of type '" + getClass() + "' is not registered! Did you forget to register it in ContentLoader#registerTypes()?");
return id;
}
}*/
}