本文整理汇总了Java中com.artemis.utils.Bag.size方法的典型用法代码示例。如果您正苦于以下问题:Java Bag.size方法的具体用法?Java Bag.size怎么用?Java Bag.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.artemis.utils.Bag
的用法示例。
在下文中一共展示了Bag.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatch
import com.artemis.utils.Bag; //导入方法依赖的package包/类
/**
* Dispatch event to registered listeners.
* Events are called on the call stack, avoid deeply nested or circular event calls.
*/
@Override
public void dispatch(Event event) {
if ( event == null ) throw new NullPointerException("Event required.");
final Bag<EventListener> listeners = getListenersForHierarchical(event.getClass());
/** Fetch hierarchical list of listeners. */
Object[] data = listeners.getData();
for (int i = 0, s = listeners.size(); i < s; i++) {
final EventListener listener = (EventListener) data[i];
if (listener != null) {
listener.handle(event);
}
}
}
示例2: createEntity
import com.artemis.utils.Bag; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private final void createEntity() {
Entity e = world.createEntity();
Bag<Class<? extends Component>> components = permutations[cmp[cmpIndex++]];
if (cmpIndex == cmp.length) cmpIndex = 0;
Object[] data = components.getData();
for (int i = 0, s = components.size(); s > i; i++) {
e.addComponent(newInstance(data[i]));
}
e.addToWorld();
}
示例3: safeDeleteAll
import com.artemis.utils.Bag; //导入方法依赖的package包/类
/** Safely delete all entities from bag, regardless if the bag changes. */
public static void safeDeleteAll(final ImmutableBag<Entity> entities1) {
final Bag<Entity> entities = new Bag<>();
entities.addAll(entities1);
for (int i = 0, s = entities.size(); i < s; i++) {
entities.get(i).deleteFromWorld();
}
}
示例4: findPoint
import com.artemis.utils.Bag; //导入方法依赖的package包/类
static IntBag findPoint (TestData data, IntBag fill, Bag<TestData> testData) {
for (int i = 0; i < testData.size(); i++) {
TestData test = testData.get(i);
if (test.contains(data.x, data.y)) {
fill.add(test.id);
}
}
fill.clear();
return fill;
}
示例5: find
import com.artemis.utils.Bag; //导入方法依赖的package包/类
static IntBag find (TestData data, IntBag fill, Bag<TestData> testData) {
for (int i = 0; i < testData.size(); i++) {
TestData test = testData.get(i);
if (test.overlaps(data.x, data.y, data.width, data.height)) {
fill.add(test.id);
}
}
fill.clear();
return fill;
}
示例6: processProfileSystems
import com.artemis.utils.Bag; //导入方法依赖的package包/类
private void processProfileSystems(Bag<BaseSystem> systems) {
final Object[] systemsData = systems.getData();
for (int i = 0, s = systems.size(); s > i; i++) {
if (disabled.get(i))
continue;
updateEntityStates();
processProfileSystem(profilers[i], (BaseSystem) systemsData[i]);
}
updateEntityStates();
}
示例7: getProxy
import com.artemis.utils.Bag; //导入方法依赖的package包/类
private EntityProxy getProxy (Entity entity) {
EntityProxy proxy = getInternalProxyFor(entity);
if (proxy == null) {
for (EditorEntitySupport support : projectExtensionStorage.getEntitySupports()) {
proxy = support.resolveProxy(entity);
if (proxy != null)
return proxy;
}
}
if (proxy == null) {
proxy = new MissingProxy(entity);
Log.error(TAG, String.format("Missing proxy for: %s. Entity structure:", entity));
Log.error(TAG, String.format("=-%s", entity));
Bag<Component> components = entity.getComponents(new Bag<>());
for (int i = 0; i < components.size(); i++) {
String formatString;
if (i == components.size() - 1)
formatString = " \\-- %s";
else
formatString = " |-- %s";
Log.error(TAG, String.format(formatString, components.get(i)));
}
}
return proxy;
}
示例8: 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;
}
示例9: removeFromAllGroups
import com.artemis.utils.Bag; //导入方法依赖的package包/类
public void removeFromAllGroups(Entity e) {
Bag<String> groups = groupsByEntity.get(e);
if(groups != null) {
for(int i = 0; groups.size() > i; i++) {
Bag<Entity> entities = entitiesByGroup.get(groups.get(i));
if(entities != null) {
entities.remove(e);
}
}
groups.clear();
}
}
示例10: check
import com.artemis.utils.Bag; //导入方法依赖的package包/类
/**
* Performs an action on each entity.
* @param entities
* @param performer
*/
private void check(Bag<Entity> entities, Performer performer) {
if (!entities.isEmpty()) {
for (int i = 0; entities.size() > i; i++) {
Entity e = entities.get(i);
notifyManagers(performer, e);
notifySystems(performer, e);
}
entities.clear();
}
}
示例11: disposeSystems
import com.artemis.utils.Bag; //导入方法依赖的package包/类
private void disposeSystems(World world) {
// Delete entities with Effects
ImmutableBag<Entity> entities = world.getManager(GroupManager.class).getEntities(Constants.EFFECTS);
for (int i = 0; i < entities.size(); ++i) {
Bag<Component> components = new Bag<Component>();
world.getComponentManager().getComponentsFor(entities.get(i), components);
for (int j = 0; j < components.size(); ++j) {
// System.out.print("C: ");
Component c = components.get(j);
// System.out.println(c.getClass());
if (c instanceof Effect) {
// System.out.println("REMOVE");
((Effect) c).dispose();
}
}
}
// Delete systems
ImmutableBag<EntitySystem> entitySystems = world.getSystems();
for (int i = 0; i < entitySystems.size(); ++i) {
EntitySystem e = entitySystems.get(i);
if (e instanceof EffectSystem) {
((EffectSystem) e).dispose();
} else if (e instanceof SpriteRenderSystem) {
((SpriteRenderSystem) e).dispose();
}
}
}
示例12: removeFromAllGroups
import com.artemis.utils.Bag; //导入方法依赖的package包/类
public void removeFromAllGroups(Entity e) {
if (groupsByEntity.containsKey(e)){
Bag<String> groups = groupsByEntity.get(e);
for(int i = 0; groups.size() > i; i++) {
Bag<Entity> entities = entitiesByGroup.get(groups.get(i));
if(entities != null) {
entities.remove(e);
}
}
groupsByEntity.remove(e);
}
}
示例13: interpolate
import com.artemis.utils.Bag; //导入方法依赖的package包/类
protected void interpolate(Bag<InterpolatingSystem> systemsBag) {
Object[] systems = systemsBag.getData();
for (int i = 0, s = systemsBag.size(); s > i; i++) {
InterpolatingSystem system = (InterpolatingSystem) systems[i];
system.interpolateSystem();
}
}
示例14: render
import com.artemis.utils.Bag; //导入方法依赖的package包/类
protected void render(Bag<RenderingSystem> systemsBag, Graphics g) {
Object[] systems = systemsBag.getData();
for (int i = 0, s = systemsBag.size(); s > i; i++) {
RenderingSystem system = (RenderingSystem) systems[i];
system.renderSystem(g);
}
}
示例15: freeEntity
import com.artemis.utils.Bag; //导入方法依赖的package包/类
public static void freeEntity(Entity entity) {
Bag<Component> fillBag = new Bag<Component>();
fillBag = entity.getComponents(fillBag);
for (int i = 0; i < fillBag.size(); i++) {
ComponentFactory.freeComponent(fillBag.get(i));
}
}