Example usage for com.badlogic.gdx.utils IntArray get

List of usage examples for com.badlogic.gdx.utils IntArray get

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils IntArray get.

Prototype

public int get(int index) 

Source Link

Usage

From source file:com.badlogic.gdx.ai.tests.BehaviorTreeViewer.java

License:Apache License

private void addToTree(Tree displayTree, TaskNode parentNode, Task<Dog> task, IntArray taskSteps,
        int taskStepIndex) {
    TaskNode node = new TaskNode(task, taskSteps == null ? step - 1 : taskSteps.get(taskStepIndex), skin);
    taskNodes.put(task, node);//from  w  w w  . j  av a  2s . com
    if (parentNode == null) {
        displayTree.add(node);
    } else {
        parentNode.add(node);
    }
    for (int i = 0; i < task.getChildCount(); i++) {
        Task<Dog> child = task.getChild(i);
        addToTree(displayTree, node, child, taskSteps, taskStepIndex + 1);
    }
}

From source file:com.badlogic.gdx.ai.tests.btree.BehaviorTreeViewer.java

License:Apache License

private int addToTree(Tree displayTree, TaskNode parentNode, Task<E> task, IntArray taskSteps,
        int taskStepIndex) {
    TaskNode node = new TaskNode(task, this, taskSteps == null ? step - 1 : taskSteps.get(taskStepIndex),
            getSkin());/*from  ww  w  .j av  a  2 s  .  c o m*/
    taskNodes.put(task, node);
    if (parentNode == null) {
        displayTree.add(node);
    } else {
        parentNode.add(node);
    }
    taskStepIndex++;
    for (int i = 0; i < task.getChildCount(); i++) {
        Task<E> child = task.getChild(i);
        taskStepIndex = addToTree(displayTree, node, child, taskSteps, taskStepIndex);
    }
    return taskStepIndex;
}

From source file:com.badlydrawngames.veryangryrobots.RoomBuilder.java

License:Apache License

private Rectangle createWall(IntArray wallDefs, int i) {
    int x1 = wallDefs.get(i);
    int y1 = wallDefs.get(i + 1);
    int x2 = wallDefs.get(i + 2);
    int y2 = wallDefs.get(i + 3);
    return (x1 == x2) ? createVWall(x1, y1, y2) : createHWall(x1, x2, y1);
}

From source file:com.badlydrawngames.veryangryrobots.RoomBuilder.java

License:Apache License

private Rectangle createDoor(IntArray doorDefs, int i) {
    int x1 = doorDefs.get(i);
    int y1 = doorDefs.get(i + 1);
    int x2 = doorDefs.get(i + 2);
    return (x1 == x2) ? createVDoor(x1, y1) : createHDoor(x1, y1);
}

From source file:com.github.antag99.retinazer.Mapper.java

License:Open Source License

void flushComponentRemoval() {
    final Bag<T> components = this.components;
    final IntArray remove = this.remove;
    final Mask componentsMask = this.componentsMask;
    final Mask removeMask = this.removeMask;
    final int removeCount = this.removeCount;

    final Pool<T> pool = this.componentPool;
    if (pool == null) {
        //Version for standard components
        for (int i = 0; i < removeCount; i++) {
            final int entity = remove.get(i);
            components.remove(entity);// w  w w.  java 2 s.co m
            componentsMask.clear(entity);
            removeMask.clear(entity);
        }
    } else {
        //Version for pooled components
        for (int i = 0; i < removeCount; i++) {
            final int entity = remove.get(i);

            final T component = components.remove(entity);
            if (component != null)
                pool.free(component);

            componentsMask.clear(entity);
            removeMask.clear(entity);
        }
    }

    if (removeCount > 0)
        remove.removeRange(0, removeCount - 1);
}

From source file:com.kotcrab.vis.editor.proxy.EntityProxy.java

License:Apache License

public int getGroupIdBefore(int gid) {
    IntArray groupIds = getGroupComponent().groupIds;
    int index = groupIds.indexOf(gid) - 1;
    if (gid == -1)
        return groupIds.peek();

    if (index < 0)
        return -1;
    else/*  www .j  av a 2  s  . c  o  m*/
        return groupIds.get(index);
}

From source file:com.kotcrab.vis.editor.proxy.EntityProxy.java

License:Apache License

public int getGroupIdAfter(int gid) {
    IntArray groupIds = getGroupComponent().groupIds;
    int index = groupIds.indexOf(gid) + 1;
    if (gid == -1)
        return groupIds.peek();

    if (index >= groupIds.size)
        return -1;
    else/*from   w  ww.java  2 s.  c o m*/
        return groupIds.get(index);
}

From source file:com.kotcrab.vis.editor.serializer.cloner.IntArrayCloner.java

License:Apache License

@Override
protected IntArray cloneObject(IntArray original, IDeepCloner cloner, Map<Object, Object> clones) {
    IntArray array = new IntArray(original.size);

    for (int i = 0; i < original.size; i++)
        array.add(original.get(i));

    return array;
}

From source file:com.kotcrab.vis.editor.serializer.json.IntArrayJsonSerializer.java

License:Apache License

@Override
public JsonElement serialize(IntArray intArray, Type typeOfSrc, JsonSerializationContext context) {
    JsonArray json = new JsonArray();

    for (int i = 0; i < intArray.size; i++) {
        json.add(new JsonPrimitive(intArray.get(i)));
    }/*from   w w  w.  ja  v  a  2s .  c  o m*/

    return json;
}

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 www  .j  a  va 2  s . c  om
        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);
                    }
                }
            }
        }
    });
}