Example usage for com.badlogic.gdx.utils ObjectMap remove

List of usage examples for com.badlogic.gdx.utils ObjectMap remove

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils ObjectMap remove.

Prototype

public V remove(K key) 

Source Link

Usage

From source file:com.dongbat.game.registry.AbilityRegistry.java

/**
 * Parse ability info from String that was loaded from load() function
 *
 * @param abilityString ability String need to parse
 *//*from   w w  w.  ja v a 2  s .com*/
private static void parseAbility(String abilityString) {
    String[] frags = abilityString.split("\\r?\\n");
    ObjectMap<String, String> common = new ObjectMap<String, String>();
    ObjectMap<Integer, ObjectMap<String, String>> levelMaps = new ObjectMap<Integer, ObjectMap<String, String>>();
    ObjectMap<String, String> abilityData;

    for (String frag : frags) {
        String[] split = frag.split(":");
        common.put(split[0].trim(), split[1].trim());
    }
    String name = common.remove("name");
    String clazz = common.remove("class");

    for (ObjectMap.Entry<String, String> entry : common.entries()) {
        String[] phongs = entry.value.split("\\|");
        abilityData = new ObjectMap<String, String>();
        for (String phong : phongs) {
            String[] minh = phong.split("=");
            abilityData.put(minh[0].trim(), minh[1].trim());
        }
        levelMaps.put(Integer.parseInt(entry.key.trim()), abilityData);
    }

    registry.put(name, new Entry(clazz, levelMaps));

}

From source file:com.dongbat.game.registry.BuffRegistry.java

/**
 * Parse buff info from String that was loaded from load() function
 *
 * @param buffString buff String need to parse
 *//*from  w ww .j  av  a  2 s  .  c  om*/
public static void parseBuffs(String buffString) {
    String[] lines = buffString.split("\\r?\\n");
    ObjectMap<String, String> common = new ObjectMap<String, String>();
    ObjectMap<Integer, ObjectMap<String, String>> levelMaps = new ObjectMap<Integer, ObjectMap<String, String>>();
    ObjectMap<String, String> buffData;

    for (String line : lines) {
        String[] split = line.split(":");
        common.put(split[0], split[1]);
    }
    String name = common.remove("name");
    String clazz = common.remove("class");

    for (ObjectMap.Entry<String, String> entry : common.entries()) {
        String[] phongs = entry.value.split("\\|");
        buffData = new ObjectMap<String, String>();
        for (String phong : phongs) {
            String[] minh = phong.split("=");
            buffData.put(minh[0].trim(), minh[1].trim());
        }
        levelMaps.put(Integer.parseInt(entry.key.trim()), buffData);
    }

    registry.put(name, new Entry(clazz, levelMaps));
}

From source file:com.dongbat.game.system.BuffSystem.java

@Override
protected void process(Entity entity) {
    BuffComponent buffComponent = EntityUtil.getComponent(world, entity, BuffComponent.class);
    ObjectMap<String, BuffInfo> buffs = buffComponent.getBuffs();
    toRemove.clear();//from ww w.  j  a  v a2  s .  c o m

    for (ObjectMap.Entry<String, BuffInfo> buff : buffs) {
        BuffEffect effect = buff.value.getEffect();
        UUID id = buff.value.getSource();
        Entity source = UuidUtil.getEntityByUuid(world, id);
        if (buff.value.getEndTime() <= TimeUtil.getCurrentFrame(world) && !buff.value.isPermanent()) {
            effect.durationEnd(world, source, entity);
            toRemove.add(buff.key);
            continue;
        }
        effect.update(world, source, entity);
    }

    for (String name : toRemove) {
        buffs.remove(name);
    }
}

From source file:com.dongbat.invasion.registry.AbilityRegistry.java

private static void parseAbility(String abilityString) {
    String[] frags = abilityString.split("\\r?\\n");
    ObjectMap<String, String> info = new ObjectMap<String, String>();

    for (String frag : frags) {
        String[] split = frag.split("=");
        info.put(split[0], split[1]);/*from  ww  w.  j  av  a2s . co m*/
    }

    String name = info.remove("name");
    String clazz = info.remove("class");
    String cooldown = info.remove("cooldown");
    registry.put(name, new Entry(clazz, Integer.parseInt(cooldown), info));
}

From source file:com.dongbat.invasion.registry.BuffRegistry.java

public static void load() {
    FileHandle file = Gdx.files.internal("./buffs");
    String[] buffs = file.readString().split("\\r?\\n\\r?\\n");

    for (String buffString : buffs) {
        String[] lines = buffString.split("\\r?\\n");
        ObjectMap<String, String> info = new ObjectMap<String, String>();

        for (String line : lines) {
            String[] split = line.split("=");
            info.put(split[0], split[1]);
        }/*from  w ww  .jav a 2s  .  c o  m*/

        String name = info.remove("name");
        String clazz = info.remove("class");
        registry.put(name, new Entry(clazz, info));
    }
}

From source file:com.dongbat.invasion.system.BuffSystem.java

@Override
protected void process(Entity entity) {
    Buff buffComponent = EntityUtil.getComponent(entity, Buff.class);
    ObjectMap<String, BuffInfo> buffs = buffComponent.getBuffs();
    Array<String> toRemove = new Array<String>();

    for (ObjectMap.Entry<String, BuffInfo> buff : buffs) {
        BuffEffect effect = buff.value.getEffect();
        Entity source = buff.value.getSource();
        if (buff.value.getEndTime() <= TimeUtil.getGameTime()) {
            // remove
            effect.durationEnd(source, entity);
            toRemove.add(buff.key);/*from  w  w w  .j av  a  2 s.  c  om*/
            continue;
        }
        effect.update(source, entity);
    }

    for (String name : toRemove) {
        buffs.remove(name);
    }
}

From source file:com.dongbat.invasion.system.TaskRunnerSystem.java

@Override
protected void processSystem() {
    ObjectMap<Long, TimeUtil.Task> tasks = TimeUtil.getTasks();
    long gameTime = TimeUtil.getGameTime();
    for (ObjectMap.Entry<Long, TimeUtil.Task> task : tasks) {
        if (task.key <= gameTime) {
            task.value.run();/* ww w.  j ava 2s .c  o  m*/
            tasks.remove(task.key);
        }
    }
}

From source file:com.mobidevelop.maps.basic.BasicMapResources.java

License:Apache License

@Override
public <T> void remove(String name, Class<T> type) {
    ObjectMap<String, Object> typeResources = data.get(type);
    if (typeResources != null) {
        T object = (T) typeResources.remove(name);
        if (object instanceof Disposable) {
            ((Disposable) object).dispose();
        }/*  ww w. ja  v  a2s.  co  m*/
    }
}