Example usage for com.badlogic.gdx.utils Array removeValue

List of usage examples for com.badlogic.gdx.utils Array removeValue

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils Array removeValue.

Prototype

public boolean removeValue(T value, boolean identity) 

Source Link

Document

Removes the first instance of the specified value in the array.

Usage

From source file:com.kotcrab.vis.runtime.system.VisGroupManager.java

License:Apache License

@Override
protected void initialize() {
    EntitySubscription subscription = subscriptionManager.get(Aspect.all(VisGroup.class));

    subscription.addSubscriptionListener(new SubscriptionListener() {
        @Override//from  ww  w  . j  a v a  2s.co m
        public void inserted(IntBag entities) {
            int[] data = entities.getData();
            for (int i = 0; i < entities.size(); i++) {
                int entityId = data[i];

                IntArray groupIds = groupCm.get(entityId).groupIds;

                for (int j = 0; j < groupIds.size; j++) {
                    int gid = groupIds.get(j);

                    Array<Entity> groupList = groups.get(gid);

                    if (groupList == null) {
                        groupList = new Array<Entity>();
                        groups.put(gid, groupList);
                    }

                    groupList.add(world.getEntity(entityId));
                }

            }
        }

        @Override
        public void removed(IntBag entities) {
            int[] data = entities.getData();
            for (int i = 0; i < entities.size(); i++) {
                int entityId = data[i];

                IntArray groupIds = groupCm.get(entityId).groupIds;

                for (int j = 0; j < groupIds.size; j++) {
                    int gid = groupIds.get(j);

                    Array<Entity> groupList = groups.get(gid);
                    groupList.removeValue(world.getEntity(entityId), true);

                    if (groupList.size == 0) {
                        groups.remove(gid);
                    }
                }
            }
        }
    });
}

From source file:com.kotcrab.vis.runtime.system.VisIDManager.java

License:Apache License

@Override
protected void initialize() {
    EntitySubscription subscription = subscriptionManager.get(Aspect.all(VisID.class));

    subscription.addSubscriptionListener(new SubscriptionListener() {
        @Override/*  w  ww .  j a va  2s  .c om*/
        public void inserted(IntBag entities) {
            int[] data = entities.getData();
            for (int i = 0; i < entities.size(); i++) {
                int entityId = data[i];
                String id = idCm.get(entityId).id;

                Array<Entity> idList = idStore.get(id);

                if (idList == null) {
                    idList = new Array<Entity>();
                    idStore.put(id, idList);
                }

                idList.add(world.getEntity(entityId));
            }
        }

        @Override
        public void removed(IntBag entities) {
            int[] data = entities.getData();
            for (int i = 0; i < entities.size(); i++) {
                int entityId = data[i];
                String id = idCm.get(entityId).id;

                Array<Entity> idList = idStore.get(id);
                idList.removeValue(world.getEntity(entityId), true);

                if (idList.size == 0) {
                    idStore.remove(id);
                }
            }
        }
    });
}

From source file:com.mangecailloux.pebble.entity.manager.EntityGroupManager.java

License:Apache License

private void unregisterFromAllGroups(Entity _entity) {

    if (_entity == null)
        throw new IllegalArgumentException("EntityGroupManager::register : _entity cannot be null");

    Array<EntityGroup> groupsForThisEntity = groupsByEntity.remove(_entity);

    if (groupsForThisEntity != null) {
        for (int i = 0; i < groupsForThisEntity.size; ++i) {
            Array<Entity> group = groups.get(groupsForThisEntity.get(i));
            if (group != null) {
                group.removeValue(_entity, true);
            }//from   ww  w .  j ava2  s.  c o m
        }
        entityGroupArrayPool.free(groupsForThisEntity);
    }
}

From source file:com.mangecailloux.pebble.entity.manager.EntityGroupManager.java

License:Apache License

private void unregisterFromGroup(Entity _entity, EntityGroup _group) {
    if (_entity == null)
        throw new IllegalArgumentException("EntityGroupManager::register : _entity cannot be null");

    if (_group == null)
        throw new IllegalArgumentException("EntityGroupManager::register : _group cannot be null");

    Array<Entity> group = groups.get(_group);
    if (group != null) {
        group.removeValue(_entity, true);
    }/*from  w ww.  j  a  v  a2 s.  co  m*/

    Array<EntityGroup> groupsForThisEntity = groupsByEntity.get(_entity);
    if (groupsForThisEntity != null) {
        groupsForThisEntity.removeValue(_group, true);
    }

    if (groupsForThisEntity.size == 0) {
        groupsByEntity.remove(_entity);
        entityGroupArrayPool.free(groupsForThisEntity);
    }
}

From source file:com.mangecailloux.pebble.entity.manager.EntityTagManager.java

License:Apache License

