oh no it's broken
This commit is contained in:
@@ -11,6 +11,7 @@ import io.anuke.arc.scene.ui.TextField;
|
|||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.entities.Effects;
|
import io.anuke.mindustry.entities.Effects;
|
||||||
|
import io.anuke.mindustry.entities.traits.TypeTrait;
|
||||||
import io.anuke.mindustry.entities.type.Player;
|
import io.anuke.mindustry.entities.type.Player;
|
||||||
import io.anuke.mindustry.game.*;
|
import io.anuke.mindustry.game.*;
|
||||||
import io.anuke.mindustry.game.EventType.*;
|
import io.anuke.mindustry.game.EventType.*;
|
||||||
@@ -270,6 +271,10 @@ public class Control implements ApplicationListener{
|
|||||||
dialog.show();
|
dialog.show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < TypeTrait.registeredTypes.size; i++){
|
||||||
|
Log.info("{0} = {1}", i, TypeTrait.getTypeByID(i).get().getClass().getSimpleName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
package io.anuke.mindustry.entities.traits;
|
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{
|
public interface TypeTrait{
|
||||||
|
/*
|
||||||
int[] lastRegisteredID = {0};
|
int[] lastRegisteredID = {0};
|
||||||
Array<Supplier<? extends TypeTrait>> registeredTypes = new Array<>();
|
Array<Supplier<? extends TypeTrait>> registeredTypes = new Array<>();
|
||||||
ObjectIntMap<Class<? extends TypeTrait>> typeToID = new ObjectIntMap<>();
|
ObjectIntMap<Class<? extends TypeTrait>> typeToID = new ObjectIntMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register and return a type ID. The supplier should return a fresh instace of that type.
|
* 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){
|
static <T extends TypeTrait> void registerType(Class<T> type, Supplier<T> supplier){
|
||||||
if(typeToID.get(type, -1) != -1){
|
if(typeToID.get(type, -1) != -1){
|
||||||
return; //already registered
|
return; //already registered
|
||||||
@@ -23,7 +20,7 @@ public interface TypeTrait{
|
|||||||
lastRegisteredID[0]++;
|
lastRegisteredID[0]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Gets a syncable type by ID.*/
|
/**Gets a syncable type by ID.
|
||||||
static Supplier<? extends TypeTrait> getTypeByID(int id){
|
static Supplier<? extends TypeTrait> getTypeByID(int id){
|
||||||
if(id == -1){
|
if(id == -1){
|
||||||
throw new IllegalArgumentException("Attempt to retrieve invalid entity type ID! Did you forget to set it in ContentLoader.registerTypes()?");
|
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.
|
* Returns the type ID of this entity used for intstantiation. Should be < BYTE_MAX.
|
||||||
* Do not override!
|
* Do not override!
|
||||||
*/
|
|
||||||
default int getTypeID(){
|
default int getTypeID(){
|
||||||
int id = typeToID.get(getClass(), -1);
|
int id = typeToID.get(getClass(), -1);
|
||||||
if(id == -1)
|
if(id == -1)
|
||||||
throw new RuntimeException("Class of type '" + getClass() + "' is not registered! Did you forget to register it in ContentLoader#registerTypes()?");
|
throw new RuntimeException("Class of type '" + getClass() + "' is not registered! Did you forget to register it in ContentLoader#registerTypes()?");
|
||||||
return id;
|
return id;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,6 +231,22 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void readEntities(DataInput stream) throws IOException{
|
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();
|
byte groups = stream.readByte();
|
||||||
|
|
||||||
for(int i = 0; i < groups; i++){
|
for(int i = 0; i < groups; i++){
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package io.anuke.mindustry.ui.fragments;
|
package io.anuke.mindustry.ui.fragments;
|
||||||
|
|
||||||
import io.anuke.arc.scene.Group;
|
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;
|
import io.anuke.mindustry.input.InputHandler;
|
||||||
|
|
||||||
/** Fragment for displaying overlays such as block inventories. */
|
/** Fragment for displaying overlays such as block inventories. */
|
||||||
@@ -8,9 +10,10 @@ public class OverlayFragment extends Fragment{
|
|||||||
public final BlockInventoryFragment inv;
|
public final BlockInventoryFragment inv;
|
||||||
public final BlockConfigFragment config;
|
public final BlockConfigFragment config;
|
||||||
|
|
||||||
private Group group = new Group();
|
private Group group = new WidgetGroup();
|
||||||
|
|
||||||
public OverlayFragment(InputHandler input){
|
public OverlayFragment(InputHandler input){
|
||||||
|
group.touchable(Touchable.childrenOnly);
|
||||||
inv = new BlockInventoryFragment();
|
inv = new BlockInventoryFragment();
|
||||||
config = new BlockConfigFragment();
|
config = new BlockConfigFragment();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user