List of usage examples for com.badlogic.gdx.utils ObjectSet addAll
public void addAll(ObjectSet<T> set)
From source file:com.github.antag99.retinazer.FamilyConfig.java
License:Open Source License
@SafeVarargs public final FamilyConfig with(Class<? extends Component>... componentTypes) { ObjectSet<Class<? extends Component>> newComponents = new ObjectSet<>(); newComponents.addAll(components); for (Class<? extends Component> componentType : componentTypes) { if (newComponents.contains(componentType)) throw new IllegalArgumentException(componentType.getName()); if (excludedComponents.contains(componentType)) throw new IllegalArgumentException(componentType.getName()); newComponents.add(componentType); }/* w w w .j a v a 2 s . c o m*/ this.components = newComponents; return this; }
From source file:com.github.antag99.retinazer.FamilyConfig.java
License:Open Source License
@SafeVarargs public final FamilyConfig exclude(Class<? extends Component>... componentTypes) { ObjectSet<Class<? extends Component>> newExcludedComponents = new ObjectSet<>(); newExcludedComponents.addAll(excludedComponents); for (Class<? extends Component> componentType : componentTypes) { if (newExcludedComponents.contains(componentType)) throw new IllegalArgumentException(componentType.getName()); if (components.contains(componentType)) throw new IllegalArgumentException(componentType.getName()); newExcludedComponents.add(componentType); }/* w w w . j a v a2 s . c o m*/ this.excludedComponents = newExcludedComponents; return this; }
From source file:com.vlaaad.dice.game.world.behaviours.processors.user.UserTurnProcessor.java
License:Open Source License
@Override public IFuture<TurnResponse> process(final TurnParams params) { final Future<TurnResponse> future = new Future<TurnResponse>(); final World world = params.creature.world; this.world = world; final Creature creature = params.creature; final UiController ui = world.getController(UiController.class); final ObjectSet<Grid2D.Coordinate> available = new ObjectSet<Grid2D.Coordinate>(); available.addAll(params.availableCells); clickListener = new ClickListener() { @Override/* w ww .ja v a 2s .c om*/ public void clicked(InputEvent event, float x, float y) { if (event.isCancelled()) return; Vector2 c = world.getController(ViewController.class) .stageToWorldCoordinates(new Vector2(event.getStageX(), event.getStageY())); final Grid2D.Coordinate coordinate = new Grid2D.Coordinate((int) c.x, (int) c.y); if (available.contains(coordinate)) { world.stage.removeListener(this); final ClickListener mainListener = this; confirm = new Image(Config.skin, "selection/turn-confirmation"); back = new Tile("selection/turn-confirmation-background"); confirm.setPosition(coordinate.x() * ViewController.CELL_SIZE, coordinate.y() * ViewController.CELL_SIZE); back.setPosition(confirm.getX(), confirm.getY()); world.getController(ViewController.class).notificationLayer.addActor(confirm); world.getController(ViewController.class).selectionLayer.addActor(back); confirmListener = new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (event.isCancelled()) return; Vector2 cell = world.getController(ViewController.class) .stageToWorldCoordinates(new Vector2(event.getStageX(), event.getStageY())); confirm.remove(); back.remove(); world.stage.removeListener(this); if (coordinate.x() == (int) cell.x && coordinate.y() == (int) cell.y) { UserTurnProcessor.this.cancel(); future.happen(new TurnResponse<Grid2D.Coordinate>(TurnResponse.TurnAction.MOVE, coordinate)); } else { world.stage.addListener(mainListener); mainListener.clicked(event, x, y); } } }; world.stage.addListener(confirmListener); } } }; world.stage.addListener(clickListener); Array<Ability> professionAbilities = creature.description.profession .getAvailableAbilities(creature.getCurrentLevel()); boolean professionTutorial = false; if (professionAbilities.size > 0) { for (Ability ability : professionAbilities) { ProfessionAbilityIcon icon = ui.getProfessionIcon(ability); icon.addListener(createListener(ability, creature, clickListener, world, future)); } if (!world.viewer.tutorialProvider.isProfessionAbilitiesTutorialCompleted()) { professionTutorial = true; Tutorial.whenAllTutorialsEnded(new Runnable() { @Override public void run() { Tutorial.TutorialResources resources = Tutorial.resources() .with("tutorial-provider", world.viewer.tutorialProvider).with("world", world) .with("stage", world.stage); new Tutorial(resources, DiceTutorial.professionAbilitiesTasks()).start(); } }); } } if (!professionTutorial && !world.viewer.tutorialProvider.isPlayPotionsTutorialCompleted() && world.viewer.hasPotions()) { Tutorial.whenAllTutorialsEnded(new Runnable() { @Override public void run() { Tutorial.TutorialResources resources = Tutorial.resources() .with("tutorial-provider", world.viewer.tutorialProvider).with("world", world) .with("stage", world.stage); new Tutorial(resources, DiceTutorial.playPotionsTasks()).start(); } }); } if (ui != null) { ui.potionsButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { new PotionsPlayWindow() .show(new PotionsPlayWindow.Params(creature, world, new PotionsPlayWindow.Callback() { @Override public void usePotion(Ability potion, Potion.ActionType action) { UserTurnProcessor.this.cancel(); future.happen(new TurnResponse<Tuple2<Ability, Potion.ActionType>>( TurnResponse.TurnAction.POTION, Tuple2.make(potion, action))); } })); } }); } return future; }
From source file:com.vlaaad.dice.game.world.controllers.SpawnController.java
License:Open Source License
@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);/*from w ww. j a va 2 s .co m*/ } 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); }
From source file:com.vlaaad.dice.game.world.util.DistanceFiller.java
License:Open Source License
private static Result recursive(World world, Creature creature, Creature.CreatureRelation relation, ObjectSet<Coordinate> checked, ObjectSet<Coordinate> toCheck, int depth) { if (toCheck.size == 0) { cleanUp();/* w w w . j a va 2 s . co m*/ return result.set(-1, -1, -1); } for (Coordinate coordinate : toCheck) { checked.add(coordinate); WorldObject object = world.get(coordinate.x, coordinate.y); if (object instanceof Creature) { Creature check = (Creature) object; if (creature.inRelation(relation, check)) { cleanUp(); return result.set(depth, coordinate.x, coordinate.y); } } } ObjectSet<Coordinate> toFill = tmp3; toFill.clear(); toFill.addAll(toCheck); toCheck.clear(); for (Coordinate coordinate : toFill) { addNeighbours(world, coordinate.x, coordinate.y, checked, toCheck); } return recursive(world, creature, relation, checked, toCheck, depth + 1); }
From source file:com.vlaaad.dice.game.world.util.DistanceFiller.java
License:Open Source License
private static Result recursive(World world, Creature target, ObjectSet<Coordinate> checked, ObjectSet<Coordinate> toCheck, int depth) { if (toCheck.size == 0) { cleanUp();/*from w w w .jav a 2 s .c o m*/ return result.set(-1, -1, -1); } for (Coordinate coordinate : toCheck) { checked.add(coordinate); WorldObject object = world.get(coordinate.x, coordinate.y); if (object instanceof Creature) { Creature creature = (Creature) object; if (creature == target) { cleanUp(); return result.set(depth, coordinate.x, coordinate.y); } } } ObjectSet<Coordinate> toFill = tmp3; toFill.clear(); toFill.addAll(toCheck); toCheck.clear(); for (Coordinate coordinate : toFill) { addNeighbours(world, coordinate.x, coordinate.y, checked, toCheck); } return recursive(world, target, checked, toCheck, depth + 1); }
From source file:com.vlaaad.dice.services.GameServicesMultiplayer.java
License:Open Source License
@SuppressWarnings("unchecked") public void loadInvitations(InvitationBuffer invitations) { ObjectSet<String> tmp = Pools.obtain(ObjectSet.class); tmp.addAll(invites); invites.clear();/*from ww w. j av a 2 s . c om*/ 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); } }); }