Java 类com.badlogic.gdx.utils.ObjectSet 实例源码

项目:Mindustry    文件:KryoClient.java   
@Override
public Array<Host> discover(){
    addresses.clear();
    List<InetAddress> list = client.discoverHosts(Vars.port, 3000);
    ObjectSet<String> hostnames = new ObjectSet<>();
    Array<Host> result = new Array<>();

    for(InetAddress a : list){
        if(!hostnames.contains(a.getHostName())) {
            Host address = addresses.get(a);
            if(address != null) result.add(address);

        }
        hostnames.add(a.getHostName());
    }

    return result;
}
项目:gdx-cclibs    文件:BatchableSorter.java   
/** Add a Batchable to the queue. */
public void add (T batchable) {
    if (batchable.isOpaque()) {
        for (ObjectMap.Entry<T, ObjectSet<T>> entry : opaqueBatchables) {
            if (batchable.hasEquivalentTextures(entry.key)) {
                entry.value.add((T)batchable);
                return;
            }
        }
        ObjectSet<T> set = objectSetPool.obtain();
        set.add(batchable);
        opaqueBatchables.put(batchable, set);
    } else {
        blendedBatchables.add(batchable);
    }
    needSort = true;
}
项目:Undertailor    文件:WorldObject.java   
public WorldObject() {
    this.id = nextId++;
    this.destroyed = false;
    this.boundingQueue = new ObjectSet<>();
    this.def = new BodyDef();
    this.persistent = false;
    this.visible = true;
    this.layer = 0;

    this.def.active = true;
    this.def.awake = true;
    this.def.fixedRotation = true;
    this.def.type = BodyType.DynamicBody;

    this.groupId = -1;
    this.canCollide = true;
    this.events = new EventHelper(this);
}
项目:Undertailor    文件:WorldRoom.java   
public WorldRoom(Tilemap map) {
    this.destroyed = false;
    this.prepared = false;
    this.events = new EventHelper(this);
    this.bodyQueue = new ObjectSet<>();
    this.entrypointQueue = new ObjectSet<>();

    this.tilemap = map;
    this.controller = null;
    this.obj = new ObjectSet<>();
    this.entrypoints = new ObjectMap<>();
    this.opacityMapping = new IntFloatMap();
    this.collisionLayers = new ObjectMap<>();
    this.renderOrder = new Array<>(true, 16);
    this.disabledCollision = new ObjectSet<>();
}
项目:Undertailor    文件:WorldRoom.java   
/**
 * Sets the state of a collision layer.
 * 
 * @param layerName the name of the layer
 * @param flag whether or not the layer is active
 */
