当前位置: 首页>>代码示例>>Java>>正文


Java StringTables类代码示例

本文整理汇总了Java中skadistats.clarity.processor.stringtables.StringTables的典型用法代码示例。如果您正苦于以下问题:Java StringTables类的具体用法?Java StringTables怎么用?Java StringTables使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StringTables类属于skadistats.clarity.processor.stringtables包,在下文中一共展示了StringTables类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHeroItem

import skadistats.clarity.processor.stringtables.StringTables; //导入依赖的package包/类
/**
 * Uses "EntityNames" string table and Entities processor
 * @param ctx Context
 * @param eHero Hero entity
 * @param idx 0-5 - inventory, 6-8 - backpack, 9-16 - stash
 * @return {@code null} - empty slot. Throws @{@link UnknownItemFoundException} if item information can't be extracted
 */
private Item getHeroItem(Context ctx, Entity eHero, int idx) throws UnknownItemFoundException {
    StringTable stEntityNames = ctx.getProcessor(StringTables.class).forName("EntityNames");
    Entities entities = ctx.getProcessor(Entities.class);

    Integer hItem = eHero.getProperty("m_hItems." + Util.arrayIdxToString(idx));
    if (hItem == 0xFFFFFF) {
        return null;
    }
    Entity eItem = entities.getByHandle(hItem);
    if(eItem == null) {
        throw new UnknownItemFoundException(String.format("Can't find item by its handle (%d)", hItem));
    }
    String itemName = stEntityNames.getNameByIndex(eItem.getProperty("m_pEntity.m_nameStringableIndex"));
    if(itemName == null) {
        throw new UnknownItemFoundException("Can't get item name from EntityName string table");
    }

    Item item = new Item();
    item.id = itemName;
    int numCharges = eItem.getProperty("m_iCurrentCharges");
    if(numCharges != 0) {
        item.num_charges = numCharges;
    }
    int numSecondaryCharges = eItem.getProperty("m_iSecondaryCharges");
    if(numSecondaryCharges != 0) {
        item.num_secondary_charges = numSecondaryCharges;
    }

    return item;
}
 
开发者ID:odota,项目名称:parser,代码行数:38,代码来源:Parse.java

示例2: runSeek

import skadistats.clarity.processor.stringtables.StringTables; //导入依赖的package包/类
public void runSeek(String[] args) throws Exception {
    Runner runner = new SimpleRunner(new MappedFileSource(args[0])).runWith(this);
    StringTables st = runner.getContext().getProcessor(StringTables.class);
    for (String name : names) {
        StringTable t = st.forName(name);
        System.out.println(t.toString());
    }
}
 
开发者ID:skadistats,项目名称:clarity-examples,代码行数:9,代码来源:Main.java

示例3: run

import skadistats.clarity.processor.stringtables.StringTables; //导入依赖的package包/类
public void run(String[] args) throws Exception {
    long tStart = System.currentTimeMillis();

    int tick = Integer.valueOf(args[0]);
    String demoName = args[1];

    ControllableRunner r = new ControllableRunner(new MappedFileSource(demoName)).runWith(this);
    r.seek(tick);
    r.halt();

    Context ctx = r.getContext();

    File dir = new File(String.format("baselines%s%s", File.separator, ctx.getBuildNumber() == -1 ? "latest" : ctx.getBuildNumber()));
    if (!dir.exists()) {
        dir.mkdirs();
    }

    FieldReader fieldReader = ctx.getEngineType().getNewFieldReader();

    StringTables stringTables = ctx.getProcessor(StringTables.class);
    DTClasses dtClasses = ctx.getProcessor(DTClasses.class);
    StringTable baselines = stringTables.forName("instancebaseline");

    for (int i = 0; i < baselines.getEntryCount(); i++) {
        DTClass dtClass = dtClasses.forClassId(Integer.valueOf(baselines.getNameByIndex(i)));
        String fileName = String.format("%s%s%s.txt", dir.getPath(), File.separator, dtClass.getDtName());
        log.info("writing {}", fileName);
        fieldReader.DEBUG_STREAM = new PrintStream(new FileOutputStream(fileName), true, "UTF-8");
        BitStream bs = BitStream.createBitStream(baselines.getValueByIndex(i));
        try {
            fieldReader.readFields(bs, dtClass, dtClass.getEmptyStateArray(), true);
            if (bs.remaining() < 0 || bs.remaining() > 7) {
                log.info("-- OFF: {} remaining", bs.remaining());
            }
        } catch (Exception e) {
            log.info("-- FAIL: {}", e.getMessage());
            e.printStackTrace(fieldReader.DEBUG_STREAM);
        } finally {
        }
    }

    long tMatch = System.currentTimeMillis() - tStart;
    log.info("total time taken: {}s", (tMatch) / 1000.0);
}
 
开发者ID:skadistats,项目名称:clarity-examples,代码行数:45,代码来源:Main.java


注:本文中的skadistats.clarity.processor.stringtables.StringTables类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。