public void removeTag(String _tag) {
    Entity entity = entityByTags.remove(_tag);

    if (entity != null) {
        Array<String> tags = tagsByEntity.get(entity);
        if (tags != null) {
            tags.removeValue(_tag, false);
        }/*from   w w  w .  j ava 2 s .  c o m*/

        if (tags.size == 0) {
            tagsByEntity.remove(entity);
            stringArrayPool.free(tags);
        }
    }

}

From source file:com.ray3k.skincomposer.data.JsonData.java

License:Open Source License

public void deleteStyle(StyleData styleData) {
    Array<StyleData> styles = getClassStyleMap().get(styleData.clazz);
    styles.removeValue(styleData, true);

    //reset any properties pointing to this style to the default style
    if (styleData.clazz.equals(Label.class)) {
        for (StyleData data : getClassStyleMap().get(TextTooltip.class)) {
            StyleProperty property = data.properties.get("label");
            if (property != null && property.value.equals(styleData.name)) {
                property.value = "default";
            }// w w  w  .  j ava  2 s .  c  o m
        }
    } else if (styleData.clazz.equals(List.class)) {
        for (StyleData data : getClassStyleMap().get(SelectBox.class)) {
            StyleProperty property = data.properties.get("listStyle");
            if (property != null && property.value.equals(styleData.name)) {
                property.value = "default";
            }
        }
    } else if (styleData.clazz.equals(ScrollPane.class)) {
        for (StyleData data : getClassStyleMap().get(SelectBox.class)) {
            StyleProperty property = data.properties.get("scrollStyle");
            if (property != null && property.value.equals(styleData.name)) {
                property.value = "default";
            }
        }
    }
}

From source file:com.ridiculousRPG.GameServiceProvider.java

License:Apache License

private <T> void shiftPos(Array<T> array, T service, T ref, int offset) {
    array.removeValue(service, true);
    array.insert(array.indexOf(ref, true) + offset, service);
}

From source file:com.turbogerm.germlibrary.util.GameUtils.java

License:Open Source License

public static Array<Integer> getRandomIndexes(int range, int numberOfIndexes, int offset,
        Array<Integer> excludedIndexes) {

    Array<Integer> selectedList = new Array<Integer>(numberOfIndexes);

    if (numberOfIndexes > 0) {
        Array<Integer> availableList = getRange(range);

        if (excludedIndexes != null) {
            for (Integer excludedIndex : excludedIndexes) {
                availableList.removeValue(excludedIndex, false);
            }//from  w w  w  . ja v a 2s .  com
        }

        for (int i = 0; i < numberOfIndexes; i++) {
            int selectedIndex = MathUtils.random(availableList.size - 1);
            int selected = availableList.get(selectedIndex);
            selectedList.add(selected + offset);
            availableList.removeIndex(selectedIndex);
        }

        selectedList.sort();
    }

    return selectedList;
}

From source file:com.turbogerm.helljump.game.generator.RiseSectionGenerator.java

License:Open Source License

private static int getRandomAvailableOffset(Array<Integer> takenOffsets) {
    Array<Integer> availableOffsets = GameUtils.getRange(PlatformData.MAX_PLATFORM_OFFSET + 1);

    for (Integer takenOffset : takenOffsets) {
        int firstInvalidatedOffset = takenOffset - PlatformData.PLATFORM_WIDTH_OFFSETS + 1;
        int numInvalidatedOffsets = PlatformData.PLATFORM_WIDTH_OFFSETS * 2 - 1;
        int lastInvalidatedOffset = firstInvalidatedOffset + numInvalidatedOffsets - 1;
        for (int i = firstInvalidatedOffset; i <= lastInvalidatedOffset; i++) {
            availableOffsets.removeValue(i, false);
        }/*  w w w. ja  va  2 s . c o  m*/
    }

    return availableOffsets.random();
}

From source file:com.turbogerm.helljump.game.generator.RiseSectionGenerator.java

License:Open Source License

private static Array<ItemData> getScoreItems(int stepRange, Array<PlatformData> platformDataList,
        ItemData powerUpItem) {/*w  w w.  j  a v  a 2  s .c  o  m*/
    Array<ItemData> itemDataList = new Array<ItemData>(true, SCORE_ITEMS_INITIAL_CAPACITY);

    Array<Integer> possibleSteps = GameUtils.getRange(stepRange);
    for (PlatformData platformData : platformDataList) {
        possibleSteps.removeValue(platformData.getStep(), false);
    }

    if (powerUpItem != null) {
        possibleSteps.removeValue((int) powerUpItem.getOffset() + 1, false);
    }

    int lastItemStepIndex = 0;
    while (lastItemStepIndex < possibleSteps.size) {
        int itemStepIndex = lastItemStepIndex + getScoreItemDistancePossibleSteps();
        if (itemStepIndex < possibleSteps.size) {
            ItemData itemData = getRandomScoreItem(possibleSteps.get(itemStepIndex));
            itemDataList.add(itemData);
        }
        lastItemStepIndex = itemStepIndex;
    }

    return itemDataList;
}