private void clearCachedState(Entity e) { currentLifeState.remove(e.getIndex()); }
private void clearCachedState(Entity e) { currentLifeState.remove(e.getIndex()); }
private void clear(Entity e) { int eIdx = e.getIndex(); classMatchesForEntity.set(eIdx, TriState.UNSET); propertyMatchesForEntity[eIdx].clear(); } }
private void clear(Entity e) { int eIdx = e.getIndex(); classMatchesForEntity.set(eIdx, TriState.UNSET); propertyMatchesForEntity[eIdx].clear(); } }
private 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) { currentLifeState.put(e.getIndex(), newState); switch(newState) { case 0: if (evSpawned != null) { evSpawned.raise(e); } break; case 1: if (evDying != null) { evDying.raise(e); } break; case 2: if (evDied != null) { evDied.raise(e); } break; } } }
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); }
@OnEntitySpawned public void onSpawned(Entity e) { System.out.printf("%06d: %s at index %d has spawned\n", ctx.getTick(), e.getDtClass().getDtName(), e.getIndex()); }
@OnEntityDied public void onDied(Entity e) { System.out.printf("%06d: %s at index %d has died\n", ctx.getTick(), e.getDtClass().getDtName(), e.getIndex()); }
@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; } };
@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); }
@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; } };