@Override
 protected void inserted(Entity e) {
   super.inserted(e);
   if (tm.get(e).getParent() != null) {
     tm.get(tm.get(e).getParent()).addChild(e);
   } else if (!roots.contains(e)) roots.add(e);
 }
 @Override
 public void addedManager(String name) {
   for (int i = 0, n = _listeners.size(); i < n; ++i) {
     EntityTrackerCommunicator communicator = _listeners.get(i);
     communicator.addedManager(name);
   }
   _managers.add(name);
 }
Exemple #3
0
 /** Fetch unique identity for passed composition. */
 int getIdentity(BitSet components) {
   Object[] bitsets = composition.getData();
   int size = composition.size();
   for (int i = NO_COMPONENTS; size > i; i++) { // want to start from 1 so that 0 can mean null
     if (components.equals(bitsets[i])) return i;
   }
   composition.add((BitSet) components.clone());
   return size;
 }
 public void setParent(Entity parent, Entity child, String bone) {
   if (tm.get(child).getParent() != null) tm.get(tm.get(child).getParent()).removeChild(child);
   else if (parent != null) roots.remove(child);
   tm.get(child).setParent(parent, bone);
   if (parent != null) {
     tm.get(parent).addChild(child);
   } else {
     if (!roots.contains(child)) roots.add(child);
   }
 }
Exemple #5
0
  public void setTeam(String player, String team) {
    removeFromTeam(player);

    teamByPlayer.put(player, team);

    Bag<String> players = playersByTeam.get(team);
    if (players == null) {
      players = new Bag<String>();
      playersByTeam.put(team, players);
    }
    players.add(player);
  }
Exemple #6
0
    void recycle() {
      int s = limbo.size();
      if (s == 0) return;

      Object[] data = limbo.getData();
      for (int i = 0; s > i; i++) {
        Entity e = (Entity) data[i];
        recycled.add(e);
        data[i] = null;
      }
      limbo.setSize(0);
    }
        @Override
        public RawConnectionCommunicator getListener(String remoteName) {
          // Server requests communicator for given remote.

          EntityTrackerCommunicator newCommunicator =
              new EntityTrackerCommunicator() {
                @Override
                public void connected(
                    SocketAddress remoteAddress, RawConnectionOutputListener output) {
                  super.connected(remoteAddress, output);
                  injectWorldController(_worldController);

                  for (int i = 0, n = _systems.size(); i < n; ++i) {
                    final Tuple3<Integer, String, AspectInfo> system = _systems.get(i);
                    final AspectInfo aspects = system.item3;
                    addedSystem(
                        system.item1,
                        system.item2,
                        aspects.allTypes,
                        aspects.oneTypes,
                        aspects.exclusionTypes);
                  }

                  for (int i = 0, n = _managers.size(); i < n; ++i) {
                    addedManager(_managers.get(i));
                  }

                  for (int i = 0, n = _componentTypes.size(); i < n; ++i) {
                    addedComponentType(i, _componentTypes.get(i));
                  }

                  for (int i = 0, n = _systems.size(); i < n; ++i) {
                    if (_entitySystemsEntitiesCount.get(i) != null) {
                      int entitiesCount = _entitySystemsEntitiesCount.get(i);
                      int maxEntitiesCount = _entitySystemsMaxEntitiesCount.get(i);
                      updatedEntitySystem(i, entitiesCount, maxEntitiesCount);
                    }
                  }

                  for (Entry<Integer, BitSet> entity : _entities.entrySet()) {
                    addedEntity(entity.getKey(), entity.getValue());
                  }
                }
              };
          _listeners.add(newCommunicator);

          return newCommunicator;
        }
 /**
  * Ensure all systems are notified of changes to this entity.
  *
  * @param e entity
  */
 public void refreshEntity(Entity e) {
   refreshed.add(e);
 }
 /**
  * Delete the provided entity from the world.
  *
  * @param e entity
  */
 public void deleteEntity(Entity e) {
   if (!deleted.contains(e)) deleted.add(e);
 }
 private void insertToSystem(Entity e) {
   actives.add(e);
   e.getSystemBits().set(this.getSystemIndex());
   inserted(e);
 }
Exemple #11
0
 ComponentIdentityResolver() {
   composition = new Bag<BitSet>();
   composition.add(null);
   composition.add(new BitSet());
 }