當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。