@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; } };
@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; } };
@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) ); }