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

项目:gdx-cclibs    文件:ObjectFloatMapSerializer.java   
public void write (Kryo kryo, Output output, ObjectFloatMap map) {
    int length = map.size;
    output.writeVarInt(length, true);
    output.writeBoolean(false); // whether type is written (in case future version of ObjectFloatMap supports type awareness)

    Serializer keySerializer = null;
    if (keyGenericType != null) {
        if (keySerializer == null) keySerializer = kryo.getSerializer(keyGenericType);
        keyGenericType = null;
    }

    for (Iterator iter = map.iterator(); iter.hasNext();) {
        ObjectFloatMap.Entry entry = (ObjectFloatMap.Entry)iter.next();
        if (keySerializer != null) {
            kryo.writeObject(output, entry.key, keySerializer);
        } else
            kryo.writeClassAndObject(output, entry.key);
        output.writeFloat(entry.value);
    }
}
项目:shadow-engine    文件:DefaultWeatherSystem.java   
@Override
public void nextDay() {
    Weather previous = current;
    current = null;

    for (ObjectFloatMap.Entry<Class<? extends Weather>> entry : probabilities.entries()) {
        if (Shadow.rand.nextFloat() <= entry.value) {
            try {
                current = entry.key.getConstructor(Level.class).newInstance(level);
                break;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    if (previous != null) {
        previous.stop();
    }

    if (current != null) {
        current.start();
    }
}
项目:typing-label    文件:TypingConfig.java   
private static ObjectFloatMap<Character> generateDefaultCharIntervals () {
    ObjectFloatMap<Character> map = new ObjectFloatMap<Character>();
    map.put(' ', 0.0f);
    map.put(':', 1.5f);
    map.put(',', 2.5f);
    map.put('.', 2.5f);
    map.put('!', 5.0f);
    map.put('?', 5.0f);
    map.put('\n', 20f);
    return map;
}
项目:gdx-cclibs    文件:ObjectFloatMapSerializer.java   
public ObjectFloatMap read (Kryo kryo, Input input, Class<ObjectFloatMap> type) {
    int length = input.readVarInt(true);
    input.readBoolean(); // currently unused
    ObjectFloatMap map = create(length);

    Class keyClass = null;

    Serializer keySerializer = null;
    if (keyGenericType != null) {
        keyClass = keyGenericType;
        if (keySerializer == null) keySerializer = kryo.getSerializer(keyClass);
        keyGenericType = null;
    }

    kryo.reference(map);

    for (int i = 0; i < length; i++) {
        Object key;
        if (keySerializer != null) {
            key = kryo.readObject(input, keyClass, keySerializer);
        } else
            key = kryo.readClassAndObject(input);
        float value = input.readFloat();
        map.put(key, value);
    }
    return map;
}
项目:ShapeOfThingsThatWere    文件:EffectsSystem.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
public ObjectFloatMap<Faction> getFactionsScores(Map<String, Object> effectsMap) {
  ObjectFloatMap<Faction> scores = new ObjectFloatMap<>(Faction.values().length);
  for (Entry<String, Object> effect : effectsMap.entrySet()) {
    Effect e = effects.get(effect.getKey());
    e.addFactionsScores(scores, effect.getValue());
  }
  return scores;
}
项目:ShapeOfThingsThatWere    文件:DiscoverySystem.java   
private ObjectFloatMap<Faction> getFactionsScores(Discovery discovery) {
  ObjectFloatMap<Faction> scores = effects.getFactionsScores(discovery.effects);
  for (String group : discovery.groups)
    if (Policy.get(group) != null) {
      for (Faction f : Faction.values())
        scores.put(f, scores.get(f, 0f) * 1.5f);
      scores.getAndIncrement(Faction.CULTURAL, 0, 0.5f);
    }
  if (scores.size == 0)
    scores.getAndIncrement(Faction.CULTURAL, 0, 0.5f);
  return scores;
}
项目:ShapeOfThingsThatWere    文件:Research.java   
public Research(Discovery target, Collection<Discovery> previous) {
  this.target = target;
  this.previous = previous;

  this.factions = new ObjectFloatMap<>();
  for (Faction f : Faction.values()) {
    factions.put(f, target.factions.get(f, 0f));
    for (Discovery p : previous)
      factions.getAndIncrement(f, 0f, p.factions.get(f, 0f) * 0.5f);
  }
}
项目:gdx-cclibs    文件:ObjectFloatMapSerializer.java   
protected ObjectFloatMap create (int size) {
    return new ObjectFloatMap(size);
}
项目:ShapeOfThingsThatWere    文件:EffectsSystem.java   
@Override
public void addFactionsScores(ObjectFloatMap<Faction> scores, Number value) {
  float delta = value.intValue();
  scores.getAndIncrement(Faction.MILITARY, 0, delta / 2f);
  scores.getAndIncrement(Faction.ECONOMIC, 0, delta);
}
项目:ShapeOfThingsThatWere    文件:EffectsSystem.java   
@Override
public void addFactionsScores(ObjectFloatMap<Faction> scores, Number value) {
  float delta = value.intValue();
  scores.getAndIncrement(Faction.ECONOMIC, 0, delta / 2f);
  scores.getAndIncrement(Faction.CULTURAL, 0, delta);
}
项目:ShapeOfThingsThatWere    文件:EffectsSystem.java   
@Override
public void addFactionsScores(ObjectFloatMap<Faction> scores, Number value) {
  float delta = value.intValue();
  scores.getAndIncrement(Faction.MILITARY, 0, delta * 3f);
  scores.getAndIncrement(Faction.CULTURAL, 0, -delta * 3f);
}
项目:ShapeOfThingsThatWere    文件:EffectsSystem.java   
@Override
public void addFactionsScores(ObjectFloatMap<Faction> scores, String value) {
  scores.getAndIncrement(Faction.MILITARY, 0, 3f);
  scores.getAndIncrement(Faction.ECONOMIC, 0, 1f);
  scores.getAndIncrement(Faction.CULTURAL, 0, 0.5f);
}
项目:ShapeOfThingsThatWere    文件:EffectsSystem.java   
@Override
public void addFactionsScores(ObjectFloatMap<Faction> scores, Number value) {
  float delta = value.intValue();
  scores.getAndIncrement(Faction.CULTURAL, 0, delta * 2);
}
项目:ShapeOfThingsThatWere    文件:EffectsSystem.java   
@Override
public void addFactionsScores(ObjectFloatMap<Faction> scores, Number value) {
  float delta = value.intValue();
  scores.getAndIncrement(Faction.ECONOMIC, 0, delta * 2);
  scores.getAndIncrement(Faction.CULTURAL, 0, delta / 2);
}
项目:ShapeOfThingsThatWere    文件:EffectsSystem.java   
@Override
public void addFactionsScores(ObjectFloatMap<Faction> scores, Number value) {
  float delta = value.intValue();
  scores.getAndIncrement(Faction.ECONOMIC, 0, delta * 2);
  scores.getAndIncrement(Faction.CULTURAL, 0, delta / 2);
}
项目:ShapeOfThingsThatWere    文件:EffectsSystem.java   
void addFactionsScores(ObjectFloatMap<Faction> scores, V value);