skadistats.clarity.model.Entity Java Examples
The following examples show how to use
skadistats.clarity.model.Entity.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Main.java From clarity-examples with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void logUpdateEnt(DotaUserMessages.CDOTAUserMsg_ParticleManager message) { int entityHandle = message.getUpdateParticleEnt().getEntityHandle(); Entity parent = entities.getByHandle(entityHandle); log.info("{} {} [index={}, entity={}({}), controlPoint={}, attachmentType={}, attachment={}, includeWearables={}]", getTick(), "PARTICLE_UPDATE_ENT", message.getIndex(), entityHandle, parent == null ? "NOT_FOUND" : parent.getDtClass().getDtName(), message.getUpdateParticleEnt().getControlPoint(), ParticleAttachmentType.forId(message.getUpdateParticleEnt().getAttachType()), message.getUpdateParticleEnt().getAttachment(), message.getUpdateParticleEnt().getIncludeWearables() ); //log.info(message.toString()); }
Example #2
Source File: Parse.java From parser with MIT License | 6 votes |
@OnEntityEntered public void onEntityEntered(Context ctx, Entity e) { if (e.getDtClass().getDtName().equals("CDOTAWearableItem")) { Integer accountId = getEntityProperty(e, "m_iAccountID", null); Integer itemDefinitionIndex = getEntityProperty(e, "m_iItemDefinitionIndex", null); Integer ownerHandle = getEntityProperty(e, "m_hOwnerEntity", null); Entity owner = ctx.getProcessor(Entities.class).getByHandle(ownerHandle); //System.err.format("%s,%s\n", accountId, itemDefinitionIndex); if (accountId > 0) { // Get the owner (a hero entity) Integer playerId = getEntityProperty(owner, "m_iPlayerID", null); Long accountId64 = 76561197960265728L + accountId; Integer playerSlot = steamid_to_playerslot.get(accountId64); cosmeticsMap.put(itemDefinitionIndex, playerSlot); } } }
Example #3
Source File: Parse.java From parser with MIT License | 6 votes |
private List<Item> getHeroInventory(Context ctx, Entity eHero) { List<Item> inventoryList = new ArrayList<>(6); for (int i = 0; i < 6; i++) { try { Item item = getHeroItem(ctx, eHero, i); if(item != null) { inventoryList.add(item); } } catch (Exception e) { System.err.println(e); } } return inventoryList; }
Example #4
Source File: PropertyChange.java From clarity with BSD 3-Clause "New" or "Revised" License | 6 votes |
boolean applyInternal(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; }
Example #5
Source File: Entities.java From clarity with BSD 3-Clause "New" or "Revised" License | 6 votes |
public Iterator<Entity> getAllByPredicate(final Predicate<Entity> predicate) { return new SimpleIterator<Entity>() { int i = -1; @Override public Entity readNext() { while (++i < entityCount) { Entity e = getByIndex(i); if (e != null && predicate.apply(e)) { return e; } } return null; } }; }
Example #6
Source File: Main.java From clarity-examples with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void logCreate(DotaUserMessages.CDOTAUserMsg_ParticleManager message) { int entityHandle = message.getCreateParticle().getEntityHandle(); // int entityIndex = Handle.indexForHandle(entityHandle); // int entitySerial = Handle.serialForHandle(entityHandle); Entity parent = entities.getByHandle(entityHandle); log.info("{} {} [index={}, entity={}({}), effect={}, attach={}]", getTick(), "PARTICLE_CREATE", message.getIndex(), entityHandle, parent == null ? "NOT_FOUND" : parent.getDtClass().getDtName(), message.getCreateParticle().getParticleNameIndex(), message.getCreateParticle().getAttachType() ); //log.info(message.toString()); }
Example #7
Source File: Parse.java From parser with MIT License | 6 votes |
private Entry buildWardEntry(Context ctx, Entity e) { Entry entry = new Entry(time); boolean isObserver = !e.getDtClass().getDtName().contains("TrueSight"); Integer x = getEntityProperty(e, "CBodyComponent.m_cellX", null); Integer y = getEntityProperty(e, "CBodyComponent.m_cellY", null); Integer z = getEntityProperty(e, "CBodyComponent.m_cellZ", null); Integer life_state = getEntityProperty(e, "m_lifeState", null); Integer[] pos = {x, y}; entry.x = x; entry.y = y; entry.z = z; entry.type = isObserver ? "obs" : "sen"; entry.entityleft = life_state == 1; entry.key = Arrays.toString(pos); entry.ehandle = e.getHandle(); if (entry.entityleft) { entry.type += "_left"; } Integer owner = getEntityProperty(e, "m_hOwnerEntity", null); Entity ownerEntity = ctx.getProcessor(Entities.class).getByHandle(owner); entry.slot = ownerEntity != null ? (Integer) getEntityProperty(ownerEntity, "m_iPlayerID", null) : null; return entry; }
Example #8
Source File: Entities.java From clarity with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void processEntityCreate(int eIdx, int serial, DTClass dtClass, NetMessages.CSVCMsg_PacketEntities message, BitStream stream) { Baseline baseline = getBaseline(dtClass.getClassId(), message.getBaseline(), eIdx, message.getIsDelta()); EntityState newState = baseline.state.copy(); fieldReader.readFields(stream, dtClass, newState, null, debug); Entity entity = entityRegistry.create( eIdx, serial, engineType.handleForIndexAndSerial(eIdx, serial), dtClass); entity.setExistent(true); entity.setState(newState); entities.setEntity(entity); logModification("CREATE", entity); emitCreatedEvent(entity); processEntityEnter(entity); if (message.getUpdateBaseline()) { Baseline updatedBaseline = entityBaselines[eIdx][1 - message.getBaseline()]; updatedBaseline.dtClassId = dtClass.getClassId(); updatedBaseline.state = newState.copy(); } }
Example #9
Source File: Main.java From clarity-examples with BSD 3-Clause "New" or "Revised" License | 6 votes |
@OnEntityUpdated public void onUpdated(Entity e, FieldPath[] updatedPaths, int updateCount) { if (!isHero(e)) { return; } ensureFieldPaths(e); boolean update = false; for (int i = 0; i < updateCount; i++) { if (updatedPaths[i].equals(mana) || updatedPaths[i].equals(maxMana)) { update = true; break; } } if (update) { System.out.format("%s (%s/%s)\n", e.getDtClass().getDtName(), e.getPropertyForFieldPath(mana), e.getPropertyForFieldPath(maxMana)); } }
Example #10
Source File: Wards.java From parser with MIT License | 5 votes |
public void processLifeStateChange(Entity e, FieldPath p) { int oldState = currentLifeState.containsKey(e.getIndex()) ? currentLifeState.get(e.getIndex()) : 2; int newState = e.getPropertyForFieldPath(p); if (oldState != newState) { switch(newState) { case 0: if (evPlaced != null) { evPlaced.raise(e); } break; case 1: String killer; if ((killer = wardKillersByWardClass.get(getWardTargetName(e.getDtClass().getDtName())).poll()) != null) { if (evKilled != null) { evKilled.raise(e, killer); } } else { if (evExpired != null) { evExpired.raise(e); } } break; } } currentLifeState.put(e.getIndex(), newState); }
Example #11
Source File: Main.java From clarity-examples with BSD 3-Clause "New" or "Revised" License | 5 votes |
@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) ); }
Example #12
Source File: Main.java From clarity-examples with BSD 3-Clause "New" or "Revised" License | 5 votes |
@OnEntityCreated public void onCreated(Entity e) { FieldPath fp = e.getDtClass().getFieldPathForName("CBodyComponent.m_hModel"); if (fp == null) { return; } Long resourceHandle = e.getPropertyForFieldPath(fp); if (resourceHandle == null || resourceHandle == 0L) { return; } Resources.Entry entry = resources.getEntryForResourceHandle(resourceHandle); System.out.format("model for entity at %d (%d): %s\n", e.getIndex(), resourceHandle, entry); }
Example #13
Source File: Main.java From clarity-examples with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public V resolveValue(int index, int team, int pos) { String fieldPathString = pattern .replaceAll("%i", Util.arrayIdxToString(index)) .replaceAll("%t", Util.arrayIdxToString(team)) .replaceAll("%p", Util.arrayIdxToString(pos)); String compiledName = entityName.replaceAll("%n", getTeamName(team)); Entity entity = getEntity(compiledName); FieldPath fieldPath = entity.getDtClass().getFieldPathForName(fieldPathString); return entity.getPropertyForFieldPath(fieldPath); }
Example #14
Source File: Main.java From clarity-examples with BSD 3-Clause "New" or "Revised" License | 5 votes |
@OnEntityCreated public void onCreated(Entity e) { if (!isHero(e)) { return; } ensureFieldPaths(e); System.out.format("%s (%s/%s)\n", e.getDtClass().getDtName(), e.getPropertyForFieldPath(mana), e.getPropertyForFieldPath(maxMana)); }
Example #15
Source File: ObservableEntityList.java From clarity-analyzer with BSD 3-Clause "New" or "Revised" License | 5 votes |
@OnEntityDeleted public void onDelete(Entity entity) { lock.lock(); try { markChange(CF_LIST); int i = entity.getIndex(); //System.out.println("delete " + i); changes[i] = new ObservableEntity(i); } finally { lock.unlock(); } }
Example #16
Source File: PropertyChange.java From clarity with BSD 3-Clause "New" or "Revised" License | 5 votes |
@OnEntityDeleted @Order(1000) public void onDeleted(Entity e) { for (ListenerAdapter adapter : adapters) { adapter.clear(e); } }
Example #17
Source File: Parse.java From parser with MIT License | 5 votes |
public <T> T getEntityProperty(Entity e, String property, Integer idx) { try { if (e == null) { return null; } if (idx != null) { property = property.replace("%i", Util.arrayIdxToString(idx)); } FieldPath fp = e.getDtClass().getFieldPathForName(property); return e.getPropertyForFieldPath(fp); } catch (Exception ex) { return null; } }
Example #18
Source File: ObservableEntityList.java From clarity-analyzer with BSD 3-Clause "New" or "Revised" License | 5 votes |
@OnEntityUpdated public void onUpdate(Entity entity, FieldPath[] fieldPaths, int num) { lock.lock(); try { markChange(CF_PROP); int i = entity.getIndex(); ObservableEntity e = changes[i] == null ? entities[i] : changes[i]; e.update(fieldPaths, num); } finally { lock.unlock(); } }
Example #19
Source File: MapControl.java From clarity-analyzer with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void add(int from, List<? extends ObservableEntity> entities) { for (int i = 0; i < entities.size(); i++) { ObservableEntity oe = entities.get(i); Entity e = oe.getEntity(); if (e == null) { continue; } FieldPath fp = e.getDtClass().getFieldPathForName("CBodyComponent.m_cellX"); if (fp == null) { continue; } String name = oe.getEntity().getDtClass().getDtName(); EntityIcon icon; if (name.equals("CDOTAPlayer")) { icon = new CameraIcon(oe); } else if (name.equals("CDOTA_BaseNPC_Barracks")) { icon = new BuildingIcon(oe, 250); } else if (name.equals("CDOTA_BaseNPC_Tower")) { icon = new BuildingIcon(oe, 200); } else if (name.equals("CDOTA_BaseNPC_Building")) { icon = new BuildingIcon(oe, 150); } else if (name.equals("CDOTA_BaseNPC_Fort")) { icon = new BuildingIcon(oe, 300); } else if (name.startsWith("CDOTA_Unit_Hero_")) { icon = new HeroIcon(oe); } else { icon = new DefaultIcon(oe); } mapEntities[from + i] = icon; icons.getChildren().add(icon.getShape()); } }
Example #20
Source File: SpawnsAndDeaths.java From clarity-examples with BSD 3-Clause "New" or "Revised" License | 5 votes |
@OnEntityCreated public void onCreated(Context ctx, Entity e) { clearCachedState(e); ensureFieldPathForEntityInitialized(e); FieldPath p = getFieldPathForEntity(e); if (p != null) { processLifeStateChange(e, p); } }
Example #21
Source File: SpawnsAndDeaths.java From clarity-examples with BSD 3-Clause "New" or "Revised" License | 5 votes |
@OnEntityUpdated public void onUpdated(Context ctx, Entity e, FieldPath[] fieldPaths, int num) { FieldPath p = getFieldPathForEntity(e); if (p != null) { for (int i = 0; i < num; i++) { if (fieldPaths[i].equals(p)) { processLifeStateChange(e, p); break; } } } }
Example #22
Source File: Parse.java From parser with MIT License | 5 votes |
@OnMessage(CUserMessageSayText2.class) public void onAllChatS2(Context ctx, CUserMessageSayText2 message) { Entry entry = new Entry(time); entry.unit = String.valueOf(message.getParam1()); entry.key = String.valueOf(message.getParam2()); Entity e = ctx.getProcessor(Entities.class).getByIndex(message.getEntityindex()); entry.slot = getEntityProperty(e, "m_iPlayerID", null); entry.type = "chat"; output(entry); }
Example #23
Source File: ClientFrame.java From clarity with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Capsule(ClientFrame frame) { int size = frame.getSize(); handle = new int[size]; active = new boolean[size]; for (int i = 0; i < size; i++) { Entity e = frame.entity[i]; handle[i] = e != null ? e.getHandle() : -1; active[i] = e != null && e.isActive(); } }
Example #24
Source File: TempEntities.java From clarity with BSD 3-Clause "New" or "Revised" License | 5 votes |
@OnMessage(S1NetMessages.CSVCMsg_TempEntities.class) public void onTempEntities(S1NetMessages.CSVCMsg_TempEntities message) { if (evTempEntity.isListenedTo()) { BitStream stream = BitStream.createBitStream(message.getEntityData()); S1DTClass cls = null; ReceiveProp[] receiveProps = null; int count = message.getNumEntries(); while (count-- > 0) { stream.readUBitInt(1); // seems to be always 0 if (stream.readBitFlag()) { cls = (S1DTClass) dtClasses.forClassId(stream.readUBitInt(dtClasses.getClassBits()) - 1); receiveProps = cls.getReceiveProps(); } EntityState state = EntityStateFactory.forS1(receiveProps); fieldReader.readFields(stream, cls, state, null, false); int handle = engineType.emptyHandle(); Entity te = new Entity( engineType.indexForHandle(handle), engineType.serialForHandle(handle), handle, cls); te.setExistent(true); te.setActive(true); te.setState(state); evTempEntity.raise(te); } } }
Example #25
Source File: Entities.java From clarity with BSD 3-Clause "New" or "Revised" License | 5 votes |
private Predicate<Object[]> getInvocationPredicate(String classPattern) { if (".*".equals(classPattern)) { return null; } final Pattern p = Pattern.compile(classPattern); return value -> { Entity e = (Entity) value[0]; return p.matcher(e.getDtClass().getDtName()).matches(); }; }
Example #26
Source File: Entities.java From clarity with BSD 3-Clause "New" or "Revised" License | 5 votes |
void debugUpdateEvent(String which, Entity entity) { if (!updateEventDebug) return; log.info("\t%6s: index: %4d, serial: %03x, handle: %7d, class: %s", which, entity.getIndex(), entity.getSerial(), entity.getHandle(), entity.getDtClass().getDtName() ); }
Example #27
Source File: Entities.java From clarity with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void processEntityUpdate(Entity entity, BitStream stream, boolean silent) { assert silent || (entity.isExistent() && entity.isActive()); int nUpdated = fieldReader.readFields(stream, entity.getDtClass(), entity.getState(), (i, f) -> updatedFieldPaths[i] = f, debug); logModification("UPDATE", entity); if (!silent) { emitUpdatedEvent(entity, nUpdated); } }
Example #28
Source File: Entities.java From clarity with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void processEntityDelete(Entity entity) { assert entity.isExistent(); entity.setExistent(false); entities.removeEntity(entity); logModification("DELETE", entity); emitDeletedEvent(entity); }
Example #29
Source File: Entities.java From clarity with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void logModification(String which, Entity entity) { if (!log.isDebugEnabled()) return; log.debug("\t%6s: index: %4d, serial: %03x, handle: %7d, class: %s", which, entity.getIndex(), entity.getSerial(), entity.getHandle(), entity.getDtClass().getDtName() ); }
Example #30
Source File: PropertyChange.java From clarity with BSD 3-Clause "New" or "Revised" License | 5 votes |
@OnEntityCreated @Order(1000) public void onEntityCreated(Entity e) { final Iterator<FieldPath> iter = e.getState().fieldPathIterator(); while(iter.hasNext()) { evPropertyChanged.raise(e, iter.next()); } }