public void setCollisionLayerState(String layerName, boolean flag) {
    if (flag != this.getCollisionLayerState(layerName)) {
        if (flag) {
            this.disabledCollision.remove(layerName);
        } else {
            this.disabledCollision.add(layerName);
        }

        ObjectSet<Body> bodies = this.collisionLayers.get(layerName);
        if (bodies != null) {
            bodies.forEach(body -> {
                body.setActive(flag);
            });
        }
    }
}
项目:dice-heroes    文件:ViewController.java   
private void showTileBackgrounds() {
    ObjectSet<Grid2D.Coordinate> processed = new ObjectSet<Grid2D.Coordinate>();
    final ArrayList<Grid2D.Coordinate> list = new ArrayList<Grid2D.Coordinate>(world.level.getCoordinates(tile));
    Collections.sort(list, new Comparator<Grid2D.Coordinate>() {
        @Override public int compare(Grid2D.Coordinate o1, Grid2D.Coordinate o2) {
            return o2.y() - o1.y();
        }
    });
    for (Grid2D.Coordinate coordinate : list) {
        showTileBackground(processed, coordinate.x() - 1, coordinate.y());
        showTileBackground(processed, coordinate.x() + 1, coordinate.y());
        showTileBackground(processed, coordinate.x(), coordinate.y() - 1);
        showTileBackground(processed, coordinate.x(), coordinate.y() + 1);
        showTileBackground(processed, coordinate.x() + 1, coordinate.y() + 1);
        showTileBackground(processed, coordinate.x() - 1, coordinate.y() + 1);
        showTileBackground(processed, coordinate.x() + 1, coordinate.y() - 1);
        showTileBackground(processed, coordinate.x() - 1, coordinate.y() - 1);
        showTransitions(coordinate.x(), coordinate.y());
    }
}
项目:dice-heroes    文件:GameServicesMultiplayer.java   
@SuppressWarnings("unchecked")
public void loadInvitations(InvitationBuffer invitations) {
    ObjectSet<String> tmp = Pools.obtain(ObjectSet.class);
    tmp.addAll(invites);
    invites.clear();
    for (Invitation invitation : invitations) {
        invites.add(invitation.getInvitationId());
        if (!tmp.contains(invitation.getInvitationId())) {
            showInvitation(invitation);
        }
    }
    tmp.clear();
    Pools.free(tmp);
    Gdx.app.postRunnable(new Runnable() {
        @Override public void run() {
            invitesDispatcher.setState(invites.size);
        }
    });
}
项目:dice-heroes    文件:LocalSession.java   
@SuppressWarnings("unchecked")
public LocalSession(final LocalMultiplayer multiplayer, final String otherPlayerId) {
    this.multiplayer = multiplayer;
    this.otherPlayerId = otherPlayerId;
    setVariant(Config.pvpModes.get("global-2").variant);
    me = new IParticipant() {
        @Override public String getDisplayedName() { return multiplayer.participantId; }
        @Override public String getImageUrl() { return "https://pp.vk.me/c307401/v307401067/e8db/rg1r1GJ-dME.jpg"; }
        @Override public String getId() { return multiplayer.participantId; }
        @Override public String toString() { return getId(); }
    };
    other = new IParticipant() {
        @Override public String getDisplayedName() { return otherPlayerId; }
        @Override public String getImageUrl() { return "https://pp.vk.me/c620127/v620127169/11996/5TkNN6HNbPE.jpg"; }
        @Override public String getId() { return otherPlayerId; }
        @Override public String toString() { return getId(); }
    };
    others = ObjectSet.with(other);
    all.put(me.getId(), me);
    all.put(other.getId(), other);
    disconnectFuture().addListener(new IFutureListener() {
        @Override public void onHappened(Object o) {
            multiplayer.sendToServer(ClientServerMessage.Type.endSession);
        }
    });
}
项目:fabulae    文件:FloatingTextRenderer.java   
private void determineTextToDisplay(float delta, ObjectSet<GameLocation> locations) {
    Array<String> texts = chatter != null ? chatter.getTexts(ChatterType.GENERAL, locations) : null;
    if (texts == null || texts.size < 1) {
        currentText = null;
        return;
    }
    stateTime += delta;
    if (stateTime < chatter.getCheckFrequency(ChatterType.GENERAL, locations)) {
        return;
    }
    stateTime = 0;

    if (MathUtils.random(100) > chatter.getChanceToSay(ChatterType.GENERAL, locations)) {
        return;
    }

    setDrawnText(texts.random());
}
项目:fabulae    文件:GameMap.java   
/**
 * Removes the supplied GameObject from this map.
 * 
 * The GO will no longer be rendered.
 * 
 * @param go
 */
