本文整理汇总了Java中com.artemis.utils.IntBag类的典型用法代码示例。如果您正苦于以下问题:Java IntBag类的具体用法?Java IntBag怎么用?Java IntBag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntBag类属于com.artemis.utils包,在下文中一共展示了IntBag类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: killCheapestUnit
import com.artemis.utils.IntBag; //导入依赖的package包/类
public void killCheapestUnit() {
int productivity = 999;
int cheapestId=-1;
IntBag actives = subscription.getEntities();
int[] ids = actives.getData();
for (int i = 0, s = actives.size(); s > i; i++) {
int entity = ids[i];
Minion minion = mMinion.get(entity);
if ( minion.productivity < productivity && !mSchedule.has(entity) )
{
productivity = minion.productivity;
cheapestId = entity;
}
}
if ( cheapestId != -1 )
{
explode(cheapestId);
}
}
开发者ID:DaanVanYperen,项目名称:odb-dynasty,代码行数:23,代码来源:MinionSystem.java
示例2: dispose
import com.artemis.utils.IntBag; //导入依赖的package包/类
@Override
public void dispose() {
physicsInitialized = false;
IntBag entityIds = getEntityIds();
for (int entity : entityIds.getData()) {
RigidBodyComponent bodyComponent = rigidBodyMapper.get(entity);
if (bodyComponent != null) {
bodyComponent.dispose();
}
}
dynamicsWorld.dispose();
constraintSolver.dispose();
collisionConfiguration.dispose();
collisionDispatcher.dispose();
dbvtBroadphase.dispose();
}
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:20,代码来源:PhysicsSystem.java
示例3: toggleHighlightedActors
import com.artemis.utils.IntBag; //导入依赖的package包/类
/**
* toggles highlighted state of actor that is on the same tile as the mouse is
* over
*/
private boolean toggleHighlightedActors() {
boolean toggled = false;
@SuppressWarnings("unchecked")
final EntitySubscription entitySubscription = GameEngine.getInstance().getAspectSubscriptionManager()
.get(Aspect.all(PositionComponent.class, HighlightAbleComponent.class)
.exclude(CursorComponent.class));
final IntBag entities = entitySubscription.getEntities();
PositionComponent positionComponent;
HighlightAbleComponent highlight;
for (int i = 0; i < entities.size(); i++) {
positionComponent = ComponentMappers.getInstance().position.get(i);
if (positionComponent.getX() == mouseOverX && positionComponent.getY() == mouseOverY) {
highlight = ComponentMappers.getInstance().highlight.get(i);
highlight.toggleHighlighted();
toggled = true;
}
}
return toggled;
}
开发者ID:davidbecker,项目名称:taloonerrl,代码行数:24,代码来源:InputSystem.java
示例4: processTurnTaken
import com.artemis.utils.IntBag; //导入依赖的package包/类
/**
* checks if all entities have their turn taken for the current turn
*
* @param _currentTurnSide
*/
private void processTurnTaken() {
if (checkReadyToSwitchTurns()) {
// reset turn components
final IntBag entities = getAspectSubscriptionManager().get(Aspect.all(TurnComponent.class))
.getEntities();
TurnComponent turnComponent;
for (int i = 0; i < entities.size(); i++) {
turnComponent = ComponentMappers.getInstance().turn.get(entities.get(i));
if (turnComponent.getMovesOnTurn() == currentTurnSide) {
turnComponent.setTurnTaken(false);
turnComponent.setProcessed(false);
}
}
// switch sides
currentTurnSide = currentTurnSide == ETurnType.PLAYER ? ETurnType.MONSTER : ETurnType.PLAYER;
Gdx.app.debug("GameEngine", "switching turn sides to " + ETurnType.toString(currentTurnSide));
}
}
开发者ID:davidbecker,项目名称:taloonerrl,代码行数:24,代码来源:GameEngine.java
示例5: getEntities
import com.artemis.utils.IntBag; //导入依赖的package包/类
/**
* Returns all entities in the specified cells.
*
* @param cells set of packed coordinates of entities
* @return
*/
public IntBag getEntities(final LongBag cells)
{
final IntBag entities = new IntBag(8);
final int[] coords = new int[2];
for (int i = 0, size = cells.size(); i < size; i++)
{
final long pos = cells.get(i);
Coords.unpackCoords(pos, coords);
final int id = grid[coords[0]][coords[1]];
if (id >= 0)
entities.add(id);
}
return entities;
}
开发者ID:fabio-t,项目名称:alone-rl,代码行数:27,代码来源:SingleGrid.java
示例6: display
import com.artemis.utils.IntBag; //导入依赖的package包/类
@Override
public void display(final AsciiPanel terminal)
{
final int playerId = pManager.getEntitiesOfPlayer("player").get(0).getId();
terminal.clear(' ');
drawHeader(terminal);
final Inventory inv = mInventory.get(playerId);
final ArrayList<String> elements = new ArrayList<>();
final IntBag items = inv.items;
for (int i = 0, size = items.size(); i < size; i++)
{
final int itemId = items.get(i);
if (!canDraw(itemId))
continue;
elements
.add(String.format("%s %s", mName.get(itemId).name.toLowerCase(), mEquip.has(itemId) ? " [WORN]" : ""));
}
drawList(terminal, elements);
}
开发者ID:fabio-t,项目名称:alone-rl,代码行数:27,代码来源:InventoryScreen.java
示例7: createGroup
import com.artemis.utils.IntBag; //导入依赖的package包/类
/**
* Creates a new, empty group.
*
* @return the id of the group
*/
public int createGroup()
{
final IntBag newGroup = new IntBag(5);
final int newId;
if (recycling.isEmpty())
{
newId = groups.size();
}
else
{
newId = recycling.popFirst();
}
groups.set(newId, newGroup);
return newId;
}
开发者ID:fabio-t,项目名称:alone-rl,代码行数:24,代码来源:GroupSystem.java
示例8: unsubscribe
import com.artemis.utils.IntBag; //导入依赖的package包/类
/**
* Unsubscribe T from entity.
*
* @param subscriber subscriber
* @param entityId entity to subscribe
*/
public void unsubscribe(T subscriber, int entityId) {
// unhook entity from subscriber
IntBag entities = subscriberEntities.get(subscriber);
if (entities != null) {
int index = entities.indexOf(entityId);
if ( index != -1 ) {
entities.remove(index);
}
}
// unhook subscriber from entity.
Bag<T> subscribers = entitySubscribers.get(entityId);
if (subscribers != null) {
subscribers.remove(subscriber);
}
}
开发者ID:DaanVanYperen,项目名称:artemis-odb-contrib,代码行数:24,代码来源:SubscriptionManager.java
示例9: getExact
import com.artemis.utils.IntBag; //导入依赖的package包/类
/**
* Returns entity ids of entities that bounds contain given point
*/
public IntBag getExact (IntBag fill, float x, float y) {
if (bounds.contains(x, y)) {
if (nodes[0] != null) {
int index = indexOf(x, y, 0, 0);
if (index != OUTSIDE) {
nodes[index].getExact(fill, x, y, 0, 0);
}
}
for (int i = 0; i < containers.size(); i++) {
Container c = containers.get(i);
if (c.contains(x, y)) {
fill.add(c.eid);
}
}
}
return fill;
}
开发者ID:DaanVanYperen,项目名称:artemis-odb-contrib,代码行数:21,代码来源:QuadTree.java
示例10: get
import com.artemis.utils.IntBag; //导入依赖的package包/类
/**
* Returns entity ids of entities that are inside {@link QuadTree}s that overlap given bounds
*
* Returned entities must be filtered further as these results are not exact
*/
public IntBag get (IntBag fill, float x, float y, float width, float height) {
if (bounds.overlaps(x, y, width, height)) {
if (nodes[0] != null) {
int index = indexOf(x, y, width, height);
if (index != OUTSIDE) {
nodes[index].get(fill, x, y, width, height);
} else {
// if test bounds don't fully fit inside a node, we need to check them all
for (int i = 0; i < nodes.length; i++) {
nodes[i].get(fill, x, y, width, height);
}
}
}
for (int i = 0; i < containers.size(); i++) {
Container c = containers.get(i);
fill.add(c.eid);
}
}
return fill;
}
开发者ID:DaanVanYperen,项目名称:artemis-odb-contrib,代码行数:26,代码来源:QuadTree.java
示例11: processSystem
import com.artemis.utils.IntBag; //导入依赖的package包/类
@Override
protected void processSystem() {
final IntBag entities = subscription.getEntities();
final int processedPerSecond = (int) ((entities.size() / getRoundTripTime()));
// Depending on subscription size invocation could potentially require less than
// one invocation. Keep track of 'partial' invocations until we can invoke.
entitiesToProcess += processedPerSecond * getWorldDelta();
if (entitiesToProcess >= 1f) {
processEntities((int) entitiesToProcess, entities.getData(), entities.size());
// keep remainder.
entitiesToProcess -= (int) entitiesToProcess;
}
}
开发者ID:DaanVanYperen,项目名称:artemis-odb-contrib,代码行数:18,代码来源:SpreadProcessingSystem.java
示例12: processSystem
import com.artemis.utils.IntBag; //导入依赖的package包/类
/**
* Iterate over all entities.
*
* Stop when allotted time has passed.
* Stop when all entities have been cycled.
*/
@Override
protected final void processSystem() {
final IntBag actives = subscription.getEntities();
final int[] array = actives.getData();
final int size = actives.size();
int processed = 0;
if ( size > 0 ) {
long time = getTime();
final long deadline = time + (long) (getAllottedTime() * MILLISECONDS_PER_SECOND);
index = index % size; // avoid breakage upon subscription changes.
while ((processed < size) && (time < deadline)) {
lastProcessedEntityId = array[index];
process(lastProcessedEntityId);
index = ++index % size;
processed++;
time = getTime();
}
}
processedEntities = processed;
}
开发者ID:DaanVanYperen,项目名称:artemis-odb-contrib,代码行数:31,代码来源:TimeboxedProcessingSystem.java
示例13: complex_get_test
import com.artemis.utils.IntBag; //导入依赖的package包/类
@Test
public void complex_get_test() {
IntBag fill = new IntBag();
QuadTree.MAX_IN_BUCKET = 1;
QuadTree tree = new QuadTree(-8, -8, 8, 8);
fill.clear();
tree.get(fill, -3, -3, 6, 6);
Assert.assertEquals(fill.size(), 0);
// all outside
tree.insert(1, -6, -6, 2, 2);
tree.insert(2, 4, -6, 2, 2);
tree.insert(3, -6, 4, 2, 2);
tree.insert(4, 4, 4, 2, 2);
tree.insert(5, -1, -1, 2, 2); // cemter
tree.insert(6, -4, -4, 2, 2); // fully inside
tree.insert(7, 2, 2, 2, 2); // fully inside
tree.insert(8, -4, -4, 2, 2); // fully inside
}
开发者ID:DaanVanYperen,项目名称:artemis-odb-contrib,代码行数:22,代码来源:QuadTreeTest.java
示例14: reloadFonts
import com.artemis.utils.IntBag; //导入依赖的package包/类
public void reloadFonts (boolean reloadBmpFonts, boolean reloadTtfFonts) {
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);
VisText text = textCm.get(entity);
VisAssetDescriptor asset = assetCm.get(entity).asset;
if (asset instanceof BmpFontAsset && reloadBmpFonts)
text.setFont(fontCache.get((BmpFontAsset) asset, pixelInUnits));
if (asset instanceof TtfFontAsset && reloadTtfFonts)
text.setFont(fontCache.get((TtfFontAsset) asset, pixelInUnits));
}
}
开发者ID:kotcrab,项目名称:vis-editor,代码行数:19,代码来源:FontReloaderManager.java
示例15: reloadTextures
import com.artemis.utils.IntBag; //导入依赖的package包/类
public void reloadTextures () {
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);
VisSprite sprite = spriteCm.get(entity);
VisAssetDescriptor asset = assetCm.get(entity).asset;
boolean flipX = sprite.isFlipX();
boolean flipY = sprite.isFlipY();
sprite.setRegion(textureCache.getRegion(asset));
sprite.setFlip(flipX, flipY);
}
}
开发者ID:kotcrab,项目名称:vis-editor,代码行数:18,代码来源:TextureReloaderManager.java
示例16: reloadParticles
import com.artemis.utils.IntBag; //导入依赖的package包/类
public void reloadParticles () {
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);
VisParticle particle = particleCm.get(entity);
VisAssetDescriptor asset = assetCm.get(entity).asset;
particle.getEffect().dispose();
particle.setEffect(particleCache.get(asset, 1f / pixelsPerUnit));
transformCm.get(entity).setDirty(true);
}
}
开发者ID:kotcrab,项目名称:vis-editor,代码行数:18,代码来源:ParticleReloaderManager.java
示例17: getEntitiesWithLayer
import com.artemis.utils.IntBag; //导入依赖的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;
}
开发者ID:kotcrab,项目名称:vis-editor,代码行数:18,代码来源:LayerManipulator.java
示例18: swapLayers
import com.artemis.utils.IntBag; //导入依赖的package包/类
/**
* Swaps layers id in entities. This SHOULD NOT be used directly because it does not update internal layer structure
* in {@link EditorScene}. Layers order is managed by {@link LayersDialog}
*/
public void swapLayers (int id1, int id2) {
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 == id1) layer.layerId = id2;
else if (layer.layerId == id2) layer.layerId = id1;
}
renderBatchingSystem.markDirty();
}
开发者ID:kotcrab,项目名称:vis-editor,代码行数:20,代码来源:LayerManipulator.java
示例19: reloadSpriterData
import com.artemis.utils.IntBag; //导入依赖的package包/类
public void reloadSpriterData () {
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);
VisSpriter spriter = spriterCm.get(entity);
SpriterAsset asset = (SpriterAsset) assetCm.get(entity).asset;
VisSpriter newSpriter = spriterCache.cloneComponent(asset, spriter);
entity.edit().remove(spriter).add(newSpriter);
transformCm.get(entity).setDirty(true);
//we've replaced SpriterComponent in entity so proxy needs manual reloading
entityProxyCache.get(entity).reload();
}
spriterCache.disposeOldLoaders();
}
开发者ID:kotcrab,项目名称:vis-editor,代码行数:22,代码来源:SpriterReloaderManager.java
示例20: processSystem
import com.artemis.utils.IntBag; //导入依赖的package包/类
/**
* Updates the {@link #stateTime}.
*/
@Override
protected void processSystem() {
if (stateTime == Float.MAX_VALUE)
stateTime = 0;
stateTime += getWorld().getDelta();
IntBag actives = subscription.getEntities();
int[] ids = actives.getData();
for (int i = 0, s = actives.size(); s > i; i++) {
process(ids[i]);
}
}
开发者ID:EtherWorks,项目名称:arcadelegends-gg,代码行数:15,代码来源:RenderSystem.java
注:本文中的com.artemis.utils.IntBag类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论