Permalink
Browse files

update artemis-odb to 2.0.0

  • Loading branch information...
bartsch-dev committed Oct 27, 2016
1 parent e7f48ee commit aeb3a7eed7f1b89bdb43af637e5c3c536979841d
Showing with 125 additions and 144 deletions.
  1. +4 −0 .gitignore
  2. +4 −4 artemis-entity-tracker-gui/src/main/java/net/namekdev/entity_tracker/ui/EntityTrackerMainWindow.java
  3. +5 −5 artemis-entity-tracker-gui/src/main/java/net/namekdev/entity_tracker/ui/model/EntityTableModel.java
  4. +2 −4 ...-entity-tracker-gui/src/main/java/net/namekdev/entity_tracker/ui/partials/EntityDetailsPanel.java
  5. +1 −1 artemis-entity-tracker/pom.xml
  6. +20 −32 artemis-entity-tracker/src/main/java/net/namekdev/entity_tracker/EntityTracker.java
  7. +3 −6 ...entity-tracker/src/main/java/net/namekdev/entity_tracker/connectors/DummyWorldUpdateListener.java
  8. +3 −4 artemis-entity-tracker/src/main/java/net/namekdev/entity_tracker/connectors/WorldUpdateListener.java
  9. +5 −5 artemis-entity-tracker/src/main/java/net/namekdev/entity_tracker/model/AspectInfo.java
  10. +3 −4 artemis-entity-tracker/src/main/java/net/namekdev/entity_tracker/model/SystemInfo.java
  11. +6 −7 artemis-entity-tracker/src/main/java/net/namekdev/entity_tracker/network/EntityTrackerServer.java
  12. +0 −1 artemis-entity-tracker/src/main/java/net/namekdev/entity_tracker/network/base/Server.java
  13. +7 −8 ...ker/src/main/java/net/namekdev/entity_tracker/network/communicator/EntityTrackerCommunicator.java
  14. +5 −5 ...src/main/java/net/namekdev/entity_tracker/network/communicator/ExternalInterfaceCommunicator.java
  15. +8 −8 ...ty-tracker/src/main/java/net/namekdev/entity_tracker/utils/serialization/NetworkDeserializer.java
  16. +5 −5 ...y-tracker/src/main/java/net/namekdev/entity_tracker/utils/serialization/NetworkSerialization.java
  17. +8 −8 ...tity-tracker/src/main/java/net/namekdev/entity_tracker/utils/serialization/NetworkSerializer.java
  18. +36 −37 ...acker/src/test/java/net/namekdev/entity_tracker/utils/serialization/NetworkSerializationTest.java
