本文整理汇总了Java中com.artemis.utils.Bag.add方法的典型用法代码示例。如果您正苦于以下问题:Java Bag.add方法的具体用法?Java Bag.add怎么用?Java Bag.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.artemis.utils.Bag
的用法示例。
在下文中一共展示了Bag.add方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRelevantListeners
import com.artemis.utils.Bag; //导入方法依赖的package包/类
/** Get listeners that are subscribed to the event. */
protected ImmutableBag<EventListener> getRelevantListeners(Event event) {
final Bag<EventListener> relevantListeners = new Bag<>();
// resort listeners when we need to.
if (sortDirty) {
sortDirty=false;
BagUtils.sort(listeners);
}
// who needs efficiency! not us!
for(int i=0, s=listeners.size(); i<s; i++) {
final EventListener listener = listeners.get(i);
if ( listener != null ) {
if ( canHandle(listener, event))
{
relevantListeners.add(listener);
}
}
}
return relevantListeners;
}
示例2: getEntitiesWithLayer
import com.artemis.utils.Bag; //导入方法依赖的package包/类
public ImmutableBag<Entity> getEntitiesWithLayer (int layerId) {
Bag<Entity> entities = new Bag<Entity>();
IntBag bag = subscription.getEntities();
int[] data = bag.getData();
for (int i = 0; i < bag.size(); i++) {
int id = data[i];
Entity entity = world.getEntity(id);
Layer layer = layerCm.get(entity);
if (layer.layerId == layerId)
entities.add(entity);
}
return entities;
}
示例3: add
import com.artemis.utils.Bag; //导入方法依赖的package包/类
/**
* Set the group of the entity.
*
* @param group group to add the entity into.
* @param e entity to add into the group.
*/
public void add(Entity e, String group) {
Bag<Entity> entities = entitiesByGroup.get(group);
if(entities == null) {
entities = new Bag<Entity>();
entitiesByGroup.put(group, entities);
}
entities.add(e);
Bag<String> groups = groupsByEntity.get(e);
if(groups == null) {
groups = new Bag<String>();
groupsByEntity.put(e, groups);
}
groups.add(group);
}
示例4: add
import com.artemis.utils.Bag; //导入方法依赖的package包/类
/**
* Set the group of the entity.
*
* @param group group to add the entity into.
* @param e entity to add into the group.
*/
public void add(Entity e, String group) {
Bag<Entity> entities;
if (!entitiesByGroup.containsKey(group))
{
entities = new Bag<Entity>();
entitiesByGroup.put(group, entities);
}
else
{
entities = entitiesByGroup.get(group);
}
entities.add(e);
Bag<String> groups;
if (!groupsByEntity.containsKey(e))
{
groups = new Bag<String>();
groupsByEntity.put(e, groups);
}
else
{
groups = groupsByEntity.get(e);
}
groups.add(group);
}
示例5: getExclusiveEntities
import com.artemis.utils.Bag; //导入方法依赖的package包/类
/**
* Get all entities that only belong to the provided group
* @param group
* @return
*/
public ImmutableBag<Entity> getExclusiveEntities(String group) {
ImmutableBag<Entity> entities = getEntities(group);
Bag<Entity> bag = new Bag<Entity>();
//check for collisions
for (int i = 0; i < entities.size(); i++)
{
Entity e = entities.get(i);
if (getGroups(e).size() == 1){
bag.add(e);
}
}
return bag;
}
示例6: initialize
import com.artemis.utils.Bag; //导入方法依赖的package包/类
@Override
protected void initialize() {
for (int i = 0; permutations.length > i; i++) {
Bag<Class<? extends Component>> components = new Bag<Class<? extends Component>>();
for (int classIndex = 0, s = (int)(rng.nextFloat() * 7) + 3; s > classIndex; classIndex++) {
components.add(types.get((int)(rng.nextFloat() * types.size())));
}
permutations[i] = components;
}
for (int i = 0; ENTITY_COUNT > i; i++)
createEntity();
}
示例7: register
import com.artemis.utils.Bag; //导入方法依赖的package包/类
@Override
public void register(EventListener listener) {
if ( listener == null ) throw new NullPointerException("Listener required.");
// Bind listener to the related event class.
Bag<EventListener> listenersFor = getListenersFor(listener.getParameterType(), true);
if ( !listenersFor.contains(listener)) {
listenersFor.add(listener);
// the hierarchical cache is now out of date. purrrrrrrrge!
invalidateHierarchicalCache();
}
}
示例8: toBag
import com.artemis.utils.Bag; //导入方法依赖的package包/类
public static <E> Bag<E> toBag (Array<E> array) {
Bag<E> bag = new Bag<E>(array.size);
for (E element : array)
bag.add(element);
return bag;
}
示例9: cloneObject
import com.artemis.utils.Bag; //导入方法依赖的package包/类
@Override
protected Bag cloneObject (Bag original, IDeepCloner cloner, Map<Object, Object> clones) {
Bag bag = new Bag(original.size());
for (Object obj : original) {
bag.add(cloner.deepClone(obj, clones));
}
return bag;
}
示例10: setPlayer
import com.artemis.utils.Bag; //导入方法依赖的package包/类
public void setPlayer(Entity e, String player) {
playerByEntity.put(e, player);
Bag<Entity> entities = entitiesByPlayer.get(player);
if(entities == null) {
entities = new Bag<Entity>();
entitiesByPlayer.put(player, entities);
}
entities.add(e);
}
示例11: setTeam
import com.artemis.utils.Bag; //导入方法依赖的package包/类
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);
}
示例12: getComponentsFor
import com.artemis.utils.Bag; //导入方法依赖的package包/类
public Bag<Component> getComponentsFor(Entity e, Bag<Component> fillBag) {
BitSet componentBits = e.getComponentBits();
for (int i = componentBits.nextSetBit(0); i >= 0; i = componentBits.nextSetBit(i+1)) {
fillBag.add(componentsByType.get(i).get(e.getId()));
}
return fillBag;
}
示例13: getComponentsFor
import com.artemis.utils.Bag; //导入方法依赖的package包/类
public Bag<Component> getComponentsFor(Entity e, Bag<Component> fillBag) {
Bits componentBits = e.getComponentBits();
for (int i = componentBits.nextSetBit(0); i >= 0; i = componentBits.nextSetBit(i+1)) {
fillBag.add(componentsByType.get(i).get(e.getId()));
}
return fillBag;
}