private void ensureFieldPathForEntityInitialized(Entity e) { Integer cid = e.getDtClass().getClassId(); if (!lifeStatePaths.containsKey(cid)) { lifeStatePaths.put(cid, e.getDtClass().getFieldPathForName("m_lifeState")); } }
public String toString() { return dtClass == null ? "" : dtClass.getDtName(); }
@SuppressWarnings("unchecked") public <T> T getProperty(String property) { FieldPath fp = dtClass.getFieldPathForName(property); if (fp == null) { throw new IllegalArgumentException(String.format("property %s not found on entity of class %s", property, getDtClass().getDtName())); } return getPropertyForFieldPath(fp); }
private Object[] getBaseline(int clsId) { BaselineEntry be = baselineEntries.get(clsId); if (be == null) { throw new ClarityException("Baseline for class %s (%d) not found.", dtClasses.forClassId(clsId).getDtName(), clsId); } if (be.baseline == null) { DTClass cls = dtClasses.forClassId(clsId); BitStream stream = BitStream.createBitStream(be.rawBaseline); be.baseline = cls.getEmptyStateArray(); fieldReader.readFields(stream, cls, be.baseline, false); } return be.baseline; }
@OnEntityPropertyChanged(classPattern = "CDOTA_Unit_Hero_.*", propertyPattern = "m_lifeState") public void onEntityPropertyChanged(Context ctx, Entity e, FieldPath fp) { System.out.format( "%6d %s: %s = %s\n", ctx.getTick(), e.getDtClass().getDtName(), e.getDtClass().getNameForFieldPath(fp), e.getPropertyForFieldPath(fp) ); }
/** * Check if this entity contains the given property. * * @param property Name of the property * @return True, if and only if the given property is present in this entity */ public boolean hasProperty(String property) { return dtClass.getFieldPathForName(property) != null; }
private FieldPath getFieldPathForEntity(Entity e) { return lifeStatePaths.get(e.getDtClass().getClassId()); }
@OnMessage(NetMessages.CSVCMsg_ClassInfo.class) public void onServerClassInfo(NetMessages.CSVCMsg_ClassInfo message) { for (NetMessages.CSVCMsg_ClassInfo.class_t ct : message.getClassesList()) { DTClass dt = dtClasses.forDtName(ct.getClassName()); dt.setClassId(ct.getClassId()); dtClasses.byClassId.put(ct.getClassId(), dt); } dtClasses.classBits = Util.calcBitsNeededFor(dtClasses.byClassId.size() - 1); evClassesComplete.raise(); }
@OnEntityCreated @Order(1000) public void onEntityCreated(Entity e) { List<FieldPath> fieldPaths = e.getDtClass().collectFieldPaths(e.getState()); for (FieldPath fp : fieldPaths) { evPropertyChanged.raise(e, fp); } }
public <T> T getPropertyForFieldPath(FieldPath fp) { return (T) dtClass.getValueForFieldPath(fp, state); }
private Object[] getBaseline(int clsId) { BaselineEntry be = baselineEntries.get(clsId); if (be == null) { throw new ClarityException("Baseline for class %s (%d) not found.", dtClasses.forClassId(clsId).getDtName(), clsId); } if (be.baseline == null) { DTClass cls = dtClasses.forClassId(clsId); BitStream stream = BitStream.createBitStream(be.rawBaseline); be.baseline = cls.getEmptyStateArray(); fieldReader.readFields(stream, cls, be.baseline, false); } return be.baseline; }
@Override public boolean apply(Object[] value) { Entity e = (Entity) value[0]; int eIdx = e.getIndex(); TriState classMatchState = classMatchesForEntity.get(eIdx); if (classMatchState == TriState.UNSET) { classMatchState = TriState.fromBoolean(classPattern.matcher(e.getDtClass().getDtName()).matches()); classMatchesForEntity.set(eIdx, classMatchState); } if (classMatchState != TriState.YES) { return false; } FieldPath fp = (FieldPath) value[1]; TriState propertyMatchState = propertyMatchesForEntity[eIdx].get(fp); if (propertyMatchState == null) { propertyMatchState = TriState.fromBoolean(propertyPattern.matcher(e.getDtClass().getNameForFieldPath(fp)).matches()); propertyMatchesForEntity[eIdx].put(fp, propertyMatchState); } if (propertyMatchState != TriState.YES) { return false; } return true; } };
@SuppressWarnings("unchecked") public <T> T getProperty(String property) { FieldPath fp = dtClass.getFieldPathForName(property); if (fp == null) { throw new IllegalArgumentException(String.format("property %s not found on entity of class %s", property, getDtClass().getDtName())); } return getPropertyForFieldPath(fp); }
/** * Check if this entity contains the given property. * * @param property Name of the property * @return True, if and only if the given property is present in this entity */ public boolean hasProperty(String property) { return dtClass.getFieldPathForName(property) != null; }
private FieldPath getFieldPathForEntity(Entity e) { return lifeStatePaths.get(e.getDtClass().getClassId()); }
@OnMessage(Demo.CDemoClassInfo.class) public void onDemoClassInfo(Demo.CDemoClassInfo message) { for (Demo.CDemoClassInfo.class_t ct : message.getClassesList()) { DTClass dt = dtClasses.forDtName(ct.getNetworkName()); dt.setClassId(ct.getClassId()); dtClasses.byClassId.put(ct.getClassId(), dt); } dtClasses.classBits = Util.calcBitsNeededFor(dtClasses.byClassId.size() - 1); evClassesComplete.raise(); }
@OnEntityCreated @Order(1000) public void onEntityCreated(Entity e) { List<FieldPath> fieldPaths = e.getDtClass().collectFieldPaths(e.getState()); for (FieldPath fp : fieldPaths) { evPropertyChanged.raise(e, fp); } }
public <T> T getPropertyForFieldPath(FieldPath fp) { return (T) dtClass.getValueForFieldPath(fp, state); }