View
@@ -3,3 +3,7 @@ target/
.settings/
.classpath
.project
# IntelliJ IDEA
.idea/
*.iml
@@ -6,7 +6,6 @@
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.BitSet;
import java.util.Enumeration;
import javax.swing.BoxLayout;
@@ -25,6 +24,7 @@
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import com.artemis.utils.BitVector;
import net.namekdev.entity_tracker.connectors.WorldController;
import net.namekdev.entity_tracker.connectors.WorldUpdateInterfaceListener;
import net.namekdev.entity_tracker.model.ComponentTypeInfo;
@@ -184,7 +184,7 @@ private void selectEntity(int viewRow, int viewCol) {
int entityId = (int) entitiesTableModel.getValueAt(modelRow, 0);
int componentIndex = modelCol-1;
BitSet entityComponents = entitiesTableModel.getEntityComponents(entityId);
BitVector entityComponents = entitiesTableModel.getEntityComponents(entityId);
if (componentIndex >= 0 && !entityComponents.get(componentIndex)) {
componentIndex = -1;
@@ -204,7 +204,7 @@ public int getListeningBitset() {
}
@Override
public void addedSystem(final int index, final String name, final BitSet allTypes, final BitSet oneTypes, final BitSet notTypes) {
public void addedSystem(final int index, final String name, final BitVector allTypes, final BitVector oneTypes, final BitVector notTypes) {
final boolean hasAspect = allTypes != null || oneTypes != null || notTypes != null;
SwingUtilities.invokeLater(new Runnable() {
@@ -253,7 +253,7 @@ public void run() {
}
@Override
public void addedEntity(final int entityId, final BitSet components) {
public void addedEntity(final int entityId, final BitVector components) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
entitiesTableModel.addEntity(entityId, components);
@@ -1,17 +1,17 @@
package net.namekdev.entity_tracker.ui.model;
import java.util.BitSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;
import com.artemis.utils.BitVector;
import net.namekdev.entity_tracker.model.ComponentTypeInfo;
import net.namekdev.entity_tracker.utils.Array;
public class EntityTableModel extends DefaultTableModel {
private Map<Integer, BitSet> _entityComponents = new HashMap<Integer, BitSet>();
private Map<Integer, BitVector> _entityComponents = new HashMap<>();
private Array<ComponentTypeInfo> _componentTypes = new Array<ComponentTypeInfo>(50);
@@ -30,13 +30,13 @@ public void setComponentType(int index, ComponentTypeInfo info) {
fireTableStructureChanged();
}
public void addEntity(int entityId, BitSet components) {
public void addEntity(int entityId, BitVector components) {
// TODO check if bitset isn't greater than before model header columns
Vector<Object> row = new Vector<Object>(components.length() + 1);
row.add(entityId);
for (int i = 0, n = components.size(); i < n; ++i) {
for (int i = 0, n = components.length(); i < n; ++i) {
row.add(components.get(i));
}
@@ -56,7 +56,7 @@ public void removeEntity(int entityId) {
_entityComponents.remove(entityId);
}
public BitSet getEntityComponents(int entityId) {
public BitVector getEntityComponents(int entityId) {
return _entityComponents.get(entityId);
}
@@ -3,7 +3,6 @@
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.util.BitSet;
import javax.swing.BoxLayout;
import javax.swing.DefaultListModel;
@@ -14,12 +13,11 @@
import javax.swing.border.TitledBorder;
import javax.swing.event.ListSelectionListener;
import net.namekdev.entity_tracker.connectors.WorldController;
import com.artemis.utils.BitVector;
import net.namekdev.entity_tracker.model.ComponentTypeInfo;
import net.namekdev.entity_tracker.ui.Context;
import net.namekdev.entity_tracker.ui.model.EntityTableModel;
import net.namekdev.entity_tracker.ui.utils.SelectionListener;
import net.namekdev.entity_tracker.utils.Array;
import net.namekdev.entity_tracker.utils.IndexBiMap;
public class EntityDetailsPanel extends JPanel {
@@ -91,7 +89,7 @@ else if (componentTypeIndex < 0 && _currentComponentIndex >= 0) {
}
if (entityId != _currentEntityId) {
BitSet entityComponents = _entityTableModel.getEntityComponents(entityId);
BitVector entityComponents = _entityTableModel.getEntityComponents(entityId);
_entityTitledBorder.setTitle("Entity #" + entityId);
@@ -12,7 +12,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<artemis-odb.version>[1.0.0,2.0.0)</artemis-odb.version>
<artemis-odb.version>2.0.0</artemis-odb.version>
</properties>
<dependencies>
@@ -1,22 +1,10 @@
package net.namekdev.entity_tracker;
import java.util.BitSet;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import net.namekdev.entity_tracker.connectors.WorldController;
import net.namekdev.entity_tracker.connectors.WorldUpdateListener;
import net.namekdev.entity_tracker.model.AspectInfo;
import net.namekdev.entity_tracker.model.ComponentTypeInfo;
import net.namekdev.entity_tracker.model.FieldInfo;
import net.namekdev.entity_tracker.model.SystemInfo;
import net.namekdev.entity_tracker.model.ManagerInfo;
import net.namekdev.entity_tracker.utils.ArrayPool;
import net.namekdev.entity_tracker.utils.ReflectionUtils;
import net.namekdev.entity_tracker.utils.serialization.NetworkSerialization;
import com.artemis.Aspect;
import com.artemis.BaseComponentMapper;
import com.artemis.BaseEntitySystem;
import com.artemis.BaseSystem;
import com.artemis.Component;
@@ -29,12 +17,23 @@
import com.artemis.EntitySubscription.SubscriptionListener;
import com.artemis.Manager;
import com.artemis.utils.Bag;
import com.artemis.utils.BitVector;
import com.artemis.utils.ImmutableBag;
import com.artemis.utils.IntBag;
import com.artemis.utils.reflect.ClassReflection;
import com.artemis.utils.reflect.Field;
import com.artemis.utils.reflect.Method;
import com.artemis.utils.reflect.ReflectionException;
import net.namekdev.entity_tracker.connectors.WorldController;
import net.namekdev.entity_tracker.connectors.WorldUpdateListener;
import net.namekdev.entity_tracker.model.AspectInfo;
import net.namekdev.entity_tracker.model.ComponentTypeInfo;
import net.namekdev.entity_tracker.model.FieldInfo;
import net.namekdev.entity_tracker.model.ManagerInfo;
import net.namekdev.entity_tracker.model.SystemInfo;
import net.namekdev.entity_tracker.utils.ArrayPool;
import net.namekdev.entity_tracker.utils.ReflectionUtils;
import net.namekdev.entity_tracker.utils.serialization.NetworkSerialization;
/**
* @author Namek
@@ -50,7 +49,7 @@
public final Map<String, ManagerInfo> managersInfoByName = new HashMap<String, ManagerInfo>();
public final Map<Class<Component>, ComponentTypeInfo> allComponentTypesInfoByClass = new HashMap<Class<Component>, ComponentTypeInfo>();
public final Bag<ComponentTypeInfo> allComponentTypesInfo = new Bag<ComponentTypeInfo>();
public final Bag<ComponentMapper<? extends Component>> allComponentMappers = new Bag<ComponentMapper<? extends Component>>();
public final Bag<BaseComponentMapper<Component>> allComponentMappers = new Bag<>();
protected Method entity_getComponentBits;
@@ -96,7 +95,7 @@ private void find42UnicornManagers() {
Class<? extends BaseSystem> systemType = system.getClass();
String systemName = systemType.getSimpleName();
Aspect aspect = null;
BitSet actives = null;
BitVector actives = null;
EntitySubscription subscription = null;
if (system instanceof BaseEntitySystem) {
@@ -171,36 +170,25 @@ public void inserted(IntBag entities) {
});
}
private BitSet componentsToAspectBitset(Collection<Class<? extends Component>> componentTypes) {
BitSet bitset = new BitSet(allComponentTypes.size());
for (Class<? extends Component> componentType : componentTypes) {
int index = typeFactory.getIndexFor(componentType);
bitset.set(index);
}
return bitset;
}
@Override
public void added(Entity e) {
if (updateListener == null || (updateListener.getListeningBitset() & WorldUpdateListener.ENTITY_ADDED) == 0) {
return;
}
BitSet componentBitset = null;
BitVector componentBitVector = null;
try {
componentBitset = (BitSet) entity_getComponentBits.invoke(e);
componentBitVector = (BitVector) entity_getComponentBits.invoke(e);
}
catch (ReflectionException exc) {
throw new RuntimeException(exc);
}
if (componentBitset.size() > _notifiedComponentTypesCount) {
if (componentBitVector.length() > _notifiedComponentTypesCount) {
inspectNewComponentTypesAndNotify();
}
updateListener.addedEntity(e.getId(), (BitSet) componentBitset.clone());
updateListener.addedEntity(e.getId(), new BitVector(componentBitVector));
}
@Override
@@ -262,7 +250,7 @@ public void setManagerState(String name, boolean isOn) {
@Override
public void requestComponentState(int entityId, int componentIndex) {
final ComponentTypeInfo info = allComponentTypesInfo.get(componentIndex);
final ComponentMapper<? extends Component> mapper = allComponentMappers.get(componentIndex);
final BaseComponentMapper<Component> mapper = allComponentMappers.get(componentIndex);
Object component = mapper.get(entityId);
@@ -288,7 +276,7 @@ public void requestComponentState(int entityId, int componentIndex) {
@Override
public void setComponentFieldValue(int entityId, int componentIndex, int fieldIndex, Object value) {
final ComponentTypeInfo info = allComponentTypesInfo.get(componentIndex);
final ComponentMapper<? extends Component> mapper = allComponentMappers.get(componentIndex);
final BaseComponentMapper<Component> mapper = allComponentMappers.get(componentIndex);
Object component = mapper.get(entityId);
FieldInfo fieldInfo = info.fields.get(fieldIndex);
@@ -1,7 +1,6 @@
package net.namekdev.entity_tracker.connectors;
import java.util.BitSet;
import com.artemis.utils.BitVector;
import net.namekdev.entity_tracker.model.ComponentTypeInfo;
public class DummyWorldUpdateListener implements WorldUpdateListener {
@@ -15,8 +14,7 @@ public int getListeningBitset() {
}
@Override
public void addedSystem(int index, String name, BitSet allTypes, BitSet oneTypes, BitSet notTypes) {
}
public void addedSystem(int index, String name, BitVector allTypes, BitVector oneTypes, BitVector notTypes) {}
@Override
public void addedManager(String name) {
@@ -31,8 +29,7 @@ public void updatedEntitySystem(int index, int entitiesCount, int maxEntitiesCou
}
@Override
public void addedEntity(int entityId, BitSet components) {
}
public void addedEntity(int entityId, BitVector components) {}
@Override
public void deletedEntity(int entityId) {
@@ -1,7 +1,6 @@
package net.namekdev.entity_tracker.connectors;
import java.util.BitSet;
import com.artemis.utils.BitVector;
import net.namekdev.entity_tracker.model.ComponentTypeInfo;
/**
@@ -19,15 +18,15 @@
int getListeningBitset();
void addedSystem(int index, String name, BitSet allTypes, BitSet oneTypes, BitSet notTypes);
void addedSystem(int index, String name, BitVector allTypes, BitVector oneTypes, BitVector notTypes);
void addedManager(String name);
void addedComponentType(int index, ComponentTypeInfo info);
void updatedEntitySystem(int index, int entitiesCount, int maxEntitiesCount);
void addedEntity(int entityId, BitSet components);
void addedEntity(int entityId, BitVector components);
// void changed(Entity e);
@@ -1,17 +1,17 @@
package net.namekdev.entity_tracker.model;
import java.util.BitSet;
import com.artemis.utils.BitVector;
public class AspectInfo {
public BitSet allTypes;
public BitSet oneTypes;
public BitSet exclusionTypes;
public BitVector allTypes;
public BitVector oneTypes;
public BitVector exclusionTypes;
public AspectInfo() {
}
public AspectInfo(BitSet allTypes, BitSet oneTypes, BitSet exclusionTypes) {
public AspectInfo(BitVector allTypes, BitVector oneTypes, BitVector exclusionTypes) {
this.allTypes = allTypes;
this.oneTypes = oneTypes;
this.exclusionTypes = exclusionTypes;
@@ -1,24 +1,23 @@
package net.namekdev.entity_tracker.model;
import java.util.BitSet;
import com.artemis.Aspect;
import com.artemis.BaseSystem;
import com.artemis.EntitySubscription;
import com.artemis.utils.BitVector;
public class SystemInfo {
public int systemIndex;
public String systemName;
public BaseSystem system;
public Aspect aspect;
public AspectInfo aspectInfo;
public BitSet actives;
public BitVector actives;
public EntitySubscription subscription;
public int entitiesCount = 0;
public int maxEntitiesCount = 0;
public SystemInfo(int systemIndex, String systemName, BaseSystem system, Aspect aspect, AspectInfo aspectInfo, BitSet actives, EntitySubscription subscription) {
public SystemInfo(int systemIndex, String systemName, BaseSystem system, Aspect aspect, AspectInfo aspectInfo, BitVector actives, EntitySubscription subscription) {
this.systemIndex = systemIndex;
this.systemName = systemName;
this.system = system;
Oops, something went wrong.

0 comments on commit aeb3a7e

Please sign in to comment.