public void removeGameObject(GameObject go) {
    gameObjects.removeValue(go, false);
    if (go instanceof Drawable) {
        removeDrawable((Drawable)go);
    }
    if (go instanceof TextDrawer) {
        textDrawers.removeValue((TextDrawer)go, false);
    }
    if (go instanceof TileBlocker) {
        blockers.removeValue((TileBlocker)go, false);
    }
    if (gameObjectsByType.containsKey(go.getType())) {
        gameObjectsByType.get(go.getType()).removeValue(go, false);
    }
    if (gameObjectsByClass.containsKey(go.getClass())) {
        gameObjectsByClass.get(go.getClass()).removeValue(go, false);
    }
    if (gameObjectTileMap != null) {
        for (ObjectSet<GameObject> objects : gameObjectTileMap) {
            objects.remove(go);
        }
    }

}
项目:fabulae    文件:TiledMapObject.java   
public TiledMapObject(MapTileObjectGround ground, int[] objectTiles, GameMap map, Array<TiledMapTileLayer> layers,
        boolean shouldDrawAsAWhole) {
    this.ground = ground;
    alreadySeenTiles = new ObjectSet<Tile>();
    objectTilesVectors = new Array<Tile>();
    for (int i = 0; i < objectTiles.length; i += 2) {
        objectTilesVectors.add(new Tile(objectTiles[i],objectTiles[i+1]));
    }
    this.shouldDrawAsAWhole = shouldDrawAsAWhole;
    this.map = map;
    this.layers = new Array<TiledMapTileLayer>(layers);
    this.position = new Position();
    wasDiscovered = false;
    isVisibleByPC = false;
    fogColor = Color.toFloatBits(Configuration.getFogColor().r,
            Configuration.getFogColor().g, Configuration.getFogColor().b,
            1f);
    visibleColor = Color.toFloatBits(1, 1, 1, 1f);
    notVisibleColor = Color.toFloatBits(0f,0f,0f,1f);
    calculateDimensions();
    removeEmptyLayers();
}
项目:fabulae    文件:AbstractGameCharacter.java   
private void init() {
    // width and height of characters is always one, since they occupy only one tile
    setWidth(1);
    setHeight(1);
    temporaryHostility = new ObjectMap<Faction, Pair<GameCalendarDate, Integer>>();
    s_stateChangeDelay = -1;
    s_newState = null;
    s_noCircle = false;
    s_sightDisabled = false;
    visibleTilesLookupCounter = 1;
    lights = new ObjectMap<LightDescriptor, Light>();
    lightDescriptors = new Array<LightDescriptor>();
    characterCircle = new CharacterCircle(this);
    destinationIndicator = new CharacterCircle(this);
    destinationIndicator.addAction(FadeAction.class, 0.5f, true, 0f, 0.5f);
    visibleArea = new PositionArray();
    viewConeArea = new PositionArray();
    setPlayingAnimation(true);
    tempSet = new ObjectSet<AbstractGameCharacter>();
    tempPosition = new Position();
    brain = createBrain();
}
项目:fabulae    文件:LineOfSight.java   
LineOfSight(RayHandler rayHandler, int rays,
        int distance, float x, float y, GameMap map) {
    start.x = x;
    start.y = y;
    sin = new float[rays];
    cos = new float[rays];
    endX = new float[rays];
    endY = new float[rays];

    visibleShapePolygons = new ObjectSet<Polygon>();

    this.rayHandler = rayHandler;
    setRayNum(rays);
    this.distance = distance < 1 ? 1 : distance;
    tileVertices = new TileSet((distance+1)*2);
    this.map = map;
}
项目:fabulae    文件:Crime.java   
private void determineWitnesses() {
    this.witnesses = new Array<GameCharacter>();
    GameMap map = perpetrator.getMap();
    if (map == null) {
        return;
    }
    int radius = map.isWorldMap() ? Configuration.getSightRadiusWorld() : Configuration.getSightRadiusLocal();
    // make the radius two tiles bigger to account for any rounding errors
    radius += 2;
    PositionArray circle = MathUtil.getCircle(perpetrator.position().tile().getX(), perpetrator.position().tile().getY(), radius, true);
    ObjectSet<GameCharacter> potentialWitnesses = new ObjectSet<GameCharacter>(); 
    map.getAllObjectsInArea(potentialWitnesses, circle, GameCharacter.class);
    Faction victimFaction = getVictimFaction();
    Faction perpFaction = perpetrator.getFaction();
    for (GameObject go : potentialWitnesses) {
        GameCharacter potentialWitness = (GameCharacter) go;
        Faction witnessFaction = potentialWitness.getFaction();
        if (!perpFaction.equals(witnessFaction) && !Faction.areHostile(witnessFaction, victimFaction) && potentialWitness.canSee(perpetrator)) {
            witnesses.add(potentialWitness);
        }
    }
}
项目:fabulae    文件:UsableGameObject.java   
public void setBlockingPath(boolean blockingPath) {
    s_blockingPath = blockingPath;
    if (blockingPath) {
        // any characters will be pushed back when a usable becomes impassable
        ObjectSet<GameObject> chars = getMap().getAllGameObjectsAt(
                0.5f + (int) position.getX(), 0.5f + (int) position.getY(), GameCharacter.class); 
        if (chars.size > 0) {
            Vector2 offset = MathUtil.getVector2();
            findFreeTile(s_orientation, offset);
            for (GameObject character : chars) {
                character.addAction(TweenToAction.class, offset.x, offset.y, 10f);
            }
            MathUtil.freeVector2(offset);
        }
    }
}
项目:fabulae    文件:PlayerCharacterController.java   
private GameObject determineClickedGameObject(Vector2 tileCoordinates) {
    ObjectSet<GameObject> clickedGameObjects = gameState.getCurrentMap().getAllGameObjectsAt(tileCoordinates.x,
            tileCoordinates.y);

    GameObject clickedGameObject = null;
    // we first determine if any characters were clicked on - if so, they
    // have priority
    for (GameObject go : clickedGameObjects) {
        if (go instanceof GameCharacter) {
            clickedGameObject = go;
            break;
        }
    }
    // if no characters were found, just take a random pick
    if (clickedGameObject == null && clickedGameObjects.size > 0) {
        clickedGameObject = clickedGameObjects.iterator().next();
    }
    return clickedGameObject;
}
项目:gdx-lml    文件:DesktopClassScanner.java   
@Override
public Array<Class<?>> findClassesAnnotatedWith(final Class<?> root,
        final Iterable<Class<? extends Annotation>> annotations) {
    final ObjectSet<Class<?>> result = GdxSets.newSet(); // Using set to remove duplicates.
    final FastClasspathScanner scanner = new FastClasspathScanner(root.getPackage().getName(),
            AutumnRoot.class.getPackage().getName());
    for (final Class<? extends Annotation> annotation : annotations) {
        scanner.matchClassesWithAnnotation(annotation, new ClassAnnotationMatchProcessor() {
            @Override
            public void processMatch(final Class<?> matchingClass) {
                result.add(matchingClass);
            }
        });
    }
    scanner.scan();
    return GdxArrays.newArray(result);
}
项目:gdx-autumn-mvc    文件:ObjectSetAssetInjection.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
private void injectAssets(final AssetService assetService) {
    try {
        ObjectSet set = (ObjectSet) Reflection.getFieldValue(field, component);
        if (set == null) {
            set = GdxSets.newSet();
        }
        for (final String assetPath : assetPaths) {
            set.add(assetService.get(assetPath, assetType));
        }
        Reflection.setFieldValue(field, component, set);
    } catch (final ReflectionException exception) {
        throw new GdxRuntimeException("Unable to inject set of assets into component: " + component + ".",
                exception);
    }
}
项目:gdx-autumn-mvc    文件:AssetService.java   
@Override
public void processField(final Field field, final Asset annotation, final Object component, final Context context,
        final ContextInitializer initializer, final ContextDestroyer contextDestroyer) {
    validateAssetData(component, field, annotation);
    if (field.getType().equals(Lazy.class)) {
        handleLazyAssetInjection(component, field, annotation);
    } else if (field.getType().equals(Array.class)) {
        handleArrayInjection(component, field, annotation);
    } else if (field.getType().equals(ObjectSet.class)) {
        handleSetInjection(component, field, annotation);
    } else if (field.getType().equals(ObjectMap.class)) {
        handleMapInjection(component, field, annotation);
    } else {
        handleRegularAssetInjection(component, field, annotation);
    }
}
项目:gdx-lml    文件:TableCellLmlMacroTag.java   
/** This is meant to handle cell attributes that will modify the extracted cell.
 *
 * @param attributes named attributes of the macro.
 * @param processedAttributes already processed attributes. Should be ignored.
 * @param table owner of the cell.
 * @param cell cell of the row. Should have its defaults set. */
