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 de.blight.game.config.KeyBindings;
|
||||
import de.blight.game.config.KeyNames;
|
||||
import de.blight.game.config.MenuScreen;
|
||||
import de.blight.game.config.OverlayState;
|
||||
import de.blight.lang.TextResolver;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -85,8 +87,8 @@ public class InteractionHudState extends BaseAppState {
|
||||
|
||||
@Override
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ import de.blight.common.model.trigger.NpcStatusTrigger;
|
||||
import de.blight.game.animation.AnimationAction;
|
||||
import de.blight.game.animation.AnimationLibrary;
|
||||
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.DamageCalculator;
|
||||
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++) {
|
||||
SpawnedNpc s = spawned.get(i);
|
||||
if (s.aggroBehavior.isAttacking()) continue;
|
||||
Vector3f pos = s.visual().getLocalTranslation();
|
||||
|
||||
float dx = pos.x - charPos.x;
|
||||
@@ -619,6 +620,7 @@ public class WorldNpcsState extends BaseAppState implements MeleeAttackCallback
|
||||
|
||||
private final ActionListener interactListener = (name, isPressed, tpf) -> {
|
||||
if (!isPressed || dialogActive || hoveredIdx < 0) return;
|
||||
if (spawned.get(hoveredIdx).aggroBehavior.isAttacking()) return;
|
||||
startDialog(hoveredIdx);
|
||||
};
|
||||
|
||||
@@ -1946,27 +1948,46 @@ public class WorldNpcsState extends BaseAppState implements MeleeAttackCallback
|
||||
}
|
||||
|
||||
private void updateNpcEnemyHud() {
|
||||
if (npcEnemyHudNode == null) { return; }
|
||||
boolean weaponOut = playerInput.isWeaponDrawn();
|
||||
if (!weaponOut) {
|
||||
if (npcEnemyHudNode == null || cam == null || physicsChar == null) { return; }
|
||||
|
||||
if (dialogActive || OverlayState.isAnyOpen() || MenuScreen.isAnyOpen()) {
|
||||
npcEnemyHudNode.setCullHint(Spatial.CullHint.Always);
|
||||
focusedNpcIdx = -1;
|
||||
return;
|
||||
}
|
||||
Vector3f playerPos = physicsChar.getPhysicsLocation();
|
||||
|
||||
boolean anyAggro = false;
|
||||
for (SpawnedNpc s : spawned) {
|
||||
if (s.aggroBehavior.isAttacking()) { anyAggro = true; break; }
|
||||
}
|
||||
if (!anyAggro) {
|
||||
npcEnemyHudNode.setCullHint(Spatial.CullHint.Always);
|
||||
focusedNpcIdx = -1;
|
||||
float bestDistSq = 6f * 6f;
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3f playerPos = physicsChar.getPhysicsLocation();
|
||||
float centerX = cam.getWidth() * 0.5f;
|
||||
float hMargin = cam.getWidth() * 0.10f;
|
||||
float screenH = cam.getHeight();
|
||||
|
||||
focusedNpcIdx = -1;
|
||||
float bestDist = Float.MAX_VALUE;
|
||||
for (int i = 0; i < spawned.size(); i++) {
|
||||
SpawnedNpc s = spawned.get(i);
|
||||
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 dz = npcPos.z - playerPos.z;
|
||||
float distSq = dx * dx + dz * dz;
|
||||
if (distSq < bestDistSq) {
|
||||
bestDistSq = distSq;
|
||||
focusedNpcIdx = i;
|
||||
}
|
||||
float d = (float) Math.sqrt(dx * dx + dz * dz);
|
||||
if (d < bestDist) { bestDist = d; focusedNpcIdx = i; }
|
||||
}
|
||||
|
||||
if (focusedNpcIdx >= 0) {
|
||||
SpawnedNpc s = spawned.get(focusedNpcIdx);
|
||||
float ratio = s.maxHp > 0 ? (float) s.currentHp / s.maxHp : 0f;
|
||||
|
||||
Reference in New Issue
Block a user