Java Code Examples for com.badlogic.gdx.utils.ObjectMap#put()
The following examples show how to use
com.badlogic.gdx.utils.ObjectMap#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileTracker.java From talos with Apache License 2.0 | 6 votes |
public void addSavedResourcePathsFor (FileTab currentTab, Array<String> savedResourcePaths) { if(savedResourcePaths == null) return; final ObjectMap<FileHandle, FileEntry> entries = new ObjectMap<>(); for (String savedResourcePath : savedResourcePaths) { FileHandle fileHandle = Gdx.files.absolute(savedResourcePath); FileEntry fileEntry = new FileEntry(fileHandle, new Tracker() { @Override public void updated (FileHandle handle) { } }); entries.put(fileHandle, fileEntry); } tabMaps.put(currentTab, entries); }
Example 2
Source File: AnimationControllerHack.java From gdx-gltf with Apache License 2.0 | 6 votes |
private final static void applyNodeAnimationBlending (final NodeAnimation nodeAnim, final ObjectMap<Node, Transform> out, final Pool<Transform> pool, final float alpha, final float time) { final Node node = nodeAnim.node; node.isAnimated = true; final Transform transform = getNodeAnimationTransform(nodeAnim, time); Transform t = out.get(node, null); if (t != null) { if (alpha > 0.999999f) t.set(transform); else t.lerp(transform, alpha); } else { if (alpha > 0.999999f) out.put(node, pool.obtain().set(transform)); else out.put(node, pool.obtain().set(node.translation, node.rotation, node.scale, ((NodePlus)node).weights).lerp(transform, alpha)); } }
Example 3
Source File: ServerMessageListener.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
private void initMatch(PvpPlayState state) { Logger.debug("server: init match "+this.state.session.getMode().name); PvpMode mode = this.state.session.getMode(); LevelDescription level = mode.levels.random(); String levelName = level.name; Array<Fraction> fractions = new Array<Fraction>(level.fractions.size); for (Fraction fraction : level.fractions) { fractions.add(fraction); } Array<String> ids = this.state.session.getAll().keys().toArray(); ids.shuffle(); ObjectMap<String, String> fMap = new ObjectMap<String, String>(); for (int i = 0; i < ids.size; i++) { fMap.put(ids.get(i), fractions.get(i).name); } int seed = MathUtils.random.nextInt(); awaitSpawning(state); sendToAll(new Init(levelName, fMap, seed)); }
Example 4
Source File: ThesaurusLoader.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
@Override public void loadAsync(AssetManager manager, String fileName, FileHandle file, ThesaurusLoader.ThesaurusParameter parameter) { Constructor constructor = new Constructor(ThesaurusData.class); Yaml yaml = new Yaml(constructor); ObjectMap<String, ThesaurusData> data = new ObjectMap<String, ThesaurusData>(); for (Object o : yaml.loadAll(resolve(fileName).read())) { ThesaurusData description = (ThesaurusData) o; data.put(description.key, description); } if (parameter != null && parameter.other.length > 0) { for (String depName : parameter.other) { Thesaurus dep = manager.get(depName); data.putAll(dep.data); } } thesaurus = new Thesaurus(data); }
Example 5
Source File: LevelsLoader.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Levels> parameter) { Yaml yaml = new Yaml(); ObjectMap<String, BaseLevelDescription> data = new ObjectMap<String, BaseLevelDescription>(); for (Object o : yaml.loadAll(resolve(fileName).read())) { HashMap<String, Object> value = (HashMap<String, Object>) o; String type = MapHelper.get(value, "type", "level"); try { BaseLevelDescription desc = types.get(type).getConstructor(Map.class).newInstance(value); data.put(desc.name, desc); } catch (Exception e) { throw new RuntimeException(e); } } levels = new Levels(data); Config.levels = levels; }
Example 6
Source File: BehaviorTreeParser.java From gdx-ai with Apache License 2.0 | 6 votes |
private Metadata findMetadata (Class<?> clazz) { Metadata metadata = metadataCache.get(clazz); if (metadata == null) { Annotation tca = ClassReflection.getAnnotation(clazz, TaskConstraint.class); if (tca != null) { TaskConstraint taskConstraint = tca.getAnnotation(TaskConstraint.class); ObjectMap<String, AttrInfo> taskAttributes = new ObjectMap<String, AttrInfo>(); Field[] fields = ClassReflection.getFields(clazz); for (Field f : fields) { Annotation a = f.getDeclaredAnnotation(TaskAttribute.class); if (a != null) { AttrInfo ai = new AttrInfo(f.getName(), a.getAnnotation(TaskAttribute.class)); taskAttributes.put(ai.name, ai); } } metadata = new Metadata(taskConstraint.minChildren(), taskConstraint.maxChildren(), taskAttributes); metadataCache.put(clazz, metadata); } } return metadata; }
Example 7
Source File: FileTracker.java From talos with Apache License 2.0 | 5 votes |
public void trackFile(FileHandle fileHandle, Tracker tracker) { final FileTab currentTab = TalosMain.Instance().ProjectController().currentTab; if (!tabMaps.containsKey(currentTab)) { tabMaps.put(currentTab, new ObjectMap<>()); } final ObjectMap<FileHandle, FileEntry> entries = tabMaps.get(currentTab); entries.put(fileHandle, new FileEntry(fileHandle, tracker)); }
Example 8
Source File: UAtlasTmxMapLoader.java From uracer-kotd with Apache License 2.0 | 5 votes |
public TiledMap load (String fileName, AtlasTiledMapLoaderParameters parameter) { try { if (parameter != null) { yUp = parameter.yUp; convertObjectToTileSpace = parameter.convertObjectToTileSpace; } else { yUp = true; convertObjectToTileSpace = false; } FileHandle tmxFile = resolve(fileName); root = xml.parse(tmxFile); ObjectMap<String, TextureAtlas> atlases = new ObjectMap<String, TextureAtlas>(); FileHandle atlasFile = loadAtlas(root, tmxFile); if (atlasFile == null) { throw new GdxRuntimeException("Couldn't load atlas"); } TextureAtlas atlas = new TextureAtlas(atlasFile); atlases.put(atlasFile.path(), atlas); AtlasResolver.DirectAtlasResolver atlasResolver = new AtlasResolver.DirectAtlasResolver(atlases); TiledMap map = loadMap(root, tmxFile, atlasResolver, parameter); map.setOwnedResources(atlases.values().toArray()); setTextureFilters(parameter.textureMinFilter, parameter.textureMagFilter); return map; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
Example 9
Source File: PvpPlayState.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
public void prepare(LevelDescription level, ObjectMap<IParticipant, Fraction> fractions, int seed) { if (prepareFuture != null) prepareFuture.happen(); this.level = level; ObjectMap<Fraction, Player> players = new ObjectMap<Fraction, Player>(); Player viewer = null; for (ObjectMap.Entry<IParticipant, Fraction> e : fractions.entries()) { Fraction f = e.value; Player player = new Player(f, level.relations.get(f)); if (e.key == session.getMe()) { viewer = player; } participantsToPlayers.put(e.key, player); playersToParticipants.put(player, e.key); players.put(f, player); } if (viewer == null) throw new IllegalStateException("WTF! viewer is null!"); viewer.setPotions(userData.potions); for (Die die : userData.dice()) { viewer.addDie(die); } world = new World(viewer, players, PlayerHelper.defaultColors, level, stage); world.addController(ViewController.class); world.addController(CreatureInfoController.class); world.init(); world.addController(PvpLoadLevelController.class); world.addController(SpawnController.class); world.addController(new RandomController(world, seed)); world.dispatcher.add(SpawnController.START, new EventListener<Void>() { @Override public void handle(EventType<Void> type, Void aVoid) { world.removeController(SpawnController.class); showPrepareWindow(); listener.sendToServer(new SpawnedToServer(world.viewer)); } }); }
Example 10
Source File: ProfessionsLoader.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Professions> parameter) { Yaml yaml = new Yaml(); ObjectMap<String, ProfessionDescription> data = new ObjectMap<String, ProfessionDescription>(); for (Object o : yaml.loadAll(resolve(fileName).read())) { Map professionData = (Map) o; ProfessionDescription profession = new ProfessionDescription(professionData); data.put(profession.name, profession); } professions = new Professions(data); Config.professions = professions; }
Example 11
Source File: AbilitiesLoader.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Abilities> parameter) { Yaml yaml = new Yaml(); ObjectMap<String, Ability> data = new ObjectMap<String, Ability>(); for (Object o : yaml.loadAll(resolve(fileName).read())) { HashMap<String, Object> value = (HashMap<String, Object>) o; Ability description = new Ability(value); data.put(description.name, description); } abilities = new Abilities(data); Config.abilities = abilities; }
Example 12
Source File: ItemsLoader.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Items> parameter) { Constructor constructor = new Constructor(Item.class); Yaml yaml = new Yaml(constructor); ObjectMap<String, Item> data = new ObjectMap<String, Item>(); for (Object o : yaml.loadAll(resolve(fileName).read())) { Item item = (Item) o; data.put(item.name, item); } items = new Items(data); Config.items = items; }
Example 13
Source File: DiceHeroes.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
private void playCampaignLevel(LevelDescription level) { Player protagonist = PlayerHelper.protagonist(); for (Die die : userData.dice()) { protagonist.addDie(die); } protagonist.setPotions(userData.potions); protagonist.tutorialProvider = new UserDataTutorialProvider(userData); Player antagonist = PlayerHelper.antagonist(); ObjectMap<Fraction, Player> players = new ObjectMap<Fraction, Player>(); players.put(protagonist.fraction, protagonist); players.put(antagonist.fraction, antagonist); setState(new PvePlayState(this, protagonist, players, PlayerHelper.defaultColors, level, PvePlayState.GameState.PLACE, new PvePlayStateCallback(this, level))); }
Example 14
Source File: BlenderAssetManager.java From GdxDemo3D with Apache License 2.0 | 5 votes |
/** * Add a disposable asset to be held * * @param name Asset name * @param asset The asset * @param type Type of asset */ public void add(String name, T asset, Class<T> type) { if (!map.containsKey(type)) { map.put(type, new ObjectMap<String, T>()); } ObjectMap<String, T> innerMap = map.get(type); if (innerMap.containsKey(name)) { throw new GdxRuntimeException("Asset name is already used, try changing it: '" + name + "'"); } innerMap.put(name, asset); }
Example 15
Source File: DistributionAdapters.java From gdx-ai with Apache License 2.0 | 5 votes |
public final void add (Class<?> clazz, Adapter<?> adapter) { map.put(clazz, adapter); ObjectMap<String, Adapter<?>> m = typeMap.get(adapter.type); if (m == null) { m = new ObjectMap<String, Adapter<?>>(); typeMap.put(adapter.type, m); } m.put(adapter.category, adapter); }
Example 16
Source File: LR2SkinCSVLoader.java From beatoraja with GNU General Public License v3.0 | 4 votes |
public S loadSkin(Path f, MainState state, SkinHeader header, IntIntMap option, SkinConfig.Property property) throws IOException { ObjectMap m = new ObjectMap(); for(SkinConfig.Option op : property.getOption()) { if(op.value != OPTION_RANDOM_VALUE) { m.put(op.name, op.value); } else { for (CustomOption opt : header.getCustomOptions()) { if(op.name.equals(opt.name)) { if(header.getRandomSelectedOptions(op.name) >= 0) m.put(op.name, header.getRandomSelectedOptions(op.name)); } } } } for(SkinConfig.FilePath file : property.getFile()) { if(!file.path.equals("Random")) { m.put(file.name, file.path); } else { for (CustomFile cf : header.getCustomFiles()) { if(file.name.equals(cf.name)) { String ext = cf.path.substring(cf.path.lastIndexOf("*") + 1); if(cf.path.contains("|")) { if(cf.path.length() > cf.path.lastIndexOf('|') + 1) { ext = cf.path.substring(cf.path.lastIndexOf("*") + 1, cf.path.indexOf('|')) + cf.path.substring(cf.path.lastIndexOf('|') + 1); } else { ext = cf.path.substring(cf.path.lastIndexOf("*") + 1, cf.path.indexOf('|')); } } final int slashindex = cf.path.lastIndexOf('/'); File dir = slashindex != -1 ? new File(cf.path.substring(0, slashindex)) : new File(cf.path); if (dir.exists() && dir.isDirectory()) { Array<File> l = new Array<File>(); for (File subfile : dir.listFiles()) { if (subfile.getPath().toLowerCase().endsWith(ext)) { l.add(subfile); } } if (l.size > 0) { String filename = l.get((int) (Math.random() * l.size)).getName(); m.put(file.name, filename); } } } } } } for(SkinConfig.Offset offset : property.getOffset()) { m.put(offset.name, offset); } mode = header.getSkinType().getMode(); return loadSkin(f, state, header, option, m); }