protected void processCellAttributes(final ObjectMap<String, String> attributes,
        final ObjectSet<String> processedAttributes, final Table table, final Cell<?> cell) {
    final LmlSyntax syntax = getParser().getSyntax();
    for (final Entry<String, String> attribute : attributes) {
        if (processedAttributes.contains(attribute.key)) {
            continue;
        }
        final LmlAttribute<?> cellAttribute = syntax.getAttributeProcessor(table, attribute.key);
        if (cellAttribute instanceof AbstractCellLmlAttribute) {
            ((AbstractCellLmlAttribute) cellAttribute).process(getParser(), getParent(), table, cell,
                    attribute.value);
        } else {
            if (!isInternalMacroAttribute(attribute.key)) {
                getParser().throwErrorIfStrict(getTagName()
                        + " macro can process only cell attributes. Found unknown or invalid attribute: "
                        + attribute.key);
            }
        }
    }
}
项目:gdx-lml    文件:AbstractActorLmlTag.java   
/**
 * Warning: invoked by the constructor.
 * @return a fully initiated instance of the actor, with its tag attributes processed.
 */
protected Actor prepareActor() {
    final LmlActorBuilder builder = getNewInstanceOfBuilder();
    final ObjectSet<String> processedAttributes = GdxSets.newSet();
    addDefaultAttributes();
    processBuildingAttributes(builder, processedAttributes);
    final Actor actor;
    try {
        actor = getNewInstanceOfActor(builder);
    } catch (final Exception exception) {
        getParser().throwError("Unable to create a new instance of actor with tag: " + getTagName(), exception);
        return null;
    }
    builder.finishBuilding(actor);
    processTagAttributes(processedAttributes, actor, getManagedObject());
    invokeOnCreateActions(actor);
    return actor;
}
项目:gdx-lml    文件:AbstractActorLmlTag.java   
private void processBuildingAttributes(final LmlActorBuilder builder, final ObjectSet<String> processedAttributes) {
    if (getNamedAttributes() == null) {
        return;
    }
    final LmlSyntax syntax = getParser().getSyntax();
    for (final Entry<String, String> attribute : getNamedAttributes()) {
        // Processing building attributes:
        final LmlBuildingAttribute<LmlActorBuilder> buildingAttributeProcessor = syntax
                .getBuildingAttributeProcessor(builder, attribute.key);
        if (buildingAttributeProcessor != null // This is the actual processing method:
                && buildingAttributeProcessor.process(getParser(), this, builder, attribute.value)) {
            // If processing returns true, the attribute is fully parsed and can be omitted during attribute parsing
            // after the actor is initiated. If it returns false, it is expected that the attribute will be
            // eventually parsed by a second processor, after the widget is created.
            processedAttributes.add(attribute.key);
        }
    }
}
项目:gdx-lml    文件:AbstractActorLmlTag.java   
private void processTagAttributes(final ObjectSet<String> processedAttributes, final Actor actor,
        final Object managedObject) {
    if (hasComponentActors() && !Lml.DISABLE_COMPONENT_ACTORS_ATTRIBUTE_PARSING) {
        // Processing own attributes first, ignoring unknowns:
        LmlUtilities.processAttributes(actor, this, getParser(), processedAttributes, false);
        // Processing leftover attributes for component children:
        processComponentAttributes(processedAttributes, actor);
        // Processing leftover attributes, after the widget is fully constructed; not throwing errors for unknown
        // attributes. After we're done with components, we parse original attributes again for meaningful
        // exceptions - "attribute for Window not found" is a lot better than "attribute for Label not found", just
        // because we were parsing Label component of Window last. Continuing even for non-strict parser to ensure
        // the same parsing behavior.
    }
    boolean hasDistinctManagedObject = managedObject != null && managedObject != actor;
    if (hasDistinctManagedObject) {
        // Throws errors if actor is null:
        LmlUtilities.processAttributes(managedObject, this, getParser(), processedAttributes, actor == null);
    }
    if (actor != null) {
        // Processing own attributes. Throwing errors for the unknown attributes:
        LmlUtilities.processAttributes(actor, this, getParser(), processedAttributes, true);
    }
}
项目:gdx-lml    文件:AbstractLmlParser.java   
protected <View> void processLmlActorAnnotation(final View view, final Field field) {
    if (Reflection.isAnnotationPresent(field, LmlActor.class)) {
        final LmlActor actorData = Reflection.getAnnotation(field, LmlActor.class);
        String[] actorIds = actorData.value();
        if (actorIds.length == 0) {
            actorIds = new String[] { field.getName() };
        }
        if (Reflection.isExtending(field.getType(), Array.class)) {
            injectArrayOfActors(view, field, actorIds);
        } else if (Reflection.isExtending(field.getType(), ObjectSet.class)) {
            injectSetOfActors(view, field, actorIds);
        } else if (Reflection.isExtending(field.getType(), ObjectMap.class)) {
            injectMapOfActors(view, field, actorIds);
        } else {
            injectSingleActor(view, field, actorIds);
        }
    }
}
项目:gdx-lml    文件:LmlUtilities.java   
/** Utility method that processes all named attributes of the selected type.
 *
 * @param widget widget (validator, actor - processed element) that will be used to process attributes.
 * @param tag contains attributes.
 * @param parser will be used to parse attributes.
 * @param processedAttributes already processed attribute names. These attributes will be ignored. Optional, can be
 *            null.
 * @param throwExceptionIfAttributeUnknown if true and unknown attribute is found, a strict parser will throw an
 *            exception.
 * @param <Type> type of processed widget. Its class tree will be used to retrieve attributes. */
