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

@@ -11,6 +11,7 @@ import io.anuke.arc.scene.ui.TextField;
import io.anuke.arc.util.*;
import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.entities.Effects;
import io.anuke.mindustry.entities.traits.TypeTrait;
import io.anuke.mindustry.entities.type.Player;
import io.anuke.mindustry.game.*;
import io.anuke.mindustry.game.EventType.*;
@@ -270,6 +271,10 @@ public class Control implements ApplicationListener{
dialog.show();
});
}
for(int i = 0; i < TypeTrait.registeredTypes.size; i++){
Log.info("{0} = {1}", i, TypeTrait.getTypeByID(i).get().getClass().getSimpleName());
}
}
@Override

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;
}
}*/
}

View File

@@ -231,6 +231,22 @@ public abstract class SaveVersion extends SaveFileReader{
}
public void readEntities(DataInput stream) throws IOException{
/* Latest data:
0 = Player
1 = Fire
2 = Puddle
3 = Draug
4 = Spirit
5 = Phantom
6 = Dagger
7 = Crawler
8 = Titan
9 = Fortress
10 = Eruptor
11 = Wraith
12 = Ghoul
13 = Revenant
*/
byte groups = stream.readByte();
for(int i = 0; i < groups; i++){

View File

@@ -1,6 +1,8 @@
package io.anuke.mindustry.ui.fragments;
import io.anuke.arc.scene.Group;
import io.anuke.arc.scene.event.Touchable;
import io.anuke.arc.scene.ui.layout.WidgetGroup;
import io.anuke.mindustry.input.InputHandler;
/** Fragment for displaying overlays such as block inventories. */
@@ -8,9 +10,10 @@ public class OverlayFragment extends Fragment{
public final BlockInventoryFragment inv;
public final BlockConfigFragment config;
private Group group = new Group();
private Group group = new WidgetGroup();
public OverlayFragment(InputHandler input){
group.touchable(Touchable.childrenOnly);
inv = new BlockInventoryFragment();
config = new BlockConfigFragment();
}