Einige Fixes bezüglich der Anzeige von Gegnern und deren Namen
This commit is contained in:
@@ -12,6 +12,8 @@ import com.jme3.scene.Node;
|
|||||||
import com.jme3.scene.Spatial;
|
import com.jme3.scene.Spatial;
|
||||||
import de.blight.game.config.KeyBindings;
|
import de.blight.game.config.KeyBindings;
|
||||||
import de.blight.game.config.KeyNames;
|
import de.blight.game.config.KeyNames;
|
||||||
|
import de.blight.game.config.MenuScreen;
|
||||||
|
import de.blight.game.config.OverlayState;
|
||||||
import de.blight.lang.TextResolver;
|
import de.blight.lang.TextResolver;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -85,8 +87,8 @@ public class InteractionHudState extends BaseAppState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float tpf) {
|
public void update(float tpf) {
|
||||||
// Label ausblenden wenn Dialog aktiv
|
if ((dialogHud != null && dialogHud.isActive())
|
||||||
if (dialogHud != null && dialogHud.isActive()) {
|
|| OverlayState.isAnyOpen() || MenuScreen.isAnyOpen()) {
|
||||||
labelText.setCullHint(Spatial.CullHint.Always);
|
labelText.setCullHint(Spatial.CullHint.Always);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ import de.blight.common.model.trigger.NpcStatusTrigger;
|
|||||||
import de.blight.game.animation.AnimationAction;
|
import de.blight.game.animation.AnimationAction;
|
||||||
import de.blight.game.animation.AnimationLibrary;
|
import de.blight.game.animation.AnimationLibrary;
|
||||||
import de.blight.game.config.KeyBindings;
|
import de.blight.game.config.KeyBindings;
|
||||||
|
import de.blight.game.config.MenuScreen;
|
||||||
|
import de.blight.game.config.OverlayState;
|
||||||
import de.blight.game.combat.CombatStyleBase;
|
import de.blight.game.combat.CombatStyleBase;
|
||||||
import de.blight.game.combat.DamageCalculator;
|
import de.blight.game.combat.DamageCalculator;
|
||||||
import de.blight.game.combat.MeleeAttackCallback;
|
import de.blight.game.combat.MeleeAttackCallback;
|
||||||
@@ -593,7 +595,6 @@ public class WorldNpcsState extends BaseAppState implements MeleeAttackCallback
|
|||||||
|
|
||||||
for (int i = 0; i < spawned.size(); i++) {
|
for (int i = 0; i < spawned.size(); i++) {
|
||||||
SpawnedNpc s = spawned.get(i);
|
SpawnedNpc s = spawned.get(i);
|
||||||
if (s.aggroBehavior.isAttacking()) continue;
|
|
||||||
Vector3f pos = s.visual().getLocalTranslation();
|
Vector3f pos = s.visual().getLocalTranslation();
|
||||||
|
|
||||||
float dx = pos.x - charPos.x;
|
float dx = pos.x - charPos.x;
|
||||||
@@ -619,6 +620,7 @@ public class WorldNpcsState extends BaseAppState implements MeleeAttackCallback
|
|||||||
|
|
||||||
private final ActionListener interactListener = (name, isPressed, tpf) -> {
|
private final ActionListener interactListener = (name, isPressed, tpf) -> {
|
||||||
if (!isPressed || dialogActive || hoveredIdx < 0) return;
|
if (!isPressed || dialogActive || hoveredIdx < 0) return;
|
||||||
|
if (spawned.get(hoveredIdx).aggroBehavior.isAttacking()) return;
|
||||||
startDialog(hoveredIdx);
|
startDialog(hoveredIdx);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1946,30 +1948,49 @@ public class WorldNpcsState extends BaseAppState implements MeleeAttackCallback
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateNpcEnemyHud() {
|
private void updateNpcEnemyHud() {
|
||||||
if (npcEnemyHudNode == null) { return; }
|
if (npcEnemyHudNode == null || cam == null || physicsChar == null) { return; }
|
||||||
boolean weaponOut = playerInput.isWeaponDrawn();
|
|
||||||
if (!weaponOut) {
|
if (dialogActive || OverlayState.isAnyOpen() || MenuScreen.isAnyOpen()) {
|
||||||
npcEnemyHudNode.setCullHint(Spatial.CullHint.Always);
|
npcEnemyHudNode.setCullHint(Spatial.CullHint.Always);
|
||||||
focusedNpcIdx = -1;
|
focusedNpcIdx = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean anyAggro = false;
|
||||||
|
for (SpawnedNpc s : spawned) {
|
||||||
|
if (s.aggroBehavior.isAttacking()) { anyAggro = true; break; }
|
||||||
|
}
|
||||||
|
if (!anyAggro) {
|
||||||
|
npcEnemyHudNode.setCullHint(Spatial.CullHint.Always);
|
||||||
|
focusedNpcIdx = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Vector3f playerPos = physicsChar.getPhysicsLocation();
|
Vector3f playerPos = physicsChar.getPhysicsLocation();
|
||||||
|
float centerX = cam.getWidth() * 0.5f;
|
||||||
|
float hMargin = cam.getWidth() * 0.10f;
|
||||||
|
float screenH = cam.getHeight();
|
||||||
|
|
||||||
focusedNpcIdx = -1;
|
focusedNpcIdx = -1;
|
||||||
float bestDistSq = 6f * 6f;
|
float bestDist = Float.MAX_VALUE;
|
||||||
for (int i = 0; i < spawned.size(); i++) {
|
for (int i = 0; i < spawned.size(); i++) {
|
||||||
SpawnedNpc s = spawned.get(i);
|
SpawnedNpc s = spawned.get(i);
|
||||||
Vector3f npcPos = s.visual().getWorldTranslation();
|
if (!s.aggroBehavior.isAttacking()) { continue; }
|
||||||
|
Vector3f npcPos = s.visual().getWorldTranslation();
|
||||||
|
Vector3f headPos = npcPos.add(0f, 1.5f, 0f);
|
||||||
|
if (headPos.subtract(cam.getLocation()).dot(cam.getDirection()) <= 0f) { continue; }
|
||||||
|
Vector3f screen = cam.getScreenCoordinates(headPos);
|
||||||
|
if (Math.abs(screen.x - centerX) > hMargin) { continue; }
|
||||||
|
if (screen.y < 0f || screen.y > screenH) { continue; }
|
||||||
float dx = npcPos.x - playerPos.x;
|
float dx = npcPos.x - playerPos.x;
|
||||||
float dz = npcPos.z - playerPos.z;
|
float dz = npcPos.z - playerPos.z;
|
||||||
float distSq = dx * dx + dz * dz;
|
float d = (float) Math.sqrt(dx * dx + dz * dz);
|
||||||
if (distSq < bestDistSq) {
|
if (d < bestDist) { bestDist = d; focusedNpcIdx = i; }
|
||||||
bestDistSq = distSq;
|
|
||||||
focusedNpcIdx = i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (focusedNpcIdx >= 0) {
|
if (focusedNpcIdx >= 0) {
|
||||||
SpawnedNpc s = spawned.get(focusedNpcIdx);
|
SpawnedNpc s = spawned.get(focusedNpcIdx);
|
||||||
float ratio = s.maxHp > 0 ? (float) s.currentHp / s.maxHp : 0f;
|
float ratio = s.maxHp > 0 ? (float) s.currentHp / s.maxHp : 0f;
|
||||||
applyNpcEnemyHpRatio(ratio);
|
applyNpcEnemyHpRatio(ratio);
|
||||||
npcEnemyHudNode.setCullHint(Spatial.CullHint.Inherit);
|
npcEnemyHudNode.setCullHint(Spatial.CullHint.Inherit);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user