Java Code Examples for skadistats.clarity.model.Entity#getPropertyForFieldPath()

The following examples show how to use skadistats.clarity.model.Entity#getPropertyForFieldPath() . 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: SpawnsAndDeaths.java    From clarity-examples with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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;
        }
    }
}
 
Example 2
Source File: Parse.java    From parser with MIT License 5 votes vote down vote up
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 3
Source File: Wards.java    From parser with MIT License 5 votes vote down vote up
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 4
Source File: Main.java    From clarity-examples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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 5
Source File: Main.java    From clarity-examples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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);
}