当前位置: 首页>>代码示例>>Java>>正文


Java Bits类代码示例

本文整理汇总了Java中com.badlogic.gdx.utils.Bits的典型用法代码示例。如果您正苦于以下问题:Java Bits类的具体用法?Java Bits怎么用?Java Bits使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Bits类属于com.badlogic.gdx.utils包,在下文中一共展示了Bits类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matches

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
/** @return Whether the entity matches the family requirements or not */
public boolean matches (Entity entity) {
	Bits entityComponentBits = entity.getComponentBits();

	if (!entityComponentBits.containsAll(all)) {
		return false;
	}

	if (!one.isEmpty() && !one.intersects(entityComponentBits)) {
		return false;
	}

	if (!exclude.isEmpty() && exclude.intersects(entityComponentBits)) {
		return false;
	}

	return true;
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:19,代码来源:Family.java

示例2: removeEntityListener

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
public void removeEntityListener (EntityListener listener) {
	for (int i = 0; i < entityListeners.size; i++) {
		EntityListenerData entityListenerData = entityListeners.get(i);
		if (entityListenerData.listener == listener) {
			// Shift down bitmasks by one step
			for (Bits mask : entityListenerMasks.values()) {
				for (int k = i, n = mask.length(); k < n; k++) {
					if (mask.get(k + 1)) {
						mask.set(k);
					} else {
						mask.clear(k);
					}
				}
			}

			entityListeners.removeIndex(i--);
		}
	}
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:20,代码来源:FamilyManager.java

示例3: registerFamily

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
private ImmutableArray<Entity> registerFamily(Family family) {
	ImmutableArray<Entity> entitiesInFamily = immutableFamilies.get(family);

	if (entitiesInFamily == null) {
		Array<Entity> familyEntities = new Array<Entity>(false, 16);
		entitiesInFamily = new ImmutableArray<Entity>(familyEntities);
		families.put(family, familyEntities);
		immutableFamilies.put(family, entitiesInFamily);
		entityListenerMasks.put(family, new Bits());

		for (Entity entity : entities){
			updateFamilyMembership(entity);
		}
	}

	return entitiesInFamily;
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:18,代码来源:FamilyManager.java

示例4: getScore

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
private int getScore(Bits state, Bits tags) {
	if (!state.containsAll(tags)) {
		return Integer.MIN_VALUE;
	}
	
	tmp.clear();
	tmp.or(state);
	tmp.and(tags);
	
	int score = 0;
	int index = 0;
	
	while ((index = tmp.nextSetBit(index)) > -1) {
		score++;
		index++;
	}
	
	return score;
}
 
开发者ID:saltares,项目名称:libgdxjam,代码行数:20,代码来源:AnimationControlSystem.java

示例5: rayTest

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
public Entity rayTest(Ray ray, Vector3 hitPointWorld, short belongsToFlag, short collidesWithFlag,
					  float rayDistance, Bits layers) {
	rayFrom.set(ray.origin);
	rayTo.set(ray.direction).scl(rayDistance).add(rayFrom);
	callback.setCollisionObject(null);
	callback.setClosestHitFraction(1f);
	callback.setRay(ray, rayDistance);
	callback.setLayers(layers);

	callback.setCollisionFilterMask(belongsToFlag);
	callback.setCollisionFilterGroup(collidesWithFlag);

	dynamicsWorld.rayTest(rayFrom, rayTo, callback);

	if (callback.hasHit()) {
		if (hitPointWorld != null) {
			callback.getHitPointWorld(hitPointWorld);
		}
		long entityId = callback.getCollisionObject().getUserPointer();
		return getEntity(entityId);
	}
	return null;
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:24,代码来源:GameEngine.java

示例6: rayTest

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
/**
 * Get the triangle which this ray intersects. Returns null if no triangle is intersected.
 *
 * @param ray
 * @param distance
 * @param allowedMeshParts
 * @return
 */
public Triangle rayTest(Ray ray, float distance, Bits allowedMeshParts) {
	Triangle hitTriangle = null;

	tmpRayTestRayFrom.set(ray.origin);
	tmpRayTestRayTo.set(ray.direction).scl(distance).add(tmpRayTestRayFrom);
	raycastCallback.setHitFraction(1);
	raycastCallback.clearReport();
	raycastCallback.setFrom(tmpRayTestRayFrom);
	raycastCallback.setTo(tmpRayTestRayTo);
	raycastCallback.setAllowedMeshPartIndices(allowedMeshParts);
	collisionShape.performRaycast(raycastCallback, tmpRayTestRayFrom, tmpRayTestRayTo);

	if (raycastCallback.triangleIndex != -1) {
		hitTriangle = graph.getTriangleFromMeshPart(raycastCallback.partId, raycastCallback.triangleIndex);
	}
	return hitTriangle;
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:26,代码来源:NavMesh.java

示例7: verticalRayTest

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
/**
 * Make a ray test at this point, using a ray spanning from far up in the sky, to far down in the ground,
 * along the up axis.
 *
 * @param testPoint        The test point
 * @param out              The point of intersection between ray and triangle
 * @param allowedMeshParts Which mesh parts to test. Null if all meshparts should be tested.
 * @return The triangle, or null if ray did not hit any triangles.
 */
public Triangle verticalRayTest(Vector3 testPoint, Vector3 out, Bits allowedMeshParts) {
	tmpRayVerticalRayTest.set(
			tmpVerticalRayTest1.set(Constants.V3_UP).scl(500).add(testPoint),
			tmpVerticalRayTest2.set(Constants.V3_DOWN));
	Triangle hitTri = rayTest(tmpRayVerticalRayTest, 1000, allowedMeshParts);
	if (hitTri == null) {
		// TODO: Perhaps this should be Nan?
		out.set(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY);
		return null;
	} else {

		Intersector.intersectRayTriangle(tmpRayVerticalRayTest, hitTri.a, hitTri.b, hitTri.c, out);
		return hitTri;
	}
}
 
开发者ID:jsjolund,项目名称:GdxDemo3D,代码行数:25,代码来源:NavMesh.java

示例8: matches

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
/**
 * @return Whether the entity matches the family requirements or not
 */
public boolean matches(Entity entity) {
    Bits entityComponentBits = entity.getComponentBits();

    if (entityComponentBits.isEmpty())
        return false;

    for (int i = all.nextSetBit(0); i >= 0; i = all.nextSetBit(i + 1)) {
        if (!entityComponentBits.get(i))
            return false;
    }

    if (!one.isEmpty() && !one.intersects(entityComponentBits)) {
        return false;
    }

    if (!exclude.isEmpty() && exclude.intersects(entityComponentBits)) {
        return false;
    }

    return true;
}
 
开发者ID:grum,项目名称:Ashley,代码行数:25,代码来源:Family.java

示例9: getBitsFor

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
/**
 * @param componentTypes list of {@link Component} classes
 * @return Bits representing the collection of components for quick comparison and matching. See
 *         {@link Family#getFor(Bits, Bits, Bits)}.
 */
public static Bits getBitsFor (Class<? extends Component>... componentTypes) {
	Bits bits = new Bits();

	int typesLength = componentTypes.length;
	for (int i = 0; i < typesLength; i++) {
		bits.set(ComponentType.getIndexFor(componentTypes[i]));
	}

	return bits;
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:16,代码来源:ComponentType.java

示例10: Family

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
/** Private constructor, use static method Family.getFamilyFor() */
private Family (Bits all, Bits any, Bits exclude) {
	this.all = all;
	this.one = any;
	this.exclude = exclude;
	this.index = familyIndex++;
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:8,代码来源:Family.java

示例11: getFamilyHash

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
private static String getFamilyHash (Bits all, Bits one, Bits exclude) {
	StringBuilder stringBuilder = new StringBuilder();
	if (!all.isEmpty()) {
		stringBuilder.append("{all:").append(getBitsString(all)).append("}");
	}
	if (!one.isEmpty()) {
		stringBuilder.append("{one:").append(getBitsString(one)).append("}");
	}
	if (!exclude.isEmpty()) {
		stringBuilder.append("{exclude:").append(getBitsString(exclude)).append("}");
	}
	return stringBuilder.toString();
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:14,代码来源:Family.java

示例12: getBitsString

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
private static String getBitsString (Bits bits) {
	StringBuilder stringBuilder = new StringBuilder();

	int numBits = bits.length();
	for (int i = 0; i < numBits; ++i) {
		stringBuilder.append(bits.get(i) ? "1" : "0");
	}

	return stringBuilder.toString();
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:11,代码来源:Family.java

示例13: Entity

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
/** Creates an empty Entity. */
public Entity () {
	components = new Bag<Component>();
	componentsArray = new Array<Component>(false, 16);
	immutableComponentsArray = new ImmutableArray<Component>(componentsArray);
	componentBits = new Bits();
	familyBits = new Bits();
	flags = 0;

	componentAdded = new Signal<Entity>();
	componentRemoved = new Signal<Entity>();
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:13,代码来源:Entity.java

示例14: addEntityListener

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
public void addEntityListener (Family family, int priority, EntityListener listener) {
	registerFamily(family);

	int insertionIndex = 0;
	while (insertionIndex < entityListeners.size) {
		if (entityListeners.get(insertionIndex).priority <= priority) {
			insertionIndex++;
		} else {
			break;
		}
	}

	// Shift up bitmasks by one step
	for (Bits mask : entityListenerMasks.values()) {
		for (int k = mask.length(); k > insertionIndex; k--) {
			if (mask.get(k - 1)) {
				mask.set(k);
			} else {
				mask.clear(k);
			}
		}
		mask.clear(insertionIndex);
	}

	entityListenerMasks.get(family).set(insertionIndex);

	EntityListenerData entityListenerData = new EntityListenerData();
	entityListenerData.listener = listener;
	entityListenerData.priority = priority;
	entityListeners.insert(insertionIndex, entityListenerData);
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:32,代码来源:FamilyManager.java

示例15: addAndRemoveComponent

import com.badlogic.gdx.utils.Bits; //导入依赖的package包/类
@Test
public void addAndRemoveComponent () {
	Entity entity = new Entity();

	entity.add(new ComponentA());

	assertEquals(1, entity.getComponents().size());

	Bits componentBits = entity.getComponentBits();
	int componentAIndex = ComponentType.getIndexFor(ComponentA.class);

	for (int i = 0; i < componentBits.length(); ++i) {
		assertEquals(i == componentAIndex, componentBits.get(i));
	}

	assertNotNull(am.get(entity));
	assertNull(bm.get(entity));
	assertTrue(am.has(entity));
	assertFalse(bm.has(entity));

	entity.remove(ComponentA.class);

	assertEquals(0, entity.getComponents().size());

	for (int i = 0; i < componentBits.length(); ++i) {
		assertFalse(componentBits.get(i));
	}

	assertNull(am.get(entity));
	assertNull(bm.get(entity));
	assertFalse(am.has(entity));
	assertFalse(bm.has(entity));
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:34,代码来源:EntityTests.java


注:本文中的com.badlogic.gdx.utils.Bits类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。