}
}
private InputProvider getInputFrom(EnvironmentComponent en, Entity ent) {
InputProvider p = new InputProvider();
if (en.hidden)
p.setInput(Acting.Hidden);
else
p.setInput(Acting.Open);
TargetComponent tgt = (TargetComponent) Singleton.get().getEntityManager().getComponent(ent.getId(), TargetComponent.class);
if (tgt != null && tgt.hasTarget()) {
p.setInput(Target.Front);
float dist = ent.getLocalTranslation().distance(
tgt.pos);
if (dist < 5f)
p.setInput(Enemy.Close);
else if (dist < 10f)
p.setInput(Enemy.Near);
else if (dist < 30f)
p.setInput(Enemy.Far);
else
p.setInput(Enemy.None);
} else {
p.setInput(Enemy.None);
}
if (en.damageReceived > 0) {
if (en.damageReceived >= 0) {
p.setInput(Hurt.Light);
p.setInput(HurtVector.Front);
} else if (en.damageReceived >= 32) {
p.setInput(Hurt.Severe);
p.setInput(HurtVector.Front);
} else if (en.damageReceived >= 128) {
p.setInput(Hurt.Deadly);
p.setInput(HurtVector.Front);
}
//TODO who is the one to decide on resetting this? this should go into an EnvSystem!!
en.damageReceived = 0;
en.damageReceivedType = 0;
} else {
p.setInput(Hurt.None);
p.setInput(HurtVector.None);
}
if(en.damageDealt >= 0){
if(en.damageDealt >0)
p.setInput(AttackResult.Success);
else
p.setInput(AttackResult.Failure);
p.setInput(AttackVector.Mid_Front);
//TODO who is the one to decide on resetting this? this should go into an EnvSystem!!
en.damageDealt = -1;
en.damageDealtType = 0;
} else {
p.setInput(AttackResult.None);
}
if (en.teamHealthPercent > 80)
p.setInput(Morale.High);
else
p.setInput(Morale.Normal);
if(en.movement < 0){
p.setInput(Direction.None);
p.setInput(Speed.None);
} else {
p.setInput(Direction.Front);
p.setInput(en.movement > 0 ? Speed.Run
: Speed.Walk);
}
p.setInput(Weapon.OneHand);
return p;
}