public static <Type> void processAttributes(final Type widget, final LmlTag tag, final LmlParser parser,
        final ObjectSet<String> processedAttributes, final boolean throwExceptionIfAttributeUnknown) {
    if (GdxMaps.isEmpty(tag.getNamedAttributes())) {
        return;
    }
    final LmlSyntax syntax = parser.getSyntax();
    final boolean hasProcessedAttributes = processedAttributes != null;
    for (final Entry<String, String> attribute : tag.getNamedAttributes()) {
        if (attribute == null || hasProcessedAttributes && processedAttributes.contains(attribute.key)) {
            continue;
        }
        final LmlAttribute<Type> attributeProcessor = syntax.getAttributeProcessor(widget, attribute.key);
        if (attributeProcessor == null) {
            if (throwExceptionIfAttributeUnknown) {
                parser.throwErrorIfStrict("Unknown attribute: \"" + attribute.key + "\" for widget type: "
                        + widget.getClass().getName());
            }
            continue;
        }
        attributeProcessor.process(parser, tag, widget, attribute.value);
        if (hasProcessedAttributes) {
            processedAttributes.add(attribute.key);
        }
    }
}
项目:gdx-lml    文件:ObjectSetAssetInjection.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
private void injectAssets(final AssetService assetService) {
    try {
        ObjectSet set = (ObjectSet) Reflection.getFieldValue(field, component);
        if (set == null) {
            set = GdxSets.newSet();
        }
        for (final String assetPath : assetPaths) {
            set.add(assetService.get(assetPath, assetType));
        }
        Reflection.setFieldValue(field, component, set);
    } catch (final ReflectionException exception) {
        throw new GdxRuntimeException("Unable to inject set of assets into component: " + component + ".",
                exception);
    }
}
项目:gdx-lml    文件:ObjectSetAssetProvider.java   
@Override
public ObjectSet<Object> provide() {
    final ObjectSet<Object> assets = GdxSets.newSet();
    for (final String assetPath : assetPaths) {
        if (loadOnDemand) {
            assets.add(assetService.finishLoading(assetPath, assetClass));
            continue;
        }
        if (!assetService.isLoaded(assetPath)) {
            // LibGDX method that should load a specific asset immediately does pretty much the same.
            assetService.finishLoading();
        }
        assets.add(assetService.get(assetPath, assetClass));
    }
    return assets;
}
项目:gdx-lml    文件:AssetService.java   
@Override
public void processField(final Field field, final Asset annotation, final Object component, final Context context,
        final ContextInitializer initializer, final ContextDestroyer contextDestroyer) {
    validateAssetData(component, field, annotation);
    if (field.getType().equals(Lazy.class)) {
        handleLazyAssetInjection(component, field, annotation);
    } else if (field.getType().equals(Array.class)) {
        handleArrayInjection(component, field, annotation);
    } else if (field.getType().equals(ObjectSet.class)) {
        handleSetInjection(component, field, annotation);
    } else if (field.getType().equals(ObjectMap.class)) {
        handleMapInjection(component, field, annotation);
    } else {
        handleRegularAssetInjection(component, field, annotation);
    }
}
项目:gdx-cclibs    文件:BatchableSorter.java   
public BatchableSorter (Camera camera, int opaqueIntialTextureCapacity, int opaqueInitialCapacityPerTexture,
    int blendedInitialCapacity) {
    this.cameraPosition = camera.position;
    this.opaqueInitialCapacityPerTexture = opaqueInitialCapacityPerTexture;
    opaqueBatchables = new ObjectMap<T, ObjectSet<T>>();
    for (int i = 0; i < opaqueIntialTextureCapacity; i++) { // seed the pool to avoid delay on first use
        objectSetPool.free(objectSetPool.obtain());
    }
    blendedBatchables = new Array<T>(blendedInitialCapacity);
    comparator = new Comparator<T>() {
        public int compare (T o1, T o2) {
            return (int)Math.signum(o2.calculateDistanceSquared(cameraPosition) - o1.calculateDistanceSquared(cameraPosition));
        }
    };
}
项目:gdx-cclibs    文件:BatchableSorter.java   
/** Clear the queue without drawing anything. */
public void clear () {
    for (ObjectSet<T> set : opaqueBatchables.values())
        objectSetPool.free(set);
    opaqueBatchables.clear();
    blendedBatchables.clear();
}
项目:Undertailor    文件:UIController.java   
public UIController(Environment parent, MultiRenderer renderer) {
    this.destroyed = false;
    this.renderer = renderer;
    this.environment = parent;
    this.removed = new ObjectSet<>();
    this.events = new EventHelper(this);
    this.camera = new OrthographicCamera(OverworldController.RENDER_WIDTH,
        OverworldController.RENDER_HEIGHT);
    this.camera.position.x += OverworldController.RENDER_WIDTH / 2F;
    this.camera.position.y += OverworldController.RENDER_HEIGHT / 2F;
    this.camera.update();

    this.aObj = new OrderedMap<>();
    this.bObj = new OrderedMap<>();
}
项目:M-M    文件:SettingsController.java   
/** @return array of serialized display modes' names. */
@LmlAction("displayModes")
public Array<String> getDisplayModes() {
    final ObjectSet<String> alreadyAdded = GdxSets.newSet(); // Removes duplicates.
    final Array<String> displayModes = GdxArrays.newArray(); // Keeps display modes sorted.
    for (final DisplayMode mode : fullscreenService.getDisplayModes()) {
        final String modeName = fullscreenService.serialize(mode);
        if (alreadyAdded.contains(modeName)) {
            continue; // Same size already added.
        }
        displayModes.add(modeName);
        alreadyAdded.add(modeName);
    }
    return displayModes;
}
项目:dice-heroes    文件:SpawnController.java   
@SuppressWarnings("unchecked")
private void autoPlace() {
    if (placed.size > 0) {
        ObjectSet<Creature> tmp = Pools.obtain(ObjectSet.class);
        tmp.addAll(placed);
        for (Creature c : tmp) {
            removeFromPlaced(c);
        }
        tmp.clear();
        Pools.free(tmp);
    }
    Array<Grid2D.Coordinate> coordinates = Pools.obtain(Array.class);
    Set<Map.Entry<Grid2D.Coordinate, Fraction>> spawns = world.level.getElements(LevelElementType.spawn);
    for (Map.Entry<Grid2D.Coordinate, Fraction> e : spawns) {
        if (e.getValue() == world.viewer.fraction) {
            coordinates.add(e.getKey());
        }
    }
    coordinates.shuffle();
    int usedCount = Math.min(creatures.size, coordinates.size);
    Array<Creature> toPlace = Pools.obtain(Array.class);
    toPlace.addAll(creatures);
    toPlace.shuffle();
    toPlace.truncate(usedCount);
    for (Creature creature : toPlace) {
        Grid2D.Coordinate coordinate = coordinates.pop();
        place(creature, coordinate.x(), coordinate.y());
    }
    toPlace.clear();
    coordinates.clear();
    Pools.free(toPlace);
    Pools.free(coordinates);
}
项目:dice-heroes    文件:DistanceFiller.java   
public static int getDistanceToNearCreatureOfRelation(World world, int x, int y, Creature creature, Creature.CreatureRelation relation) {
    if (!world.inBounds(x, y))
        return -1;
    ObjectSet<Coordinate> checked = tmp;
    ObjectSet<Coordinate> toCheck = tmp2;
    addNeighbours(world, x, y, checked, toCheck);
    return recursive(world, creature, relation, checked, toCheck, 1).distance;
}
项目:dice-heroes    文件:DistanceFiller.java   
public static Result getInfoOfNearCreatureOfRelation(World world, int x, int y, Creature creature, Creature.CreatureRelation relation) {
    if (!world.inBounds(x, y))
        return null;
    ObjectSet<Coordinate> checked = tmp;
    ObjectSet<Coordinate> toCheck = tmp2;
    addNeighbours(world, x, y, checked, toCheck);
    recursive(world, creature, relation, checked, toCheck, 1);
    return result;
}
项目:dice-heroes    文件:DistanceFiller.java   
public static Coordinate getCoordinateOfNearCreatureOfRelation(World world, int x, int y, Creature creature, Creature.CreatureRelation relation) {
    if (!world.inBounds(x, y))
        return null;
    ObjectSet<Coordinate> checked = tmp;
    ObjectSet<Coordinate> toCheck = tmp2;
    addNeighbours(world, x, y, checked, toCheck);
    recursive(world, creature, relation, checked, toCheck, 1);
    return result.distance == -1 ? null : Coordinate.obtain(result.position.x, result.position.y);
}
项目:dice-heroes    文件:DistanceFiller.java   
public static int getDistance(Creature from, Creature to) {
    int x = from.getX();
    int y = from.getY();
    World world = from.world;
    if (!world.inBounds(x, y))
        return -1;
    ObjectSet<Coordinate> checked = tmp;
    ObjectSet<Coordinate> toCheck = tmp2;
    addNeighbours(world, x, y, checked, toCheck);
    return recursive(world, to, checked, toCheck, 1).distance;
}
项目:dice-heroes    文件:DistanceFiller.java   
private static void addNeighbours(World world, int x, int y, ObjectSet<Coordinate> checked, ObjectSet<Coordinate> toCheck) {
    addNeighbour(world, x - 1, y - 1, checked, toCheck);
    addNeighbour(world, x - 1, y, checked, toCheck);
    addNeighbour(world, x - 1, y + 1, checked, toCheck);

    addNeighbour(world, x, y - 1, checked, toCheck);
    addNeighbour(world, x, y + 1, checked, toCheck);

    addNeighbour(world, x + 1, y - 1, checked, toCheck);
    addNeighbour(world, x + 1, y, checked, toCheck);
    addNeighbour(world, x + 1, y + 1, checked, toCheck);
}
项目:dice-heroes    文件:DistanceFiller.java   
private static void addNeighbour(World world, int x, int y, ObjectSet<Coordinate> checked, ObjectSet<Coordinate> toCheck) {
    if (!world.inBounds(x, y) || !world.level.exists(LevelElementType.tile, x, y))
        return;
    Coordinate coordinate = Coordinate.obtain(x, y);
    if (checked.contains(coordinate)) {
        coordinate.free();
        return;
    }
    toCheck.add(coordinate);

}
项目:dice-heroes    文件:Achievement.java   
public Achievement(String name, String id, ObjectSet<EventType> eventTypes, AchievementCondition condition, int order) {
    this.name = name;
    this.id = id;
    this.eventTypes = eventTypes;
    this.condition = condition;
    this.order = order;
}