Compare commits
No commits in common. "v0.12.0" and "v0.11.0" have entirely different histories.
128
CHANGELOG.md
128
CHANGELOG.md
@ -6,129 +6,6 @@ lignée du jeu amont (0.2.2 en 2017, abandonné).
|
|||||||
|
|
||||||
## [Non publié]
|
## [Non publié]
|
||||||
|
|
||||||
_(vide — prochaine fonctionnalité)_
|
|
||||||
|
|
||||||
## [0.12.0] — 2026-11-16
|
|
||||||
|
|
||||||
### Ajouté
|
|
||||||
- **Export de logs partageables sur Android** (retour v0.11.0 : « le jeu
|
|
||||||
crash énormément, faut ajouter des logs larges que je pourrai partager ») :
|
|
||||||
tampon GameLog 4000 lignes (thread-safe) + `crash-<date>.txt` (stack
|
|
||||||
complète, device, journal intégral) + `gamelog-latest.txt` (dump 5 s,
|
|
||||||
survit au kill) dans `Android/data/fr.siphonight.lostsectorport/files/`
|
|
||||||
— lisible sans root, dans l'app Fichiers ou via `adb pull`
|
|
||||||
- **Génération procédurale entièrement tracée** (MapManager) : seed loggué
|
|
||||||
(reproductible), segments + tuiles par couche, gids sans tileset, objets
|
|
||||||
TMX, spawns ; gardes anti-crash 2017 (segment null, tileset manquant,
|
|
||||||
porte hors bornes) ; catches avaleurs convertis en GameLog.e avec stack
|
|
||||||
- **Batterie d'anti-régression Android** `scripts/test-android.sh` :
|
|
||||||
26 checks automatisés (menu, tir, pouvoirs, pause, procédural, spawn au
|
|
||||||
sol, Survival, Settings ×2, lobby multi, export logs) + captures écran
|
|
||||||
par check — PASS 26/26
|
|
||||||
|
|
||||||
### Corrigé
|
|
||||||
- **Menu principal Android inerte au touch** (retour v0.11.0) : les
|
|
||||||
MotionEvents étaient écrits sur le thread UI et lus sur le thread GL sans
|
|
||||||
synchronisation (violation du memory model) — marshaling via
|
|
||||||
`GLSurfaceView.queueEvent` (AndroidLauncher) ; les taps courts down+up
|
|
||||||
dans la même frame étaient de plus écrasés par la machine à états d'
|
|
||||||
`Input` (releases différées d'une frame dans updateKeys)
|
|
||||||
- **Settings invisibles** (retour v0.11.0 : « les settings ne s'affichent
|
|
||||||
plus ») : le walk v0.9.0 via `getComponentsOfType` ne parcourt pas la
|
|
||||||
hiérarchie — contenu caché sous le fond depth 10 ; depths posés à la
|
|
||||||
création ; zone de clic = barre entière (`Menu.optionRects`, le texte
|
|
||||||
seul était trop fin pour le tactile) ; HUD masqué pendant le panneau
|
|
||||||
- **Crash du lobby multi à la recherche de partie** (retour v0.11.0) :
|
|
||||||
le manifest Android n'avait PAS la permission INTERNET →
|
|
||||||
`DatagramSocket` EPERM → FATAL sur le thread GL ; permission ajoutée +
|
|
||||||
catch défensif + timeout 8 s (cadre rouge lisible, lobby réutilisable)
|
|
||||||
- **NPE sur glyphes absents de l'atlas de fonte** (le « / » manquait :
|
|
||||||
trou dans `GuiText.characters` → crash au `setText` du message d'erreur)
|
|
||||||
— gardes null dans `GuiText.generateRenderers` + libellés sans « / »
|
|
||||||
- **Multi : le client Android crashait au GAME_JOIN** (retour v0.11.0 coop
|
|
||||||
émulateur) : le matchmaker transmet l'ip du hôte TELLE QU'IL LA VOIT —
|
|
||||||
derrière NAT/loopback le client tentait 127.0.0.1:2829 = lui-même →
|
|
||||||
tcpOut null → NPE ; `Network.addPlayer` réécrit une ip loopback vers
|
|
||||||
l'hôte du matchmaker (logs LS-NET) ; serveur Node durci contre les acks
|
|
||||||
sans jeu connu (un ack post-purge tuait tout le serveur → tous les
|
|
||||||
clients timeout) ; `LS_MP_AUTOJOIN=1` pour la coop desktop de test ;
|
|
||||||
épreuve réelle : pairing OK, join sans crash, les deux côtés dans le
|
|
||||||
niveau multiplayer (la visibilité croisée des joueurs reste le chantier
|
|
||||||
handshake P2P)
|
|
||||||
- **IA : acquisition impossible hors ligne de vue** (retour v0.11.0 :
|
|
||||||
« ils tentent pas de venir me chercher ») : l'acquisition exigeait la LOS,
|
|
||||||
toujours coupée sur les cartes multi-niveaux → IDLE planté ; désormais
|
|
||||||
acquisition à la portée sans LOS (les murs bloquent toujours le TIR) —
|
|
||||||
la poursuite inter-étages (Jump links NavMesh) est en cours
|
|
||||||
- **Spawner Exterminate : ennemis hors carte / autre étage** (retour
|
|
||||||
v0.11.0 : « ennemis spawn en dehors de la map ») : sol de référence =
|
|
||||||
celui du joueur, 6 tentatives de colonnes alternées, même étage exigé
|
|
||||||
(≤ 300 px) sinon re-tir — plus d'ennemis hors NavMesh
|
|
||||||
|
|
||||||
- **Gel complet du MacBook au ballon** (retour v0.12.0 desktop : « ta
|
|
||||||
version desktop fait planter le macbook en softlock ») : DEUX spins à
|
|
||||||
100% CPU — (1) le reader TCP sur connexion MORTE : `readLine()` rend
|
|
||||||
null instantanément quand le pair ferme, `socket.isConnected()` ne passe
|
|
||||||
jamais false (état local) → fix = EOF → log + break + gardes sur les
|
|
||||||
readLine imbriqués ; (2) le writer TCP sur connexion VIVE (QA v0.12.0) :
|
|
||||||
le `wait()` 2017 était inatteignable (`if (!initialising)`) → boucle
|
|
||||||
synchronisée serrée à fond pendant tout le multi, un cœur par client ;
|
|
||||||
fix = `while (messages.isEmpty()) wait()`
|
|
||||||
|
|
||||||
- **IA Defend : le cryopod n'était pas attaqué / ennemis plantés en
|
|
||||||
TRACKING** (retour v0.12.0 desktop : « les ennemis n'attaquent pas le
|
|
||||||
pod ») : le fallback objectif fonctionnait, MAIS un joueur (même AFK)
|
|
||||||
sur une cellule NavMesh injoignable (étagère de spawn) « volait » la
|
|
||||||
cible des ennemis à portée 2000 sans LOS → « aucun chemin NavMesh » en
|
|
||||||
boucle → figés pour toujours ; fix = cible joueur abandonnée après 3 s
|
|
||||||
sans chemin → fallback pod reprend (prouvé en jeu : bouclier du pod
|
|
||||||
200 -> 194, 17× ATTACKING cible=Cryopod)
|
|
||||||
- **IA : idle vivant** (retour v0.12.0 : « ils sont super cons, aucun idle
|
|
||||||
pattern, plantés là ») : willPatrol (champ mort 2017) désormais lu —
|
|
||||||
patrouille NavMesh ≤5 liens/≤5 cellules, nouveau choix à l'arrivée ou
|
|
||||||
/4 s (anim idle de base : elle existe et est jouée ; TODO art : un
|
|
||||||
pattern « regard autour » dédié)
|
|
||||||
- **Crash FATAL : mort par Kubrow** — `AnimationState.valueOf(
|
|
||||||
"DIE_KUBROW_FRONT")` sans anim dans l'atlas → IllegalArgumentException,
|
|
||||||
jeu mort en ~90 s ; mort kubrow réutilisée sur DIE_SLASH_* (TODO art :
|
|
||||||
die_kubrow_front/back)
|
|
||||||
### Modifié
|
|
||||||
- Lobby multi refait selon la DA (cadres néon du menu principal, cadre
|
|
||||||
d'erreur rouge généré par `scripts/gen-lobby-sprites.py`)
|
|
||||||
|
|
||||||
## [0.11.0] — 2026-11-15
|
|
||||||
|
|
||||||
La release qui rend Exterminate jouable sur desktop (le crash
|
|
||||||
`inputStream` des tilesets procéduraux) et les ennemis qui spawn sur le
|
|
||||||
sol (raycast vertical) au lieu d'apparaître dans les murs.
|
|
||||||
|
|
||||||
### Ajouté
|
|
||||||
- **Spawn d'ennemis SUR LE SOL** (feedback v0.10.0 : « les ennemis spawn
|
|
||||||
dans les murs ») : raycast vertical depuis au-dessus de la carte — le
|
|
||||||
premier sol touché dans la colonne de spawn donne la position (100 px
|
|
||||||
au-dessus de la tuile solide) ; sans sol : chute libre (clamp NavMesh)
|
|
||||||
- **Lobby multi : retry + erreur visible** (QA v0.10.0 P2) :
|
|
||||||
`connecting` réinitialisé dans onError (le lobby était définitivement
|
|
||||||
mort après une recherche échouée) + erreur affichée en GuiText
|
|
||||||
|
|
||||||
### Corrigé
|
|
||||||
- **Crash desktop Exterminate** (feedback v0.9.0 desktop) :
|
|
||||||
`NullPointerException: inputStream` — la 2ᵉ lookup du loadImage desktop
|
|
||||||
utilisait le chemin BRUT avec « .. » (non normalisé → null dans le
|
|
||||||
JarClassLoader) ; normalisation + null-check lisible
|
|
||||||
- **Menu : garde 2..6 options unifiée** (QA v0.10.0 P3 : elle n'était
|
|
||||||
appliquée que d'un côté)
|
|
||||||
- **presetIndex du lobby aligné sur le serveur persisté** (QA v0.10.0 P3)
|
|
||||||
|
|
||||||
### Modifié
|
|
||||||
- MultiplayerLobbyLevel : commentaire-résidu réécrit proprement
|
|
||||||
|
|
||||||
## [0.10.0] — 2026-11-15
|
|
||||||
|
|
||||||
Le batch de fixes gameplay issus des retours v0.9.0 : IA ennemie
|
|
||||||
bidirectionnelle, crash director, logo/Settings depths, wall jump jouable,
|
|
||||||
flèches compass, menu Multiplayer avec lobby.
|
|
||||||
|
|
||||||
### Ajouté
|
### Ajouté
|
||||||
- **Entrée Multiplayer au menu principal** (feedback v0.9.0 : « y'a
|
- **Entrée Multiplayer au menu principal** (feedback v0.9.0 : « y'a
|
||||||
littérallement aucun moyen de le sélectionner, de mettre le serveur ou de
|
littérallement aucun moyen de le sélectionner, de mettre le serveur ou de
|
||||||
@ -457,8 +334,3 @@ et découvre un port Android complet avec HUD tactile.
|
|||||||
[0.7.0]: https://gitea.cloudyfy.fr/Siphonight/lost-sector-port/compare/v0.6.0...v0.7.0
|
[0.7.0]: https://gitea.cloudyfy.fr/Siphonight/lost-sector-port/compare/v0.6.0...v0.7.0
|
||||||
[0.6.0]: https://gitea.cloudyfy.fr/Siphonight/lost-sector-port/compare/v0.5.0...v0.6.0
|
[0.6.0]: https://gitea.cloudyfy.fr/Siphonight/lost-sector-port/compare/v0.5.0...v0.6.0
|
||||||
[0.5.0]: https://gitea.cloudyfy.fr/Siphonight/lost-sector-port/compare/v0.4.0...v0.5.0
|
[0.5.0]: https://gitea.cloudyfy.fr/Siphonight/lost-sector-port/compare/v0.4.0...v0.5.0
|
||||||
|
|
||||||
[0.12.0]: https://gitea.cloudyfy.fr/Siphonight/lost-sector-port/compare/v0.11.0...v0.12.0
|
|
||||||
[0.11.0]: https://gitea.cloudyfy.fr/Siphonight/lost-sector-port/compare/v0.10.0...v0.11.0
|
|
||||||
[0.10.0]: https://gitea.cloudyfy.fr/Siphonight/lost-sector-port/compare/v0.9.0...v0.10.0
|
|
||||||
[0.9.0]: https://gitea.cloudyfy.fr/Siphonight/lost-sector-port/compare/v0.8.0...v0.9.0
|
|
||||||
|
|||||||
22
README.md
22
README.md
@ -30,26 +30,8 @@ est documentée dans le fichier LICENSE (note de provenance).
|
|||||||
| 4ᵉ pouvoir Frost (Avalanche) | ✅ | ✅ bouton 4 | chantier 2017 terminé |
|
| 4ᵉ pouvoir Frost (Avalanche) | ✅ | ✅ bouton 4 | chantier 2017 terminé |
|
||||||
| Rendu | OpenGL 3.2 core (macOS/Linux/Win) | OpenGL ES 3.0 | |
|
| Rendu | OpenGL 3.2 core (macOS/Linux/Win) | OpenGL ES 3.0 | |
|
||||||
| Audio | OpenAL (LWJGL) | SoundPool + MediaPlayer (boucle incluse) | |
|
| Audio | OpenAL (LWJGL) | SoundPool + MediaPlayer (boucle incluse) | |
|
||||||
| Génération procédurale / Survival / Exterminate | ✅ | ✅ | Testé émulateur (spawn au sol confirmé) |
|
| Génération procédurale / Survival / Exterminate | ✅ code | non testé | |
|
||||||
| Multiplayer (matchmaker local + lobby) | ✅ | ✅ (10.0.2.2) | Testé desktop↔émulateur ; visibilité croisée des joueurs en cours (TODO) |
|
| Multiplayer | code présent, serveurs morts | idem | voir TODO.md |
|
||||||
|
|
||||||
## Multi local
|
|
||||||
|
|
||||||
Le matchmaker 2017 (repo `Matchmaking-Server/javascript`, Node, UDP 3000)
|
|
||||||
fonctionne tel quel :
|
|
||||||
|
|
||||||
```sh
|
|
||||||
node ~/projects/Matchmaking-Server/javascript/server.js # serveur
|
|
||||||
```
|
|
||||||
|
|
||||||
Desktop : variables d'environnement `LS_MP_HOST` / `LS_MP_PORT` (défaut
|
|
||||||
127.0.0.1:3000), `LS_MP_AUTOJOIN=1` pour lancer la recherche au chargement
|
|
||||||
du lobby (outil de test), `LS_LEVEL=<niveau>` pour démarrer sur un niveau
|
|
||||||
(menu, exterminate, multiplayer_lobby…).
|
|
||||||
|
|
||||||
Android : lobby > SERVEUR pour cycler les préréglages (local 127.0.0.1 /
|
|
||||||
émulateur 10.0.2.2 / serveur historique 8bitwarframe.com — mort), choix
|
|
||||||
persisté ; `LS_MP_AUTOJOIN=1` fonctionne aussi via adb shell.
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
|||||||
182
TODO.md
182
TODO.md
@ -37,96 +37,29 @@ commande ligne) :
|
|||||||
- [ ] Angle mort vertical de l'acquisition IA (rayons horizontaux seuls —
|
- [ ] Angle mort vertical de l'acquisition IA (rayons horizontaux seuls —
|
||||||
raycast y+100 fixe) : joueur directement au-dessus/dessous jamais
|
raycast y+100 fixe) : joueur directement au-dessus/dessous jamais
|
||||||
acquis — atténué par le NavMesh, tracé comme amélioration
|
acquis — atténué par le NavMesh, tracé comme amélioration
|
||||||
- [ ] **Defend : les ennemis n'attaquent pas le cryopod** (retour v0.12.0
|
- [ ] Lobby multi mort après erreur de connexion (connecting jamais
|
||||||
desktop, "les ennemis n'attaquent pas le pod") — EN COURS : le fallback
|
réinitialisé, erreur seulement dans les logs) — fix v0.11.0 : reset +
|
||||||
objectif (getObjectiveTarget) ne se déclenche pas / le chemin vers le
|
affichage en GuiText
|
||||||
pod est coupé (portes fermées = cellules solides ?) ; à diagnostiquer
|
|
||||||
avec les logs LS-AI
|
|
||||||
- [ ] **IA : aucun comportement idle** (retour v0.12.0 desktop, "ils sont
|
|
||||||
super cons, ne bougent pas tant que le joueur n'apparaît pas, aucun
|
|
||||||
idle pattern ou idle animation, plantés là") — EN COURS : willPatrol
|
|
||||||
est un champ mort 2017 (stocké jamais lu) ; chantier = idle patrol
|
|
||||||
(NavMesh aléatoire à courte portée) + animation idle dédiée (art ?)
|
|
||||||
- [ ] **Desktop : touches reconfigurables** (retour v0.12.0, "peut-on
|
|
||||||
changer les touches ?") — TRACÉ (feature v0.13.0) : écran de rebinding
|
|
||||||
dans Settings > CONTROLS (desktop) + persistance PlayerPrefs ; les
|
|
||||||
codes moteurs sont Input.KeyCode (desktop GLFW) — lire des touches
|
|
||||||
dans les prefs et les mapper au lieu des constantes Player/TouchControls
|
|
||||||
- [ ] Test coop sur émulateur (client Android via 10.0.2.2) — BLOQUÉ : AVD
|
- [ ] Test coop sur émulateur (client Android via 10.0.2.2) — BLOQUÉ : AVD
|
||||||
zombie (processus 91234 état UE, impossible à tuer sans redémarrage)
|
zombie (processus 91234 état UE, impossible à tuer sans redémarrage)
|
||||||
- [ ] **Ennemis spawn DANS LES MURS en Exterminate**
|
- [ ] **Ennemis spawn DANS LES MURS en Exterminate** (retour v0.10.0, "je
|
||||||
- [x] **CRASH en Exterminate côté Android (v0.11.0)** (retour v0.11.0,
|
sais pas si c'est comme ça partout") — EN COURS (v0.11.0) : le spawner
|
||||||
"l'appli plante en exterminate") — FAIT (v0.12.0) : la cause racine du
|
tire un x aléatoire sans vérifier la solidité de la colonne ; fix =
|
||||||
crash au MENU était le multi-threading des entrées (touches écrites sur
|
raycast vertical vers le bas pour trouver le sol et spawner au-dessus
|
||||||
le thread UI, lues sur le thread GL sans synchronisation -> menu inerte
|
- [x] Crash au chargement d'Exterminate desktop (`NullPointerException:
|
||||||
puis comportements incohérents) ; fix = marshaling queueEvent
|
inputStream` sur DesktopRenderUtils.loadImage:126) — FAIT (v0.11.0) :
|
||||||
(AndroidLauncher) + machine à états Input down/up différé. Le procédural
|
la 2ᵉ lookup du loadImage desktop utilisait le chemin BRUT avec « .. »
|
||||||
Android lui-même charge maintenant sans crash (épreuve : seed loggué,
|
(non normalisé) → null dans le JarClassLoader ; normalisation +
|
||||||
26 segments, spawn au sol confirmé en jeu)
|
null-check lisible ; confirmé desktop : Exterminate charge, 3 ennemis
|
||||||
- [x] **CRASH en Defend côté Android (v0.11.0)** (retour v0.11.0,
|
spawnés, IA ATTACKING cible Player ✓
|
||||||
"le jeu plante aussi en Defend") — FAIT (v0.12.0) : même famille de
|
- [x] Lobby multi mort après erreur de connexion (QA v0.10.0 P2) — FAIT
|
||||||
crash que Exterminate (inputs + Settings du pause) ; Defend chargé et
|
(v0.11.0) : connecting réinitialisé dans onError + erreur affichée en
|
||||||
joué en réel sur émulateur sans crash (vagues WAVE, cryopod attaqué
|
GuiText (réessayez / changez de serveur)
|
||||||
par l'IA corrigée)
|
- [x] Garde 2..6 options absente du constructeur protégé Menu() (QA
|
||||||
- [x] **Settings ne s'affichent plus côté Android (v0.11.0)** (retour
|
v0.10.0 P3) — FAIT : garde unifiée checkOptionsCount()
|
||||||
v0.11.0, "les settings ne s'affichent plus") — FAIT (v0.12.0) : (1) le
|
- [x] presetIndex du lobby désynchronisé du serveur persisté (QA v0.10.0
|
||||||
"walk" v0.9.0 via getComponentsOfType ne parcourt PAS la hiérarchie
|
P3) — FAIT : aligné sur mp_host/mp_port au chargement
|
||||||
(GameObject.java:297-303) -> contenu caché sous le fond depth 10 ;
|
- [ ] Angle mort vertical de l'acquisition IA (rayons horizontaux seuls,
|
||||||
depths 12 posés À LA CRÉATION sur chaque élément ; (2) le clic ne
|
|
||||||
hit-testait que le TEXTE (le menu pause "Settings" est court) ->
|
|
||||||
zone de clic = barre entière (Menu.optionRects) ; (3) le tap court
|
|
||||||
down+up même frame était écrasé par la machine à états Input ->
|
|
||||||
releases différées d'une frame ; (4) le HUD de jeu repassait DEVANT
|
|
||||||
après close() -> masqué pendant le panneau. Prouvé émulateur : le
|
|
||||||
panneau s'ouvre depuis le menu principal ET le menu pause (captures)
|
|
||||||
- [ ] **IA ennemie : détection + pathfinding défaillants** (retour
|
|
||||||
v0.11.0 Android) — EN COURS (2 volets) : (1) acquisition FAIT
|
|
||||||
(v0.12.0) : le visionCheck exigeait une LIGNE DE VUE or les spawns
|
|
||||||
multi-niveaux ont la LOS coupée -> jamais acquis -> IDLE planté ;
|
|
||||||
désormais acquisition à la portée SANS LOS (les murs bloquent
|
|
||||||
toujours le TIR : ATTACKING exige canSeeEnemy) — prouvé en jeu
|
|
||||||
("acquisition cible Player dist=1639" + "IDLE -> TRACKING") ;
|
|
||||||
(2) POURSUITE inter-étages : NavMesh.java a ses Jump links
|
|
||||||
COMMENTÉS depuis 2017 -> aucun chemin vertical possible ->
|
|
||||||
"aucun chemin NavMesh vers Player" en boucle -> ennemis bloqués ;
|
|
||||||
dev-IA en cours sur la réactivation/adaptation des jump links
|
|
||||||
- [x] **CRASHS Android en masse (v0.11.0)** (retour v0.11.0, "le jeu
|
|
||||||
crash énormément, faut vraiment ajouter des logs larges que je pourrai
|
|
||||||
partager") — FAIT (v0.12.0) : crash-<date>.txt (stack + causes + device
|
|
||||||
+ journal intégral) et gamelog-latest.txt (dump 5 s, survit au kill)
|
|
||||||
dans /sdcard/Android/data/fr.siphonight.lostsectorport/files/ sans
|
|
||||||
root ; procédural entièrement loggué avec seed reproductible ;
|
|
||||||
gardes anti-NPE 2017 (segments null, tileset manquant, glyphe absent)
|
|
||||||
- [ ] **Émulateur Android instable (environnement, pas le jeu)** : l'AVD
|
|
||||||
ls05 (swiftshader_indirect, contournement du GPU host bloqué par le
|
|
||||||
zombie 91234) meurt toutes les ~10-20 min de test — 4 relances le
|
|
||||||
15/11 soir. À surveiller : si le redémarrage machine (zombie tué) ne
|
|
||||||
suffit pas, tester -accel off / un AVD API plus basse / une image
|
|
||||||
google_apis au lieu de google_atd (retour v0.11.0, "le jeu crash
|
|
||||||
énormément, faut vraiment ajouter des logs larges que je pourrai
|
|
||||||
partager") — EN COURS : le système crash-<date>.txt +
|
|
||||||
gamelog-latest.txt (export sans root dans
|
|
||||||
Android/data/fr.siphonight.lostsectorport/files/) vient d'être
|
|
||||||
implémenté pour CETTE raison ; livraison dans la prochaine release
|
|
||||||
pour que les crashs de l'utilisateur remontent leurs stacks + logs
|
|
||||||
- [x] **Menu multijoueur hors DA + crash à la recherche de partie**
|
|
||||||
(retour v0.11.0, "menu multi dégeulasse et crash dès la recherche") —
|
|
||||||
FAIT (v0.12.0) : (1) CRASH reproduit et corrigé : le manifest n'avait
|
|
||||||
PAS la permission INTERNET -> DatagramSocket EPERM -> FATAL sur le
|
|
||||||
thread GL ; + catch défensif sur la création de socket + timeout 8s
|
|
||||||
(serveur mort -> cadre rouge lisible, lobby réutilisable) ; le glyphe
|
|
||||||
"/" absent de l'atlas NPE-ait aussi GuiText.setText (garde moteur
|
|
||||||
ajouté) ; (2) DA : refonte avec les cadres néon du menu principal +
|
|
||||||
cadre d'erreur rouge généré (scripts/gen-lobby-sprites.py), zone de
|
|
||||||
clic = barres entières — prouvé émulateur (captures)
|
|
||||||
- [x] **Tests extensifs de TOUS les modes de jeu** (retour v0.11.0,
|
|
||||||
"tester tous les modes de façon extensive") — FAIT (v0.12.0) :
|
|
||||||
batterie d'anti-régression automatisée scripts/test-android.sh
|
|
||||||
(26 checks : menu, Defend tir+pouvoir, pause II, Exterminate
|
|
||||||
procédural+spawn sol, Survival timer, Settings x2, lobby multi
|
|
||||||
LANCER serveur mort, export logs) = PASS 26/26 + captures revues
|
|
||||||
visuellement ; reste la coop desktop+émulateur (10.0.2.2) à jouer
|
|
||||||
avec le matchmaker local (les inputs Android marchent maintenant)
|
|
||||||
- [ ] **Portes fonctionnelles + salles multi-niveaux** (feedback v0.11.0,
|
- [ ] **Portes fonctionnelles + salles multi-niveaux** (feedback v0.11.0,
|
||||||
"rendre les portes utilisables par les joueurs pour passer dans
|
"rendre les portes utilisables par les joueurs pour passer dans
|
||||||
d'autres parties de la map") — GROS chantier, s'articule avec les
|
d'autres parties de la map") — GROS chantier, s'articule avec les
|
||||||
@ -140,6 +73,10 @@ commande ligne) :
|
|||||||
y+100 fixe) : joueur directement au-dessus/dessous jamais acquis —
|
y+100 fixe) : joueur directement au-dessus/dessous jamais acquis —
|
||||||
atténué par le NavMesh + suivi de cible ; amélioration possible
|
atténué par le NavMesh + suivi de cible ; amélioration possible
|
||||||
(raycast vertical ou cone de vision)
|
(raycast vertical ou cone de vision)
|
||||||
|
- [ ] Macos.zip = natives Intel uniquement (crash UnsatisfiedLinkError
|
||||||
|
liblwjgl sur Mac ARM : les natives x64 ne se chargent pas depuis une
|
||||||
|
JVM aarch64) — DOC plus forte nécessaire dans README/CHANGELOG
|
||||||
|
(macos.zip = Intel + JVM Rosetta uniquement ; macos-arm64.zip = Apple
|
||||||
Silicon) OU publier les deux jeux de natives dans le même zip
|
Silicon) OU publier les deux jeux de natives dans le même zip
|
||||||
(+2 Mo)
|
(+2 Mo)
|
||||||
|
|
||||||
@ -342,69 +279,7 @@ reste du portage Android.
|
|||||||
(chemin data/kubrows corrigé)
|
(chemin data/kubrows corrigé)
|
||||||
- [ ] Test coop sur émulateur (client Android via 10.0.2.2) — BLOQUÉ : AVD
|
- [ ] Test coop sur émulateur (client Android via 10.0.2.2) — BLOQUÉ : AVD
|
||||||
zombie (processus 91234 état UE, impossible à tuer sans redémarrage)
|
zombie (processus 91234 état UE, impossible à tuer sans redémarrage)
|
||||||
- [ ] **Ennemis spawn DANS LES MURS en Exterminate**
|
- [ ] **Ennemis spawn DANS LES MURS en Exterminate** (retour v0.10.0, "je
|
||||||
- [ ] **CRASH en Exterminate côté Android (v0.11.0)**
|
|
||||||
- [ ] **CRASH en Defend côté Android (v0.11.0)**
|
|
||||||
- [ ] **Settings ne s'affichent plus côté Android (v0.11.0)**
|
|
||||||
- [ ] **IA ennemie : détection + pathfinding défaillants**
|
|
||||||
- [x] **Écran gris côté utilisateur** (retour v0.11.0, "écran gris de mon
|
|
||||||
côté") — RÉSOLU : PAS le jeu, c'est la FENÊTRE de l'émulateur
|
|
||||||
(front-end Qt + swiftshader) qui perd son rendu. Preuve
|
|
||||||
simultanée du 15/11 23:32 : capture adb de l'utilisateur montrant la
|
|
||||||
fenêtre ls05 entièrement grise pendant qu'au même moment
|
|
||||||
`adb exec-out screencap` du MÊME AVD rend le jeu parfait
|
|
||||||
(menu, Exterminate avec tuiles, HUD complet). L'AVD tourne, la
|
|
||||||
surface de la fenêtre est morte. Fix = relancer l'émulateur
|
|
||||||
(ou redémarrage machine pour débloquer le GPU host et quitter
|
|
||||||
swiftshader — cf. item AVD instable ci-dessus). Reste un polish
|
|
||||||
distinct : la transition inter-niveaux montre ~2 s de monde noir
|
|
||||||
(HUD rendu, tuiles absentes — textures détruites/rechargées via
|
|
||||||
destroyAllTextures) — envisager un écran de chargement (retour
|
|
||||||
v0.11.0 Android, "l'IA détecte toujours pas correctement les joueurs
|
|
||||||
avant que je ne me place directement devant eux, ils tentent pas de
|
|
||||||
venir me chercher par pathfinding, restent plantés là à attendre") —
|
|
||||||
EN COURS : le visionCheck bidirectionnel (fix v0.10.0) reste limité
|
|
||||||
(rayons horizontaux, portée courte ?) ; le NavMesh est censé faire le
|
|
||||||
chemin mais les ennemis restent IDLE à distance ; chantier = portée
|
|
||||||
d'acquisition + poursuite NavMesh active + angle mort vertical (item
|
|
||||||
déjà tracé)
|
|
||||||
- [ ] **CRASHS Android en masse (v0.11.0)**
|
|
||||||
- [ ] **Émulateur Android instable (environnement, pas le jeu)** : l'AVD
|
|
||||||
ls05 (swiftshader_indirect, contournement du GPU host bloqué par le
|
|
||||||
zombie 91234) meurt toutes les ~10-20 min de test — 4 relances le
|
|
||||||
15/11 soir. À surveiller : si le redémarrage machine (zombie tué) ne
|
|
||||||
suffit pas, tester -accel off / un AVD API plus basse / une image
|
|
||||||
google_apis au lieu de google_atd (retour v0.11.0, "le jeu crash
|
|
||||||
énormément, faut vraiment ajouter des logs larges que je pourrai
|
|
||||||
partager") — EN COURS : le système crash-<date>.txt +
|
|
||||||
gamelog-latest.txt (export sans root dans
|
|
||||||
Android/data/fr.siphonight.lostsectorport/files/) vient d'être
|
|
||||||
implémenté pour CETTE raison ; livraison dans la prochaine release
|
|
||||||
pour que les crashs de l'utilisateur remontent leurs stacks + logs
|
|
||||||
- [ ] **Menu multijoueur hors DA + crash à la recherche de partie**
|
|
||||||
(retour v0.11.0 Android, "menu multi dégeulasse, ne respecte pas la
|
|
||||||
DA du reste des menus, et crash dès la sélection d'une recherche de
|
|
||||||
partie") — EN COURS : crash à reproduire (le lobby existait pas
|
|
||||||
quand il a tenté, mais un crash est inacceptable) ; refonte visuelle
|
|
||||||
du lobby selon la DA (cadres bleus néon du menu principal)
|
|
||||||
- [ ] **Tests extensifs de TOUS les modes de jeu** (retour v0.11.0 Android,
|
|
||||||
"tester également tous les modes de jeu de façon extensive") — EN
|
|
||||||
COURS sur émulateur : Defend ✓, Exterminate ✓ (22:50, spawn sol
|
|
||||||
confirmé), reste Survival, wall jump, pause II, coop émulateur+desktop
|
|
||||||
via 10.0.2.2, lobby multi (retour
|
|
||||||
v0.11.0, "les settings ne s'affichent plus") — EN COURS : le panneau
|
|
||||||
Settings ne se rend pas au tap sur l'option du menu ; suspect =
|
|
||||||
depths (le panneau est à depth 10/12 depuis le fix v0.10.0 "logo
|
|
||||||
au-dessus des Settings") ou le tap lui-même qui ne déclenche pas les
|
|
||||||
options du menu (constaté aussi sur émulateur : aucun tap sur
|
|
||||||
Defend/Exterminate/Settings/Quit ne réagit) (retour v0.11.0,
|
|
||||||
"le jeu plante aussi en Defend") — EN COURS : même famille de crash
|
|
||||||
que Exterminate ? à reproduire + stack traces des deux (retour v0.11.0,
|
|
||||||
"l'appli plante en exterminate") — EN COURS : reproduction sur
|
|
||||||
émulateur ls05 (swiftshader) ; suspect n°1 = chargement procédural
|
|
||||||
des tilesets côté Android (la famille de crash inputStream desktop
|
|
||||||
était spécifique au JarClassLoader, il doit y avoir l'équivalent
|
|
||||||
Android — AssetManager) (retour v0.10.0, "je
|
|
||||||
sais pas si c'est comme ça partout") — EN COURS (v0.11.0) : le spawner
|
sais pas si c'est comme ça partout") — EN COURS (v0.11.0) : le spawner
|
||||||
tire un x aléatoire sans vérifier la solidité de la colonne ; fix =
|
tire un x aléatoire sans vérifier la solidité de la colonne ; fix =
|
||||||
raycast vertical vers le bas pour trouver le sol et spawner au-dessus
|
raycast vertical vers le bas pour trouver le sol et spawner au-dessus
|
||||||
@ -421,6 +296,7 @@ reste du portage Android.
|
|||||||
v0.10.0 P3) — FAIT : garde unifiée checkOptionsCount()
|
v0.10.0 P3) — FAIT : garde unifiée checkOptionsCount()
|
||||||
- [x] presetIndex du lobby désynchronisé du serveur persisté (QA v0.10.0
|
- [x] presetIndex du lobby désynchronisé du serveur persisté (QA v0.10.0
|
||||||
P3) — FAIT : aligné sur mp_host/mp_port au chargement
|
P3) — FAIT : aligné sur mp_host/mp_port au chargement
|
||||||
|
- [ ] Angle mort vertical de l'acquisition IA (rayons horizontaux seuls,
|
||||||
- [ ] **Portes fonctionnelles + salles multi-niveaux** (feedback v0.11.0,
|
- [ ] **Portes fonctionnelles + salles multi-niveaux** (feedback v0.11.0,
|
||||||
"rendre les portes utilisables par les joueurs pour passer dans
|
"rendre les portes utilisables par les joueurs pour passer dans
|
||||||
d'autres parties de la map") — GROS chantier, s'articule avec les
|
d'autres parties de la map") — GROS chantier, s'articule avec les
|
||||||
@ -434,5 +310,9 @@ reste du portage Android.
|
|||||||
y+100 fixe) : joueur directement au-dessus/dessous jamais acquis —
|
y+100 fixe) : joueur directement au-dessus/dessous jamais acquis —
|
||||||
atténué par le NavMesh + suivi de cible ; amélioration possible
|
atténué par le NavMesh + suivi de cible ; amélioration possible
|
||||||
(raycast vertical ou cone de vision)
|
(raycast vertical ou cone de vision)
|
||||||
|
- [ ] Macos.zip = natives Intel uniquement (crash UnsatisfiedLinkError
|
||||||
|
liblwjgl sur Mac ARM : les natives x64 ne se chargent pas depuis une
|
||||||
|
JVM aarch64) — DOC plus forte nécessaire dans README/CHANGELOG
|
||||||
|
(macos.zip = Intel + JVM Rosetta uniquement ; macos-arm64.zip = Apple
|
||||||
Silicon) OU publier les deux jeux de natives dans le même zip
|
Silicon) OU publier les deux jeux de natives dans le même zip
|
||||||
(+2 Mo)
|
(+2 Mo)
|
||||||
|
|||||||
@ -34,8 +34,8 @@ android {
|
|||||||
applicationId 'fr.siphonight.lostsectorport'
|
applicationId 'fr.siphonight.lostsectorport'
|
||||||
minSdk 24 // java.util.stream (parallelStream dans GraphicsEngine)
|
minSdk 24 // java.util.stream (parallelStream dans GraphicsEngine)
|
||||||
targetSdk 36
|
targetSdk 36
|
||||||
versionCode 12
|
versionCode 1
|
||||||
versionName '0.12.0'
|
versionName '0.2.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
|
|||||||
@ -9,12 +9,6 @@
|
|||||||
-->
|
-->
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<!-- INTERNET : le multi (matchmaker UDP + client TCP) crée des sockets —
|
|
||||||
sans cette permission, DatagramSocket échoue en EPERM et le lobby
|
|
||||||
CRASHAIT l'appli (retour v0.11.0 : "crash dès la sélection d'une
|
|
||||||
recherche de partie"). -->
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:label="Lost Sector"
|
android:label="Lost Sector"
|
||||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||||
|
|||||||
@ -1,24 +1,11 @@
|
|||||||
package com.ezardlabs.lostsector;
|
package com.ezardlabs.lostsector;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import com.ezardlabs.dethsquare.util.AndroidAudioUtils;
|
import com.ezardlabs.dethsquare.util.AndroidAudioUtils;
|
||||||
import com.ezardlabs.dethsquare.util.AndroidLauncher;
|
import com.ezardlabs.dethsquare.util.AndroidLauncher;
|
||||||
import com.ezardlabs.dethsquare.util.GameLog;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Point d'entrée Android du jeu (équivalent de Main.java côté desktop).
|
* Point d'entrée Android du jeu (équivalent de Main.java côté desktop).
|
||||||
@ -27,37 +14,15 @@ import java.util.concurrent.Executors;
|
|||||||
* référentiel 1920x1080 en ScaleMode.WIDTH, la rotation casserait la mise en
|
* référentiel 1920x1080 en ScaleMode.WIDTH, la rotation casserait la mise en
|
||||||
* page des menus. La config landscape/hard-key est déclarée dans le manifest
|
* page des menus. La config landscape/hard-key est déclarée dans le manifest
|
||||||
* pour éviter toute recréation de l'Activity en cours de partie.
|
* pour éviter toute recréation de l'Activity en cours de partie.
|
||||||
*
|
|
||||||
* Diagnostic SANS adb : logcat n'est pas accessible à l'utilisateur, donc
|
|
||||||
* tout ce qui est tracé via GameLog est mis en disque ici :
|
|
||||||
* - gamelog-latest.txt : le journal des 4000 dernières lignes, réécrit
|
|
||||||
* toutes les ~5 s (throttlé dans GameLog.tick, branché sur la boucle de
|
|
||||||
* rendu GraphicsEngine) — survit à un kill sans crash ;
|
|
||||||
* - crash-<date>.txt : écrit une fois au crash, contient la stack complète
|
|
||||||
* + l'environnement + le journal GameLog ; le handler par défaut est
|
|
||||||
* TOUJOURS invoqué ensuite (dialogue/trace Android standard conservés).
|
|
||||||
*
|
|
||||||
* Dossier : getExternalFilesDir(null) — accessible SANS root via
|
|
||||||
* adb pull /sdcard/Android/data/fr.siphonight.lostsectorport/files/
|
|
||||||
* et visible par l'utilisateur dans Fichiers > Android > data > ... > files.
|
|
||||||
*/
|
*/
|
||||||
public class AndroidGameActivity extends Activity {
|
public class AndroidGameActivity extends Activity {
|
||||||
private AndroidLauncher launcher;
|
private AndroidLauncher launcher;
|
||||||
private AndroidAudioUtils audio;
|
private AndroidAudioUtils audio;
|
||||||
|
|
||||||
// Écritures disque du dump périodique sur un thread dédié : le thread GL
|
|
||||||
// ne bloque JAMAIS sur l'I/O (politique du dépôt : pas d'I/O dans le
|
|
||||||
// chemin chaud). Un seul thread = ordre d'écriture préservé.
|
|
||||||
private final ExecutorService logWriter = Executors.newSingleThreadExecutor();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// AVANT tout le reste : un crash pendant l'init (surface GL, assets,
|
|
||||||
// game.create) doit lui aussi produire un crash-<date>.txt.
|
|
||||||
installDiagnostics();
|
|
||||||
|
|
||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
launcher = new AndroidLauncher(this);
|
launcher = new AndroidLauncher(this);
|
||||||
@ -74,104 +39,6 @@ public class AndroidGameActivity extends Activity {
|
|||||||
audio = (AndroidAudioUtils) launcher.getAudio();
|
audio = (AndroidAudioUtils) launcher.getAudio();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Installe le dump périodique du GameLog et le crash handler.
|
|
||||||
* Appelé en tête de onCreate, avant toute création GL.
|
|
||||||
*/
|
|
||||||
private void installDiagnostics() {
|
|
||||||
// Résolu UNE fois sur le thread UI : getExternalFilesDir fait du
|
|
||||||
// stat disque, on ne le rappelle jamais depuis le thread GL.
|
|
||||||
final File logDir = resolveLogDir();
|
|
||||||
|
|
||||||
// 1) Dump périodique : GameLog.tick() (boucle de rendu) appelle ce
|
|
||||||
// consommateur toutes les ~5 s SI du contenu est nouveau ; on ne
|
|
||||||
// fait qu'empiler l'écriture sur logWriter — aucun blocage GL.
|
|
||||||
GameLog.setFlushConsumer(snapshot -> logWriter.execute(() -> {
|
|
||||||
if (logDir == null) return;
|
|
||||||
writeAtomic(new File(logDir, "gamelog-latest.txt"), snapshot);
|
|
||||||
}));
|
|
||||||
|
|
||||||
// 2) Crash handler : capture AVANT la mort du process. Le handler
|
|
||||||
// par défaut est invoqué EN DERNIER pour conserver le crash Android
|
|
||||||
// standard (dialogue, trace système, ANR/tombstone).
|
|
||||||
final Thread.UncaughtExceptionHandler previous = Thread.getDefaultUncaughtExceptionHandler();
|
|
||||||
Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
|
|
||||||
try {
|
|
||||||
if (logDir != null) {
|
|
||||||
String ts = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.US)
|
|
||||||
.format(new Date());
|
|
||||||
StringBuilder sb = new StringBuilder(8192);
|
|
||||||
sb.append("== CRASH Lost Sector ==\n");
|
|
||||||
sb.append("horodatage : ").append(
|
|
||||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z", Locale.US)
|
|
||||||
.format(new Date())).append('\n');
|
|
||||||
sb.append("app : v").append(appVersion()).append('\n');
|
|
||||||
sb.append("device : ").append(Build.MANUFACTURER).append(' ')
|
|
||||||
.append(Build.MODEL).append(" — Android ")
|
|
||||||
.append(Build.VERSION.RELEASE).append(" (API ")
|
|
||||||
.append(Build.VERSION.SDK_INT).append(")\n");
|
|
||||||
sb.append("thread : ").append(thread.getName()).append('\n');
|
|
||||||
sb.append("\n== STACK TRACE ==\n");
|
|
||||||
// printStackTrace(PrintWriter) inclut déjà la chaîne de causes
|
|
||||||
// (Caused by:) — inutile de la dérouler à la main.
|
|
||||||
sb.append(GameLog.getStackTraceString(throwable));
|
|
||||||
sb.append("\n\n== GAMELOG (4000 dernières lignes) ==\n");
|
|
||||||
sb.append(GameLog.snapshot());
|
|
||||||
writeAtomic(new File(logDir, "crash-" + ts + ".txt"), sb.toString());
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
// Le rapport NE DOIT JAMAIS masquer le crash d'origine :
|
|
||||||
// on avale et on laisse mourir le process normalement.
|
|
||||||
}
|
|
||||||
if (previous != null) {
|
|
||||||
previous.uncaughtException(thread, throwable);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dossier des dumps : external PREFERÉ (l'utilisateur peut le voir dans
|
|
||||||
* Fichiers et l'extraire sans root) ; fallback interne si le stockage
|
|
||||||
* externe n'est pas monté (getExternalFilesDir peut renvoyer null).
|
|
||||||
*/
|
|
||||||
private File resolveLogDir() {
|
|
||||||
File ext = getExternalFilesDir(null);
|
|
||||||
return ext != null ? ext : getFilesDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String appVersion() {
|
|
||||||
try {
|
|
||||||
return getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return "inconnue";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Écriture ATOMIQUE : tmp puis rename. POURQUOI : le fichier peut être
|
|
||||||
* tiré (adb pull / Fichiers) PENDANT la réécriture — sans rename, on
|
|
||||||
* risquait de lire un fichier tronqué et de croire à un log corrompu.
|
|
||||||
*/
|
|
||||||
private static void writeAtomic(File target, String content) {
|
|
||||||
try {
|
|
||||||
File tmp = new File(target.getParentFile(), target.getName() + ".tmp");
|
|
||||||
try (Writer w = new OutputStreamWriter(new FileOutputStream(tmp), StandardCharsets.UTF_8)) {
|
|
||||||
w.write(content);
|
|
||||||
}
|
|
||||||
// renameTo remplace la cible existante sur Linux/Android.
|
|
||||||
if (!tmp.renameTo(target)) {
|
|
||||||
target.delete();
|
|
||||||
if (!tmp.renameTo(target)) {
|
|
||||||
GameLog.w("LS-INIT", "renommage du dump impossible : " + target.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Pas de writeAtomic récursif : GameLog.e n'écrit QUE dans le
|
|
||||||
// tampon mémoire + logcat, aucune boucle infinie possible.
|
|
||||||
GameLog.e("LS-INIT", "écriture dump impossible : " + target.getName(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(android.view.MotionEvent event) {
|
public boolean onTouchEvent(android.view.MotionEvent event) {
|
||||||
launcher.onTouchEvent(event);
|
launcher.onTouchEvent(event);
|
||||||
|
|||||||
@ -2,8 +2,6 @@ package com.ezardlabs.dethsquare.util;
|
|||||||
|
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
|
|
||||||
import com.ezardlabs.dethsquare.util.GameLog;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -34,10 +32,6 @@ public class AndroidIOUtils implements IOUtils {
|
|||||||
// Même contrat que ClassLoader.getSystemResourceAsStream côté desktop :
|
// Même contrat que ClassLoader.getSystemResourceAsStream côté desktop :
|
||||||
// null quand la ressource n'existe pas (les appelants testent le null
|
// null quand la ressource n'existe pas (les appelants testent le null
|
||||||
// et lèvent ResourceNotFoundError).
|
// et lèvent ResourceNotFoundError).
|
||||||
// Debug (pas error) : le null fait partie du contrat, mais la
|
|
||||||
// PREMIÈRE trace d'un asset manquant reste précieuse dans le
|
|
||||||
// tampon GameLog quand une map/tileset charge mal.
|
|
||||||
GameLog.d("LS-INIT", "asset introuvable : " + path);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,7 +50,7 @@ public class AndroidIOUtils implements IOUtils {
|
|||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
GameLog.e("LS-INIT", "lecture de '" + path + "' interrompue", e);
|
e.printStackTrace();
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
return data.toArray(new String[data.size()]);
|
return data.toArray(new String[data.size()]);
|
||||||
@ -80,12 +74,8 @@ public class AndroidIOUtils implements IOUtils {
|
|||||||
}
|
}
|
||||||
return list.toArray(new String[list.size()]);
|
return list.toArray(new String[list.size()]);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// POURQUOI error (et pas err+printStackTrace) : files.lsd est
|
System.err.println("Failed to load " + dirPath + " files.lsd");
|
||||||
// l'INDEX de toutes les ressources — s'il manque, TOUTES les
|
e.printStackTrace();
|
||||||
// énumérations renvoient vide (génération procédurale morte,
|
|
||||||
// prefabs introuvables). La stack va dans le tampon GameLog.
|
|
||||||
GameLog.e("LS-INIT", "index files.lsd de '" + dirPath + "' illisible — "
|
|
||||||
+ "aucune ressource énumérable (généré par la tâche Gradle indexResources)", e);
|
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,11 +35,11 @@ import static android.opengl.GLES30.glClearColor;
|
|||||||
* game.create() est différé au premier onSurfaceChanged pour conserver cet
|
* game.create() est différé au premier onSurfaceChanged pour conserver cet
|
||||||
* ordre (le jeu lit Screen.width dès le menu).
|
* ordre (le jeu lit Screen.width dès le menu).
|
||||||
*
|
*
|
||||||
* Entrées : les MotionEvents sont snapshot côté thread UI puis MARSHALÉS sur
|
* Entrées : les MotionEvents sont envoyés au core via Input.addTouch/moveTouch/
|
||||||
* le thread GL via GLSurfaceView.queueEvent (voir le commentaire de
|
* removeTouch/cancelTouch (consommés par Input.update() sur la branche
|
||||||
* onTouchEvent pour le POURQUOI). Toute la synthèse de contrôles (boutons
|
* ANDROID). Toute la synthèse de contrôles (boutons virtuels, clic souris) vit
|
||||||
* virtuels, clic souris) vit dans TouchControls, côté jeu — le launcher reste
|
* dans TouchControls, côté jeu — le launcher reste un simple pont
|
||||||
* un simple pont MotionEvent -> Input.
|
* MotionEvent -> Input.
|
||||||
*/
|
*/
|
||||||
public class AndroidLauncher extends Launcher implements GLSurfaceView.Renderer {
|
public class AndroidLauncher extends Launcher implements GLSurfaceView.Renderer {
|
||||||
private final Context context;
|
private final Context context;
|
||||||
@ -163,87 +163,47 @@ public class AndroidLauncher extends Launcher implements GLSurfaceView.Renderer
|
|||||||
* (Input.addTouch/moveTouch/removeTouch/cancelTouch, consommées par
|
* (Input.addTouch/moveTouch/removeTouch/cancelTouch, consommées par
|
||||||
* Input.update() sur la branche ANDROID).
|
* Input.update() sur la branche ANDROID).
|
||||||
*
|
*
|
||||||
* POURQUOI queueEvent : onTouchEvent tourne sur le thread UI, Input.update()
|
* Toute la SYNTHESE de contrôles (clavier virtuel, clic souris) vit dans
|
||||||
* sur le thread GL (onDrawFrame). Sans marshaling, changesToMake/touches/
|
* le HUD de jeu TouchControls (côté jeu, instancié en premier dans chaque
|
||||||
* keys sont écrits d'un thread et lus de l'autre SANS AUCUNE
|
* niveau) : c'est lui qui fait le hit-test des boutons et injecte les
|
||||||
* synchronisation (violation du memory model Java) : sur émulateur le
|
* touches via Input.injectKeyDown/injectKeyUp. Le launcher reste un
|
||||||
* thread GL peut ne jamais voir les taps — cause du menu principal inerte
|
* simple pont MotionEvent -> Input.
|
||||||
* v0.11.0 (le launcher logue le tap, TouchControls ne le voit jamais).
|
|
||||||
* queueEvent exécute les injections SUR le thread GL (FIFO, drainé avant
|
|
||||||
* la frame suivante) : tout l'état d'Input devient mono-thread. Bonus : le
|
|
||||||
* premier tap déclenche le bloc statique de Input (enregistrement de ses
|
|
||||||
* listeners de boucle) sur le thread GL lui-même — plus d'écriture
|
|
||||||
* concurrente dans updateListeners pendant que Launcher.update() itère.
|
|
||||||
*
|
|
||||||
* Le launcher reste un simple pont MotionEvent -> Input : la SYNTHESE
|
|
||||||
* (clavier virtuel, clic souris) vit dans TouchControls (côté jeu), seul
|
|
||||||
* endroit capable de hit-tester les boutons virtuels — synthétiser
|
|
||||||
* MOUSE_LEFT ici ferait un clic de menu sur chaque tap de bouton (FIRE
|
|
||||||
* déclencherait aussi l'attaque mêlée). Snapshot des coordonnées AVANT le
|
|
||||||
* queueEvent : le MotionEvent est recyclé dès le retour de cette méthode.
|
|
||||||
*/
|
*/
|
||||||
public void onTouchEvent(MotionEvent event) {
|
public void onTouchEvent(MotionEvent event) {
|
||||||
int action = event.getActionMasked();
|
int action = event.getActionMasked();
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
case MotionEvent.ACTION_POINTER_DOWN: {
|
case MotionEvent.ACTION_POINTER_DOWN:
|
||||||
int index = action == MotionEvent.ACTION_DOWN ? 0 : event.getActionIndex();
|
int pointerDownIndex = action == MotionEvent.ACTION_DOWN ? 0
|
||||||
final int downId = event.getPointerId(index);
|
: event.getActionIndex();
|
||||||
final float downX = event.getX(index);
|
int downId = event.getPointerId(pointerDownIndex);
|
||||||
final float downY = event.getY(index);
|
float downX = event.getX(pointerDownIndex);
|
||||||
glView.queueEvent(() -> {
|
float downY = event.getY(pointerDownIndex);
|
||||||
GameLog.d("LS-INPUT", "touch down id=" + downId + " (" + (int) downX + "," + (int) downY + ")");
|
GameLog.d("LS-INPUT", "touch down id=" + downId + " (" + (int) downX + "," + (int) downY + ")");
|
||||||
Input.addTouch(downId, downX, downY);
|
Input.addTouch(downId, downX, downY);
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
case MotionEvent.ACTION_MOVE:
|
||||||
case MotionEvent.ACTION_MOVE: {
|
for (int i = 0; i < event.getPointerCount(); i++) {
|
||||||
final int count = event.getPointerCount();
|
Input.moveTouch(event.getPointerId(i), event.getX(i), event.getY(i));
|
||||||
final int[] moveIds = new int[count];
|
|
||||||
final float[] moveXs = new float[count];
|
|
||||||
final float[] moveYs = new float[count];
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
moveIds[i] = event.getPointerId(i);
|
|
||||||
moveXs[i] = event.getX(i);
|
|
||||||
moveYs[i] = event.getY(i);
|
|
||||||
}
|
}
|
||||||
glView.queueEvent(() -> {
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
Input.moveTouch(moveIds[i], moveXs[i], moveYs[i]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP:
|
||||||
case MotionEvent.ACTION_POINTER_UP: {
|
case MotionEvent.ACTION_POINTER_UP:
|
||||||
int index = action == MotionEvent.ACTION_UP ? 0 : event.getActionIndex();
|
int upIndex = action == MotionEvent.ACTION_UP
|
||||||
final int upId = event.getPointerId(index);
|
? 0 : event.getActionIndex();
|
||||||
final float upX = event.getX(index);
|
int upId = event.getPointerId(upIndex);
|
||||||
final float upY = event.getY(index);
|
float upX = event.getX(upIndex);
|
||||||
glView.queueEvent(() -> {
|
float upY = event.getY(upIndex);
|
||||||
GameLog.d("LS-INPUT", "touch up id=" + upId + " (" + (int) upX + "," + (int) upY + ")");
|
GameLog.d("LS-INPUT", "touch up id=" + upId + " (" + (int) upX + "," + (int) upY + ")");
|
||||||
Input.removeTouch(upId, upX, upY);
|
Input.removeTouch(upId, upX, upY);
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
case MotionEvent.ACTION_CANCEL:
|
||||||
case MotionEvent.ACTION_CANCEL: {
|
for (int i = 0; i < event.getPointerCount(); i++) {
|
||||||
final int count = event.getPointerCount();
|
int cancelId = event.getPointerId(i);
|
||||||
final int[] cancelIds = new int[count];
|
GameLog.d("LS-INPUT", "touch cancel id=" + cancelId);
|
||||||
final float[] cancelXs = new float[count];
|
Input.cancelTouch(cancelId, event.getX(i), event.getY(i));
|
||||||
final float[] cancelYs = new float[count];
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
cancelIds[i] = event.getPointerId(i);
|
|
||||||
cancelXs[i] = event.getX(i);
|
|
||||||
cancelYs[i] = event.getY(i);
|
|
||||||
}
|
}
|
||||||
glView.queueEvent(() -> {
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
GameLog.d("LS-INPUT", "touch cancel id=" + cancelIds[i]);
|
|
||||||
Input.cancelTouch(cancelIds[i], cancelXs[i], cancelYs[i]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -147,7 +147,7 @@ public class AndroidRenderUtils implements RenderUtils {
|
|||||||
try {
|
try {
|
||||||
normalisedPath = new java.net.URI(path).normalize().getPath();
|
normalisedPath = new java.net.URI(path).normalize().getPath();
|
||||||
} catch (java.net.URISyntaxException e) {
|
} catch (java.net.URISyntaxException e) {
|
||||||
GameLog.w("LS-RENDER", "chemin non normalisable : '" + path + "' — utilisé tel quel", e);
|
e.printStackTrace();
|
||||||
normalisedPath = path;
|
normalisedPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,10 +197,7 @@ public class AndroidRenderUtils implements RenderUtils {
|
|||||||
|
|
||||||
return returnVals;
|
return returnVals;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// POURQUOI GameLog.e : un échec de décodage/chargement GL laissait
|
e.printStackTrace();
|
||||||
// un int[3] vide (textureName=0, taille 0) et le bug apparaissait
|
|
||||||
// à des kilomètres de sa cause. La stack va dans le crash report.
|
|
||||||
GameLog.e("LS-RENDER", "loadImage '" + path + "' : échec", e);
|
|
||||||
return new int[3];
|
return new int[3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,5 @@
|
|||||||
package com.ezardlabs.dethsquare.util;
|
package com.ezardlabs.dethsquare.util;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Journalisation multi-plateformes du moteur et du jeu.
|
* Journalisation multi-plateformes du moteur et du jeu.
|
||||||
*
|
*
|
||||||
@ -27,17 +18,6 @@ import java.nio.charset.StandardCharsets;
|
|||||||
* répétitifs (entrées utilisateur, textures, boucle) : leur volume est
|
* répétitifs (entrées utilisateur, textures, boucle) : leur volume est
|
||||||
* maîtrisé par le throttling aux sites d'appel.
|
* maîtrisé par le throttling aux sites d'appel.
|
||||||
*
|
*
|
||||||
* Tampon circulaire (POURQUOI) : sur Android, logcat n'est pas accessible à
|
|
||||||
* l'utilisateur (adb/root). Chaque appel d/i/e/w alimente donc un tampon en
|
|
||||||
* mémoire des 4000 dernières lignes (coût : une écriture tableau + un
|
|
||||||
* System.currentTimeMillis, AUCUNE I/O dans le chemin chaud). Le back-end
|
|
||||||
* Android lit ce tampon via snapshot() pour :
|
|
||||||
* - écrire gamelog-latest.txt toutes les ~5 s (dump périodique, throttlé
|
|
||||||
* par tick() — survit à un kill sans crash) ;
|
|
||||||
* - embarquer le journal COMPLET dans crash-<date>.txt au crash
|
|
||||||
* (AndroidGameActivity). Sur desktop, aucun consommateur n'est branché :
|
|
||||||
* le tampon reste disponible via dumpToFile(File) si besoin.
|
|
||||||
*
|
|
||||||
* Conventions de tags (préfixe LS-, lisible dans logcat comme en console) :
|
* Conventions de tags (préfixe LS-, lisible dans logcat comme en console) :
|
||||||
* LS-INIT initialisation moteur/plateforme
|
* LS-INIT initialisation moteur/plateforme
|
||||||
* LS-LEVEL chargement de niveau (LevelManager)
|
* LS-LEVEL chargement de niveau (LevelManager)
|
||||||
@ -59,14 +39,6 @@ public final class GameLog {
|
|||||||
void error(String tag, String message);
|
void error(String tag, String message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Consommateur du dump périodique (branché par le back-end Android :
|
|
||||||
* écrit gamelog-latest.txt hors du thread GL). Desktop n'en branche pas.
|
|
||||||
*/
|
|
||||||
public interface FlushConsumer {
|
|
||||||
void flush(String snapshot);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sink par défaut desktop : console standard/erreur. */
|
/** Sink par défaut desktop : console standard/erreur. */
|
||||||
private static final Sink SYSTEM_SINK = new Sink() {
|
private static final Sink SYSTEM_SINK = new Sink() {
|
||||||
@Override
|
@Override
|
||||||
@ -92,27 +64,6 @@ public final class GameLog {
|
|||||||
|
|
||||||
private static Sink sink = SYSTEM_SINK;
|
private static Sink sink = SYSTEM_SINK;
|
||||||
|
|
||||||
// ---- Tampon circulaire ----
|
|
||||||
/** 4000 lignes : ~1 min de jeu dense à 60 logs/s, quelques Mo en RAM au pire. */
|
|
||||||
private static final int RING_CAPACITY = 4000;
|
|
||||||
private static final String[] ring = new String[RING_CAPACITY];
|
|
||||||
/** Compteur total de lignes écrites (monotone) : index = total % capacité. */
|
|
||||||
private static long totalLines = 0;
|
|
||||||
/** Origine des horodatages relatifs : "il y a combien de temps" plutôt qu'une date absolue. */
|
|
||||||
private static final long startMs = System.currentTimeMillis();
|
|
||||||
/**
|
|
||||||
* Verrou du tampon : le jeu écrit depuis le thread GL ET le thread UI
|
|
||||||
* Android (touch events) — deux écritures concurrentes ne doivent jamais
|
|
||||||
* corrompre l'ordre du journal, et snapshot() doit voir un état cohérent.
|
|
||||||
*/
|
|
||||||
private static final Object ringLock = new Object();
|
|
||||||
|
|
||||||
// ---- Dump périodique ----
|
|
||||||
private static volatile FlushConsumer flushConsumer = null;
|
|
||||||
/** Appelé UNIQUEMENT depuis la boucle de rendu (GraphicsEngine), thread GL. */
|
|
||||||
private static long tickCount = 0;
|
|
||||||
private static long lastFlushedTotal = -1;
|
|
||||||
|
|
||||||
private GameLog() {
|
private GameLog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,121 +74,24 @@ public final class GameLog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Branche le consommateur du dump périodique (AndroidGameActivity). */
|
|
||||||
public static void setFlushConsumer(FlushConsumer consumer) {
|
|
||||||
flushConsumer = consumer;
|
|
||||||
// -1 force un premier flush au prochain tick : le fichier existe dès
|
|
||||||
// les 5 premières secondes, même si le jeu ne loggue presque rien.
|
|
||||||
lastFlushedTotal = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void d(String tag, String message) {
|
public static void d(String tag, String message) {
|
||||||
record('D', tag, message);
|
|
||||||
sink.debug(tag, message);
|
sink.debug(tag, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void i(String tag, String message) {
|
public static void i(String tag, String message) {
|
||||||
record('I', tag, message);
|
|
||||||
sink.info(tag, message);
|
sink.info(tag, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void w(String tag, String message) {
|
public static void w(String tag, String message) {
|
||||||
record('W', tag, message);
|
|
||||||
sink.warn(tag, message);
|
sink.warn(tag, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Symétrique de e(tag, message, t) : stack dans le tampon ET le sink. */
|
|
||||||
public static void w(String tag, String message, Throwable t) {
|
|
||||||
String withStack = message + "\n" + getStackTraceString(t);
|
|
||||||
record('W', tag, withStack);
|
|
||||||
sink.warn(tag, withStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void e(String tag, String message) {
|
public static void e(String tag, String message) {
|
||||||
record('E', tag, message);
|
|
||||||
sink.error(tag, message);
|
sink.error(tag, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Erreur avec exception : la stack est rendue en texte et passée AU MÊME
|
|
||||||
* sink (et dans le tampon) — sur Android, t.printStackTrace() seul ne
|
|
||||||
* rattache pas la stack au tag GameLog et échappait donc au journal.
|
|
||||||
*/
|
|
||||||
public static void e(String tag, String message, Throwable t) {
|
public static void e(String tag, String message, Throwable t) {
|
||||||
String withStack = message + "\n" + getStackTraceString(t);
|
sink.error(tag, message);
|
||||||
record('E', tag, withStack);
|
t.printStackTrace();
|
||||||
sink.error(tag, withStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Équivalent plateforme-neutre de android.util.Log.getStackTraceString. */
|
|
||||||
public static String getStackTraceString(Throwable t) {
|
|
||||||
StringWriter sw = new StringWriter(512);
|
|
||||||
t.printStackTrace(new PrintWriter(sw));
|
|
||||||
return sw.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Appelé une fois par frame par GraphicsEngine : throttlé en interne. */
|
|
||||||
public static void tick() {
|
|
||||||
FlushConsumer consumer = flushConsumer;
|
|
||||||
if (consumer == null) {
|
|
||||||
return; // desktop : rien à faire, coût = 1 lecture de référence
|
|
||||||
}
|
|
||||||
// Throttling : ~1 tentative toutes les 300 frames (5 s à 60 fps) —
|
|
||||||
// politique du dépôt : jamais d'I/O par frame, et le test "nouveau
|
|
||||||
// contenu" évite de réécrire un fichier identique.
|
|
||||||
if (++tickCount % 300 != 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
long current;
|
|
||||||
synchronized (ringLock) {
|
|
||||||
current = totalLines;
|
|
||||||
}
|
|
||||||
if (current == lastFlushedTotal) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
lastFlushedTotal = current;
|
|
||||||
try {
|
|
||||||
consumer.flush(snapshot());
|
|
||||||
} catch (Throwable t) {
|
|
||||||
// Un échec d'écriture ne doit JAMAIS tuer le thread GL : on
|
|
||||||
// trace et on tentera au prochain tick.
|
|
||||||
e("LS-INIT", "dump périodique du GameLog en échec", t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Journal complet (4000 dernières lignes), du plus ancien au plus récent. */
|
|
||||||
public static String snapshot() {
|
|
||||||
synchronized (ringLock) {
|
|
||||||
if (totalLines == 0) {
|
|
||||||
return "(GameLog vide)\n";
|
|
||||||
}
|
|
||||||
int n = (int) Math.min(totalLines, RING_CAPACITY);
|
|
||||||
StringBuilder sb = new StringBuilder(n * 80);
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
sb.append(ring[(int) ((totalLines - n + i) % RING_CAPACITY)]).append('\n');
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Écrit snapshot() dans un fichier (diagnostic manuel, desktop comme Android). */
|
|
||||||
public static boolean dumpToFile(File file) {
|
|
||||||
String content = snapshot();
|
|
||||||
try (Writer w = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
|
|
||||||
w.write(content);
|
|
||||||
return true;
|
|
||||||
} catch (IOException e) {
|
|
||||||
e("LS-INIT", "dumpToFile impossible : " + file, e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Une écriture tableau sous verrou : le chemin chaud reste minuscule. */
|
|
||||||
private static void record(char level, String tag, String message) {
|
|
||||||
String line = "[" + (System.currentTimeMillis() - startMs) + "ms] " + level + "/" + tag + ": " + message;
|
|
||||||
synchronized (ringLock) {
|
|
||||||
ring[(int) (totalLines % RING_CAPACITY)] = line;
|
|
||||||
totalLines++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -120,11 +120,7 @@ public class GuiText extends Component implements Bounded {
|
|||||||
|
|
||||||
if (text.length() < characters.length) {
|
if (text.length() < characters.length) {
|
||||||
for (int i = text.length(); i < characters.length; i++) {
|
for (int i = text.length(); i < characters.length; i++) {
|
||||||
// Garde-fou null : un glyphe absent de l'atlas (ex "/") laisse
|
characters[i].setActive(false);
|
||||||
// un trou dans characters — setText("") sur un texte contenant
|
|
||||||
// un tel glyphe crashait (lobby multi v0.11.0 : watchdog 8s ->
|
|
||||||
// afficherErreur -> NPE).
|
|
||||||
if (characters[i] != null) characters[i].setActive(false);
|
|
||||||
}
|
}
|
||||||
} else if (text.length() > characters.length) {
|
} else if (text.length() > characters.length) {
|
||||||
GameObject[] temp = new GameObject[text.length()];
|
GameObject[] temp = new GameObject[text.length()];
|
||||||
@ -159,13 +155,6 @@ public class GuiText extends Component implements Bounded {
|
|||||||
case ':':
|
case ':':
|
||||||
s = font.getSprite("colon");
|
s = font.getSprite("colon");
|
||||||
break;
|
break;
|
||||||
case '-':
|
|
||||||
// POURQUOI ce cas : l'atlas 2017 nomme le tiret "dash"
|
|
||||||
// (fonts/atlas.txt:40) — getSprite("-") échouait ->
|
|
||||||
// SpriteNotFound -> caractère sauté (trou dans le texte :
|
|
||||||
// "Serveur 2 3 : emulateur", QA v0.12.0 P2).
|
|
||||||
s = font.getSprite("dash");
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
try {
|
try {
|
||||||
s = font.getSprite(String.valueOf(text.charAt(i)));
|
s = font.getSprite(String.valueOf(text.charAt(i)));
|
||||||
@ -193,16 +182,9 @@ public class GuiText extends Component implements Bounded {
|
|||||||
characters[i] = GameObject.instantiate(new GameObject(String.valueOf(text.charAt(i)), guiRenderer),
|
characters[i] = GameObject.instantiate(new GameObject(String.valueOf(text.charAt(i)), guiRenderer),
|
||||||
new Vector2(transform.position.x + xOffset, transform.position.y));
|
new Vector2(transform.position.x + xOffset, transform.position.y));
|
||||||
characters[i].transform.setParent(transform);
|
characters[i].transform.setParent(transform);
|
||||||
} else if (characters[i].getComponent(GuiRenderer.class) != null) {
|
} else {
|
||||||
// Slot déjà créé : réutiliser son renderer (les trous null
|
|
||||||
// tombent dans la branche de création ci-dessus — un glyphe
|
|
||||||
// absent puis ré-apparu ne doit pas NPE, cf. garde-fou plus haut).
|
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
characters[i].getComponent(GuiRenderer.class).setSprite(s);
|
characters[i].getComponent(GuiRenderer.class).setSprite(s);
|
||||||
} else {
|
|
||||||
// Slot corrompu (GameObject sans renderer) : on le recrée.
|
|
||||||
characters[i] = null;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
characters[i].setActive(true);
|
characters[i].setActive(true);
|
||||||
|
|
||||||
|
|||||||
@ -95,19 +95,6 @@ public final class Input {
|
|||||||
*/
|
*/
|
||||||
private static HashMap<KeyCode, Integer> keys = new HashMap<>();
|
private static HashMap<KeyCode, Integer> keys = new HashMap<>();
|
||||||
private static HashMap<KeyCode, Integer> keyChanges = new HashMap<>();
|
private static HashMap<KeyCode, Integer> keyChanges = new HashMap<>();
|
||||||
/*
|
|
||||||
* Releases différés d'une frame (retour v0.11.0 Android) : un tap court
|
|
||||||
* produit down+up DANS LA MÊME frame (TouchControls injecte les deux à la
|
|
||||||
* suite ; côté desktop GLFW peut faire pareil pour un clic rapide). La
|
|
||||||
* fusion putAll écrasait le down par la up (last-write-wins) ->
|
|
||||||
* getKeyDown JAMAIS vrai : le menu pause s'ouvrait 1 fois sur 2, les
|
|
||||||
* options du menu aussi. Désormais : down appliqué à la frame N (état 0 =
|
|
||||||
* getKeyDown vrai), up re-queué et appliqué à la frame N+1 (état 2 =
|
|
||||||
* getKeyUp vrai puis suppression) — sémantique d'un vrai clic clavier.
|
|
||||||
* Edge assumé : un re-press dans la même frame que le release différé
|
|
||||||
* est ignoré (setKeyDown exige que la clé soit absente).
|
|
||||||
*/
|
|
||||||
private static final ArrayList<KeyCode> pendingReleases = new ArrayList<>();
|
|
||||||
|
|
||||||
private static boolean controllerConnected = false;
|
private static boolean controllerConnected = false;
|
||||||
private static HashMap<Button, Integer> buttons = new HashMap<>();
|
private static HashMap<Button, Integer> buttons = new HashMap<>();
|
||||||
@ -301,30 +288,7 @@ public final class Input {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Releases différés de la frame précédente : état 2 (getKeyUp vrai
|
keys.putAll(keyChanges);
|
||||||
// cette frame), l'aging ci-dessus les retirera au prochain update.
|
|
||||||
for (KeyCode keyCode : pendingReleases) {
|
|
||||||
keys.put(keyCode, 2);
|
|
||||||
}
|
|
||||||
pendingReleases.clear();
|
|
||||||
// Fusion down/up : un down présent dans CE lot gagne TOUJOURS (la up
|
|
||||||
// est différée), cf. commentaire du champ pendingReleases.
|
|
||||||
ArrayList<KeyCode> upsInBatch = new ArrayList<>();
|
|
||||||
ArrayList<KeyCode> downsInBatch = new ArrayList<>();
|
|
||||||
for (java.util.Map.Entry<KeyCode, Integer> e : keyChanges.entrySet()) {
|
|
||||||
if (e.getValue() == 0) downsInBatch.add(e.getKey());
|
|
||||||
else upsInBatch.add(e.getKey());
|
|
||||||
}
|
|
||||||
for (KeyCode keyCode : downsInBatch) {
|
|
||||||
keys.put(keyCode, 0);
|
|
||||||
}
|
|
||||||
for (KeyCode keyCode : upsInBatch) {
|
|
||||||
if (downsInBatch.contains(keyCode)) {
|
|
||||||
pendingReleases.add(keyCode);
|
|
||||||
} else {
|
|
||||||
keys.put(keyCode, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
keyChanges.clear();
|
keyChanges.clear();
|
||||||
//noinspection ForLoopReplaceableByForEach
|
//noinspection ForLoopReplaceableByForEach
|
||||||
for (int i = 0; i < touches.length; i++) {
|
for (int i = 0; i < touches.length; i++) {
|
||||||
@ -353,7 +317,6 @@ public final class Input {
|
|||||||
static void clearAll() {
|
static void clearAll() {
|
||||||
keys.clear();
|
keys.clear();
|
||||||
keyChanges.clear();
|
keyChanges.clear();
|
||||||
pendingReleases.clear();
|
|
||||||
changesToMake.clear();
|
changesToMake.clear();
|
||||||
touches = new Touch[0];
|
touches = new Touch[0];
|
||||||
touchesToRemove.clear();
|
touchesToRemove.clear();
|
||||||
|
|||||||
@ -4,8 +4,6 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import com.ezardlabs.dethsquare.util.GameLog;
|
|
||||||
|
|
||||||
import static com.ezardlabs.dethsquare.util.Dethsquare.IO;
|
import static com.ezardlabs.dethsquare.util.Dethsquare.IO;
|
||||||
import static com.ezardlabs.dethsquare.util.Dethsquare.RENDER;
|
import static com.ezardlabs.dethsquare.util.Dethsquare.RENDER;
|
||||||
|
|
||||||
@ -71,11 +69,7 @@ public final class TextureAtlas {
|
|||||||
new Sprite(Float.parseFloat(split2[0]) / width, Float.parseFloat(split2[1]) / height,
|
new Sprite(Float.parseFloat(split2[0]) / width, Float.parseFloat(split2[1]) / height,
|
||||||
Float.parseFloat(split2[2]) / width, Float.parseFloat(split2[3]) / height));
|
Float.parseFloat(split2[2]) / width, Float.parseFloat(split2[3]) / height));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException ignored) {
|
||||||
// POURQUOI plus un `ignored` : un atlas.txt absent/illisible
|
|
||||||
// laissait un atlas VIDE (aucun sprite) et crashait plus loin
|
|
||||||
// dans SpriteNotFoundInAtlasError sans lien avec la cause.
|
|
||||||
GameLog.e("LS-RENDER", "atlas '" + mapPath + "' : fichier de sprites illisible", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -100,11 +100,6 @@ private static final ArrayList<Renderer> renderers = new ArrayList<>();
|
|||||||
}
|
}
|
||||||
render(visible);
|
render(visible);
|
||||||
|
|
||||||
// Drain du tampon GameLog vers le dump disque (gamelog-latest.txt
|
|
||||||
// côté Android) : appelé chaque frame mais throttlé DANS GameLog.tick
|
|
||||||
// (1 écriture / 5 s max, aucune I/O si rien de nouveau).
|
|
||||||
GameLog.tick();
|
|
||||||
|
|
||||||
// Stat throttlé (1 ligne / 5 s à 60 fps) : indispensable pour
|
// Stat throttlé (1 ligne / 5 s à 60 fps) : indispensable pour
|
||||||
// diagnostiquer un écran noir (culling, caméra, échelle).
|
// diagnostiquer un écran noir (culling, caméra, échelle).
|
||||||
frameCount++;
|
frameCount++;
|
||||||
|
|||||||
@ -20,7 +20,6 @@ public class Matchmaker implements NetworkConstants {
|
|||||||
private long lastGamePing = 0;
|
private long lastGamePing = 0;
|
||||||
|
|
||||||
public Matchmaker(InetAddress ip, int serverPort) {
|
public Matchmaker(InetAddress ip, int serverPort) {
|
||||||
Network.setMatchmakerAddress(ip);
|
|
||||||
DatagramSocket socket = null;
|
DatagramSocket socket = null;
|
||||||
try {
|
try {
|
||||||
socket = new DatagramSocket();
|
socket = new DatagramSocket();
|
||||||
|
|||||||
@ -14,7 +14,6 @@ import java.io.InputStreamReader;
|
|||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.net.DatagramPacket;
|
import java.net.DatagramPacket;
|
||||||
import java.net.DatagramSocket;
|
import java.net.DatagramSocket;
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
@ -184,52 +183,15 @@ public class Network {
|
|||||||
GameListeners.addUpdateListener(Network::update);
|
GameListeners.addUpdateListener(Network::update);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adresse du matchmaker utilisée par CE client (posée par Matchmaker à
|
|
||||||
* sa construction). POURQUOI : le matchmaker transmet l'ip du hôte TELLE
|
|
||||||
* QU'IL LA VOIT — derrière un NAT/loopback c'est l'adresse du NAT, pas
|
|
||||||
* une adresse joignable par les clients (émulateur Android : le hôte est
|
|
||||||
* 10.0.2.2 mais le matchmaker le voit en 127.0.0.1 ; un client qui tente
|
|
||||||
* 127.0.0.1:2829 se connecte à LUI-MÊME -> tcpOut null -> crash
|
|
||||||
* requestState). Un joueur annoncé en loopback est donc réécrit vers
|
|
||||||
* l'hôte du matchmaker : dans ces topologies (émulateur, LAN local),
|
|
||||||
* hôte et matchmaker sont la même machine.
|
|
||||||
*/
|
|
||||||
private static InetAddress matchmakerAddress;
|
|
||||||
|
|
||||||
static void setMatchmakerAddress(InetAddress address) {
|
|
||||||
matchmakerAddress = address;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Réécrit une ip de joueur loopback vers l'hôte du matchmaker. */
|
|
||||||
private static String resolvableIp(String playerIp) {
|
|
||||||
try {
|
|
||||||
if (matchmakerAddress != null
|
|
||||||
&& (InetAddress.getByName(playerIp).isLoopbackAddress())
|
|
||||||
&& !matchmakerAddress.isLoopbackAddress()) {
|
|
||||||
GameLog.i("LS-NET", "Multiplayer : ip hôte '" + playerIp
|
|
||||||
+ "' loopback -> réécrite vers " + matchmakerAddress.getHostAddress()
|
|
||||||
+ " (NAT/émulateur)");
|
|
||||||
return matchmakerAddress.getHostAddress();
|
|
||||||
}
|
|
||||||
} catch (java.net.UnknownHostException e) {
|
|
||||||
// Laisse l'ip d'origine : addPlayer gèrera l'échec de connexion.
|
|
||||||
}
|
|
||||||
return playerIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void addPlayer(MatchmakingPlayer player) {
|
static void addPlayer(MatchmakingPlayer player) {
|
||||||
String ip = resolvableIp(player.getIp());
|
udpAddresses[player.getId()] = new InetSocketAddress(player.getIp(), player.getUdpPort());
|
||||||
udpAddresses[player.getId()] = new InetSocketAddress(ip, player.getUdpPort());
|
|
||||||
udpOut.setAddresses(udpAddresses);
|
udpOut.setAddresses(udpAddresses);
|
||||||
try {
|
try {
|
||||||
GameLog.i("LS-NET", "Multiplayer : connexion TCP au joueur " + player.getId()
|
System.out.println("Attempting to connect to TCP port " + player.getTcpPort());
|
||||||
+ " sur " + ip + ":" + player.getTcpPort());
|
tcpOut[player.getId()] = new TCPWriter(new Socket(player.getIp(), player.getTcpPort()));
|
||||||
tcpOut[player.getId()] = new TCPWriter(new Socket(ip, player.getTcpPort()));
|
|
||||||
tcpOut[player.getId()].start();
|
tcpOut[player.getId()].start();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
GameLog.e("LS-NET", "Multiplayer : connexion TCP au joueur "
|
e.printStackTrace();
|
||||||
+ player.getId() + " impossible (" + ip + ":" + player.getTcpPort() + ")", e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,44 +312,26 @@ public class Network {
|
|||||||
socket.setKeepAlive(true);
|
socket.setKeepAlive(true);
|
||||||
while (socket.isConnected()) {
|
while (socket.isConnected()) {
|
||||||
String command = in.readLine();
|
String command = in.readLine();
|
||||||
if (command == null) {
|
if (command != null) {
|
||||||
/*
|
switch (command) {
|
||||||
* EOF = le pair a fermé la connexion. SANS ce garde, la
|
case INSTANTIATE:
|
||||||
* boucle spinait à 100% CPU PAR CONNEXION MORTE pour
|
processInstantiation(in.readLine());
|
||||||
* toujours : readLine() rend null instantanément et
|
break;
|
||||||
* isConnected() ne passe JAMAIS false sur une fermeture
|
case DESTROY:
|
||||||
* distante (état local seulement). C'était le gel du
|
processDestruction(in.readLine());
|
||||||
* MacBook complet au ballon (retour v0.12.0 : chaque
|
break;
|
||||||
* déconnexion du client multi laissait un cœur à
|
case REQUEST_STATE:
|
||||||
* fond, cumulé au jeu GL et à l'émulateur).
|
sendState(in.readLine());
|
||||||
*/
|
break;
|
||||||
GameLog.i("LS-NET", "Multiplayer : connexion TCP fermée par le pair");
|
default:
|
||||||
break;
|
System.out.println("Unknown command:" + command);
|
||||||
}
|
break;
|
||||||
switch (command) {
|
}
|
||||||
case INSTANTIATE:
|
|
||||||
String instantiateMsg = in.readLine();
|
|
||||||
if (instantiateMsg == null) break;
|
|
||||||
processInstantiation(instantiateMsg);
|
|
||||||
break;
|
|
||||||
case DESTROY:
|
|
||||||
String destroyMsg = in.readLine();
|
|
||||||
if (destroyMsg == null) break;
|
|
||||||
processDestruction(destroyMsg);
|
|
||||||
break;
|
|
||||||
case REQUEST_STATE:
|
|
||||||
String requestMsg = in.readLine();
|
|
||||||
if (requestMsg == null) break;
|
|
||||||
sendState(requestMsg);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
GameLog.d("LS-NET", "Multiplayer : commande TCP inconnue '" + command + "'");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
GameLog.e("LS-NET", "Multiplayer : reader TCP interrompu", e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,6 +339,7 @@ public class Network {
|
|||||||
private static class TCPWriter extends Thread {
|
private static class TCPWriter extends Thread {
|
||||||
private final Socket socket;
|
private final Socket socket;
|
||||||
private final ArrayList<String[]> messages = new ArrayList<>();
|
private final ArrayList<String[]> messages = new ArrayList<>();
|
||||||
|
private boolean initialising = true;
|
||||||
|
|
||||||
TCPWriter(Socket socket) {
|
TCPWriter(Socket socket) {
|
||||||
super("TCPWriter");
|
super("TCPWriter");
|
||||||
@ -406,19 +351,9 @@ public class Network {
|
|||||||
try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()))) {
|
try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()))) {
|
||||||
while (true) {
|
while (true) {
|
||||||
synchronized (messages) {
|
synchronized (messages) {
|
||||||
/*
|
if (!initialising) {
|
||||||
* Attendre tant que la file est VIDE. L'original 2017
|
|
||||||
* ('if (!initialising) wait()') n'appelait JAMAIS wait()
|
|
||||||
* (initialising restait true) -> boucle synchronisée
|
|
||||||
* serrée à 100% CPU PAR CONNEXION TCP VIVE pendant tout
|
|
||||||
* le multi — le vrai responsable du gel du MacBook au
|
|
||||||
* ballon (le reader TCP dormait bien, lui). wait() est
|
|
||||||
* réveillé par sendMessage() via notify() ; quand
|
|
||||||
* l'iterateur de sortie s'exécute, la file est
|
|
||||||
* garantie non vide.
|
|
||||||
*/
|
|
||||||
while (messages.isEmpty()) {
|
|
||||||
messages.wait();
|
messages.wait();
|
||||||
|
initialising = false;
|
||||||
}
|
}
|
||||||
while (!messages.isEmpty()) {
|
while (!messages.isEmpty()) {
|
||||||
String[] s = messages.remove(0);
|
String[] s = messages.remove(0);
|
||||||
@ -431,7 +366,7 @@ public class Network {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException | InterruptedException e) {
|
} catch (IOException | InterruptedException e) {
|
||||||
GameLog.e("LS-NET", "Multiplayer : writer TCP interrompu", e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -198,11 +198,7 @@ public class TMXLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// POURQUOI GameLog.e (au lieu de printStackTrace) : la stack doit
|
ex.printStackTrace();
|
||||||
// atterrir dans le tampon GameLog — sur Android, un TMX qui casse
|
|
||||||
// ici rendait map == null sans trace exploitable dans le crash
|
|
||||||
// report. Le map reste null : les appelants logguent ce cas.
|
|
||||||
GameLog.e("LS-MAP", "TMX '" + filePath + "' : échec de chargement", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,9 +218,7 @@ public class TMXLoader {
|
|||||||
Element root = doc.getDocumentElement();
|
Element root = doc.getDocumentElement();
|
||||||
tileSet = loadTMXTileSet(filePath, root, firstGid);
|
tileSet = loadTMXTileSet(filePath, root, firstGid);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// TileSet null ici = gids orphelins comptés côté MapManager — la
|
ex.printStackTrace();
|
||||||
// stack dans le tampon GameLog dit QUEL fichier XML a lâché.
|
|
||||||
GameLog.e("LS-MAP", "tileset '" + filePath + "' : échec de chargement", ex);
|
|
||||||
}
|
}
|
||||||
return tileSet;
|
return tileSet;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
package com.ezardlabs.lostsector;
|
package com.ezardlabs.lostsector;
|
||||||
|
|
||||||
import com.ezardlabs.dethsquare.Time;
|
|
||||||
import com.ezardlabs.dethsquare.Transform;
|
import com.ezardlabs.dethsquare.Transform;
|
||||||
import com.ezardlabs.dethsquare.Vector2;
|
import com.ezardlabs.dethsquare.Vector2;
|
||||||
import com.ezardlabs.dethsquare.util.GameLog;
|
|
||||||
import com.ezardlabs.lostsector.NavMesh.NavPoint.NavPointType;
|
import com.ezardlabs.lostsector.NavMesh.NavPoint.NavPointType;
|
||||||
import com.ezardlabs.lostsector.map.MapManager;
|
import com.ezardlabs.lostsector.map.MapManager;
|
||||||
|
|
||||||
@ -103,26 +101,7 @@ public class NavMesh {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static NavPoint[] getPath(Vector2 a, Vector2 b) {
|
public static NavPoint[] getPath(Vector2 a, Vector2 b) {
|
||||||
/*
|
return getPath(getNavPoint(a), getNavPoint(b));
|
||||||
* Hors grille (v0.12.x) : getNavPoint renvoie null pour une position
|
|
||||||
* hors du graphe (l'ancien clamp renvoyait SILENCIEUSEMENT la cellule
|
|
||||||
* la plus proche — le BFS cherchait alors un chemin depuis/vers une
|
|
||||||
* case fausse sans jamais le dire, diagnostic impossible à distance).
|
|
||||||
* On signale ici, log throttlé 1/300 frames (politique AGENTS.md),
|
|
||||||
* et on rend un chemin vide : l'ennemi reste sur place (comportement
|
|
||||||
* dégradé assumé, PAS de téléportation ni de crash).
|
|
||||||
*/
|
|
||||||
NavPoint start = getNavPoint(a);
|
|
||||||
NavPoint end = getNavPoint(b);
|
|
||||||
if (start == null || end == null) {
|
|
||||||
if (Time.frameCount % 300 == 0) {
|
|
||||||
GameLog.d("LS-AI", "getPath : position hors grille NavMesh (a=" + a
|
|
||||||
+ (start == null ? " [HORS GRILLE]" : "")
|
|
||||||
+ " b=" + b + (end == null ? " [HORS GRILLE]" : "") + ")");
|
|
||||||
}
|
|
||||||
return new NavPoint[0];
|
|
||||||
}
|
|
||||||
return getPath(start, end);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NavPoint[] getPath(NavPoint start, NavPoint end) {
|
public static NavPoint[] getPath(NavPoint start, NavPoint end) {
|
||||||
@ -175,63 +154,18 @@ public class NavMesh {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensemble des NavPoints joignables depuis {@code start} en AU PLUS
|
|
||||||
* {@code maxLinks} liens (tous types confondus), start exclu.
|
|
||||||
*
|
|
||||||
* POURQUOI ce helper : l'idle patrol de Behaviour (retour utilisateur
|
|
||||||
* v0.12.0 "aucun idle pattern, plantés là") doit choisir une destination
|
|
||||||
* PROCHE et REELLEMENT joignable — or NavPoint.Link est package-private :
|
|
||||||
* com.ezardlabs.lostsector.ai ne peut pas itérer les liens lui-même.
|
|
||||||
* Le BFS borné vit donc ici, à côté du graphe qu'il parcourt.
|
|
||||||
*/
|
|
||||||
public static NavPoint[] getReachableNavPoints(NavPoint start, int maxLinks) {
|
|
||||||
if (start == null || maxLinks <= 0) return new NavPoint[0];
|
|
||||||
ArrayList<NavPoint> found = new ArrayList<>();
|
|
||||||
HashSet<NavPoint> visited = new HashSet<>();
|
|
||||||
ArrayDeque<NavPoint> queue = new ArrayDeque<>();
|
|
||||||
ArrayDeque<Integer> depths = new ArrayDeque<>();
|
|
||||||
visited.add(start);
|
|
||||||
queue.add(start);
|
|
||||||
depths.add(0);
|
|
||||||
while (!queue.isEmpty()) {
|
|
||||||
NavPoint p = queue.pop();
|
|
||||||
int depth = depths.pop();
|
|
||||||
if (depth >= maxLinks) continue;
|
|
||||||
for (NavPoint.Link l : p.links) {
|
|
||||||
if (visited.add(l.target)) {
|
|
||||||
found.add(l.target);
|
|
||||||
queue.add(l.target);
|
|
||||||
depths.add(depth + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return found.toArray(new NavPoint[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NavPoint getNavPoint(Vector2 position) {
|
public static NavPoint getNavPoint(Vector2 position) {
|
||||||
return getNavPoint(position.x, position.y);
|
return getNavPoint(position.x, position.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NavPoint getNavPoint(float x, float y) {
|
public static NavPoint getNavPoint(float x, float y) {
|
||||||
/*
|
/*
|
||||||
* Hors grille -> null (v0.12.x, remplace le clamp) : le clamp
|
* Clamp aux bornes : un ennemi hors de la grille (spawn en l'air au
|
||||||
* renvoyait le point le plus proche — une cellule FAUSSE et silencieuse
|
* bord de la carte, ou poussé hors champ) provoquait un
|
||||||
* pour un joueur/ennemi hors du NavMesh (spawn en l'air au bord de la
|
* ArrayIndexOutOfBounds fatal — on renvoie le point le plus proche.
|
||||||
* carte, ou poussé hors champ). Le crash ArrayIndexOutOfBounds d'origine
|
|
||||||
* reste évité, mais le cas est maintenant VISIBLE : getPath logue
|
|
||||||
* throttlé et l'ennemi reste sur place ( Behaviour.getPath gère null,
|
|
||||||
* seuls appelants existants vérifiés par grep).
|
|
||||||
* Convention 2017 CONSERVÉE : j = round(y/100) + 1 — le NavPoint d'une
|
|
||||||
* position porte l'index de la cellule sous ses pieds (position d'une
|
|
||||||
* entité = origine en haut du collider de 200px de haut : y=25500 ->
|
|
||||||
* cellules 255-256, j+1 vise la cellule basse du corps, celle qui
|
|
||||||
* "tient debout"). Ne pas "corriger" ce +1 sans revalider le mapping
|
|
||||||
* acquisitions/chemins sur émulateur.
|
|
||||||
*/
|
*/
|
||||||
int i = Math.round(x / 100f);
|
int i = Math.max(0, Math.min(navPoints.length - 1, Math.round(x / 100f)));
|
||||||
int j = Math.round(y / 100f) + 1;
|
int j = Math.max(0, Math.min(navPoints[0].length - 1, Math.round(y / 100f) + 1));
|
||||||
if (i < 0 || i >= navPoints.length || j < 0 || j >= navPoints[0].length) return null;
|
|
||||||
return navPoints[i][j];
|
return navPoints[i][j];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,43 +260,14 @@ public class NavMesh {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Jump links
|
||||||
* Jump links (RÉACTIVÉS v0.12.x, adaptés du bloc 2017 commenté).
|
/*for (int x = 0; x < navPoints.length; x++) {
|
||||||
*
|
|
||||||
* POURQUOI c'est le fix central du retour "ils tentent pas de venir me
|
|
||||||
* chercher" : le 2017 avait désactivé ce bloc ENTIER — les étages
|
|
||||||
* multi-niveaux n'étaient JAMAIS reliés verticalement à la montée.
|
|
||||||
* La convention BFS (NavPoint.index) réserve JUMP à la montée
|
|
||||||
* (cible plus haut) et FALL à la descente ; les FALL existaient, donc
|
|
||||||
* DESCENDRE restait possible, mais MONTER un étage = aucun chemin
|
|
||||||
* possible pour TOUS les ennemis, systématiquement (joueur sur un
|
|
||||||
* étage supérieur -> "aucun chemin NavMesh" en boucle).
|
|
||||||
*
|
|
||||||
* Cas couvert : un rebord (RIGHT_EDGE/SOLO/LEFT_EDGE) buttant contre
|
|
||||||
* un mur — l'ennemi saute SUR le haut du mur / la marche supérieure.
|
|
||||||
* Contraintes :
|
|
||||||
* - hauteur max 3 cellules (boucle 2017 i<4) : cohérent avec la
|
|
||||||
* physique de Behaviour.jump(d) (v = √(2.5·d)+2 -> apogée ≈ d + marge,
|
|
||||||
* Rigidbody.gravity=1.25 -> apogée = v²/2.5) ; le joueur, lui, monte
|
|
||||||
* plus haut (double saut + wall jump, Player.java) — l'IA reste plus
|
|
||||||
* limitée que le joueur, choix assumé.
|
|
||||||
* - atterrissage VALIDE (isJumpLanding) : cellule libre + tête libre +
|
|
||||||
* APPUI sous les pieds. Le bloc 2017 sautait ce check — un link vers
|
|
||||||
* une cellule en l'air (NavPoint sans walk links) créait un
|
|
||||||
* cul-de-sac dans le graphe : le BFS y entrait et n'en ressortait
|
|
||||||
* jamais. Un atterrissage avec appui est une cellule "debout", donc
|
|
||||||
* déjà chaînée à sa plateforme par les walk links.
|
|
||||||
* - garde-fou addLink : toute cible hors graphe est rejetée.
|
|
||||||
* (Le addLink du cas RIGHT du 2017 ciblait x-1 au lieu de x+1 — typo
|
|
||||||
* d'époque, corrigée ici en version symétrique du cas LEFT.)
|
|
||||||
*/
|
|
||||||
for (int x = 0; x < navPoints.length; x++) {
|
|
||||||
for (int y = 0; y < navPoints[x].length; y++) {
|
for (int y = 0; y < navPoints[x].length; y++) {
|
||||||
if (navPoints[x][y].type == NavPointType.RIGHT_EDGE || navPoints[x][y].type == NavPointType.SOLO) {
|
if (navPoints[x][y].type == NavPointType.RIGHT_EDGE || navPoints[x][y].type == NavPointType.SOLO) {
|
||||||
if (isCollision(solidityMap, x + 1, y)) {
|
if (isCollision(solidityMap, x + 1, y)) {
|
||||||
for (int i = 1; i <= 3; i++) {
|
for (int i = 1; i < 4; i++) {
|
||||||
if (isJumpLanding(solidityMap, x + 1, y - i)) {
|
if (!isCollision(solidityMap, x + 1, y - i) && !isCollision(solidityMap, x + 1, y - i - 1)) {
|
||||||
addLink(x, y, x + 1, y - i, LinkType.JUMP);
|
// addLink(x - 1, y, x + 1, y - i, LinkType.JUMP);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -370,61 +275,19 @@ public class NavMesh {
|
|||||||
}
|
}
|
||||||
if (navPoints[x][y].type == NavPointType.LEFT_EDGE || navPoints[x][y].type == NavPointType.SOLO) {
|
if (navPoints[x][y].type == NavPointType.LEFT_EDGE || navPoints[x][y].type == NavPointType.SOLO) {
|
||||||
if (isCollision(solidityMap, x - 1, y)) {
|
if (isCollision(solidityMap, x - 1, y)) {
|
||||||
for (int i = 1; i <= 3; i++) {
|
for (int i = 1; i < 4; i++) {
|
||||||
if (isJumpLanding(solidityMap, x - 1, y - i)) {
|
if (!isCollision(solidityMap, x - 1, y - i) && !isCollision(solidityMap, x - 1, y - i - 1)) {
|
||||||
addLink(x, y, x - 1, y - i, LinkType.JUMP);
|
// addLink(x, y, x - 1, y - i, LinkType.JUMP);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/*
|
|
||||||
* Synthèse d'init : la première ligne à lire pour vérifier que les
|
|
||||||
* jump links existent bien sur une carte donnée (saut=0 -> aucune
|
|
||||||
* marche ≤ 3 cellules détectée : la montée inter-étages restera
|
|
||||||
* impossible sur CETTE carte, à distinguer d'un patch absent).
|
|
||||||
* addLink est bidirectionnel : chaque lien est compté deux fois.
|
|
||||||
*/
|
|
||||||
int marches = 0;
|
|
||||||
int chutes = 0;
|
|
||||||
int sauts = 0;
|
|
||||||
for (NavPoint[] colonne : navPoints) {
|
|
||||||
for (NavPoint p : colonne) {
|
|
||||||
for (NavPoint.Link l : p.links) {
|
|
||||||
switch (l.linkType) {
|
|
||||||
case WALK: marches++; break;
|
|
||||||
case FALL: chutes++; break;
|
|
||||||
case JUMP: sauts++; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GameLog.i("LS-MAP", "NavMesh init : grille " + navPoints.length + "x" + navPoints[0].length
|
|
||||||
+ ", liens marche=" + marches + " chute=" + chutes + " saut=" + sauts
|
|
||||||
+ " (bidirectionnels -> comptés 2x)");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Atterrissage de saut valide : cellule libre, tête libre (l'ennemi fait
|
|
||||||
* 2 cellules de haut), appui solide sous les pieds. Voir le commentaire
|
|
||||||
* du bloc jump links pour le POURQUOI de chaque condition.
|
|
||||||
*/
|
|
||||||
private static boolean isJumpLanding(int[][] solidity, int x, int y) {
|
|
||||||
return !isCollision(solidity, x, y) // cellule d'atterrissage libre
|
|
||||||
&& !isCollision(solidity, x, y - 1) // place pour la tête
|
|
||||||
&& isCollision(solidity, x, y + 1); // appui sous les pieds
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addLink(int x1, int y1, int x2, int y2, LinkType type) {
|
private static void addLink(int x1, int y1, int x2, int y2, LinkType type) {
|
||||||
/*
|
|
||||||
* Garde-fou : un link vers une cellule hors graphe est un cul-de-sac
|
|
||||||
* silencieux (le BFS atteint un NavPoint inexistant -> crash ou chemin
|
|
||||||
* corrompu selon l'appelant). Toute création de link passe ici.
|
|
||||||
*/
|
|
||||||
if (x2 < 0 || x2 >= navPoints.length || y2 < 0 || y2 >= navPoints[0].length) return;
|
|
||||||
navPoints[x1][y1].links.add(new NavPoint.Link(type, navPoints[x2][y2]));
|
navPoints[x1][y1].links.add(new NavPoint.Link(type, navPoints[x2][y2]));
|
||||||
navPoints[x2][y2].links.add(new NavPoint.Link(type, navPoints[x1][y1]));
|
navPoints[x2][y2].links.add(new NavPoint.Link(type, navPoints[x1][y1]));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.ezardlabs.lostsector.ai;
|
package com.ezardlabs.lostsector.ai;
|
||||||
|
|
||||||
import com.ezardlabs.dethsquare.Collider;
|
|
||||||
import com.ezardlabs.dethsquare.GameObject;
|
import com.ezardlabs.dethsquare.GameObject;
|
||||||
import com.ezardlabs.dethsquare.Layers;
|
import com.ezardlabs.dethsquare.Layers;
|
||||||
import com.ezardlabs.dethsquare.Level;
|
import com.ezardlabs.dethsquare.Level;
|
||||||
@ -8,7 +7,6 @@ import com.ezardlabs.dethsquare.LevelManager;
|
|||||||
import com.ezardlabs.dethsquare.Mathf;
|
import com.ezardlabs.dethsquare.Mathf;
|
||||||
import com.ezardlabs.dethsquare.Physics;
|
import com.ezardlabs.dethsquare.Physics;
|
||||||
import com.ezardlabs.dethsquare.Physics.RaycastHit;
|
import com.ezardlabs.dethsquare.Physics.RaycastHit;
|
||||||
import com.ezardlabs.dethsquare.RectF;
|
|
||||||
import com.ezardlabs.dethsquare.StateMachine;
|
import com.ezardlabs.dethsquare.StateMachine;
|
||||||
import com.ezardlabs.dethsquare.util.GameLog;
|
import com.ezardlabs.dethsquare.util.GameLog;
|
||||||
import com.ezardlabs.dethsquare.StateMachine.Transition;
|
import com.ezardlabs.dethsquare.StateMachine.Transition;
|
||||||
@ -19,9 +17,6 @@ import com.ezardlabs.lostsector.Game.DamageType;
|
|||||||
import com.ezardlabs.lostsector.NavMesh;
|
import com.ezardlabs.lostsector.NavMesh;
|
||||||
import com.ezardlabs.lostsector.NavMesh.NavPoint;
|
import com.ezardlabs.lostsector.NavMesh.NavPoint;
|
||||||
import com.ezardlabs.lostsector.levels.MissionLevel;
|
import com.ezardlabs.lostsector.levels.MissionLevel;
|
||||||
import com.ezardlabs.lostsector.objects.Entity;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public abstract class Behaviour {
|
public abstract class Behaviour {
|
||||||
private float moveSpeed;
|
private float moveSpeed;
|
||||||
@ -42,35 +37,7 @@ public abstract class Behaviour {
|
|||||||
private long thawStart = 0;
|
private long thawStart = 0;
|
||||||
private int directionToLook = 0;
|
private int directionToLook = 0;
|
||||||
private final int visionLayerMask = Layers.getLayerMask("Player", "Objective", "Solid");
|
private final int visionLayerMask = Layers.getLayerMask("Player", "Objective", "Solid");
|
||||||
|
private final int visionLayerMaskTarget = Layers.getLayerMask("Player");
|
||||||
/*
|
|
||||||
* Cible injoignable (retour utilisateur v0.12.0 "plantés là") : une cible
|
|
||||||
* acquise par proximité mais SANS chemin NavMesh (joueur sur une étagère
|
|
||||||
* non joignable — cas prouvé en repro desktop : l'étagère de spawn (40,24)
|
|
||||||
* n'est atteignable par AUCUN lien du graphe) laissait l'ennemi figé en
|
|
||||||
* TRACKING indéfiniment. Au-delà de PATH_FAIL_DROP_TIME sans chemin, la
|
|
||||||
* cible est abandonnée : l'ennemi repart en IDLE et le fallback objectif
|
|
||||||
* le renvoie attaquer le cryopod — un ennemi ne reste plus jamais planté.
|
|
||||||
*/
|
|
||||||
private static final long PATH_FAIL_DROP_TIME = 3000;
|
|
||||||
private long pathFailStart = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* IDLE vivant (retour utilisateur v0.12.0 "aucun idle pattern, plantés
|
|
||||||
* là") : willPatrol était un champ mort 2017 (stocké, jamais lu). Une
|
|
||||||
* patrouille minimale : en IDLE sans cible, micro-déplacement NavMesh
|
|
||||||
* vers un NavPoint aléatoire à <= PATROL_RADIUS liens, nouveau choix
|
|
||||||
* seulement à l'arrivée ou après PATROL_INTERVAL (throttle : jamais par
|
|
||||||
* frame). L'acquisition joueur prime toujours : la patrouille est
|
|
||||||
* abandonnée dès que visionCheck pose une cible.
|
|
||||||
*/
|
|
||||||
private static final long PATROL_INTERVAL = 4000;
|
|
||||||
private static final int PATROL_RADIUS = 5;
|
|
||||||
private NavPoint[] patrolPath = null;
|
|
||||||
private int patrolIndex = 0;
|
|
||||||
private NavPoint patrolFrom = null;
|
|
||||||
private NavPoint patrolDestination = null;
|
|
||||||
private long nextPatrolChoice = 0;
|
|
||||||
|
|
||||||
private StateMachine<State> stateMachine = new StateMachine<>();
|
private StateMachine<State> stateMachine = new StateMachine<>();
|
||||||
private Transform transform;
|
private Transform transform;
|
||||||
@ -108,23 +75,12 @@ public abstract class Behaviour {
|
|||||||
this.willPatrol = willPatrol;
|
this.willPatrol = willPatrol;
|
||||||
this.visionRange = visionRange;
|
this.visionRange = visionRange;
|
||||||
|
|
||||||
/*
|
|
||||||
* IA v0.11.x (retour utilisateur "l'IA des ennemis est pourrie") :
|
|
||||||
* - IDLE -> TRACKING élargi : une cible ACQUISE à portée de frappe
|
|
||||||
* mais sans ligne de vue (derrière un coin/muret) doit quand même
|
|
||||||
* déclencher la poursuite NavMesh, sinon l'ennemi reste planté en
|
|
||||||
* IDLE juste à côté du joueur sans jamais aller le chercher.
|
|
||||||
* - TRACKING -> IDLE ajouté (garde-fou) : sans lui, une cible devenue
|
|
||||||
* null (morte, disparue) laissait l'ennemi en TRACKING éternel.
|
|
||||||
*/
|
|
||||||
stateMachine.addState(State.IDLE,
|
stateMachine.addState(State.IDLE,
|
||||||
new Transition<>(State.TRACKING, () -> target != null &&
|
new Transition<>(State.TRACKING, () -> target != null && !inRange(transform, target)),
|
||||||
(!inRange(transform, target) || !canSeeEnemy())),
|
|
||||||
new Transition<>(State.ATTACKING, () -> canSeeEnemy() && inRange(transform, target)));
|
new Transition<>(State.ATTACKING, () -> canSeeEnemy() && inRange(transform, target)));
|
||||||
|
|
||||||
stateMachine.addState(State.TRACKING,
|
stateMachine.addState(State.TRACKING,
|
||||||
new Transition<>(State.ATTACKING, () -> canSeeEnemy() && inRange(transform, target)),
|
new Transition<>(State.ATTACKING, () -> canSeeEnemy() && inRange(transform, target)));
|
||||||
new Transition<>(State.IDLE, () -> target == null));
|
|
||||||
|
|
||||||
stateMachine.addState(State.ATTACKING,
|
stateMachine.addState(State.ATTACKING,
|
||||||
new Transition<>(State.TRACKING, () -> !canSeeEnemy() || !inRange(transform, target)));
|
new Transition<>(State.TRACKING, () -> !canSeeEnemy() || !inRange(transform, target)));
|
||||||
@ -167,44 +123,22 @@ public abstract class Behaviour {
|
|||||||
// politique de logs throttlés AGENTS.md). Identifie l'ennemi par son
|
// politique de logs throttlés AGENTS.md). Identifie l'ennemi par son
|
||||||
// nom de GameObject (ex "Dera Crewman #12").
|
// nom de GameObject (ex "Dera Crewman #12").
|
||||||
if (stateMachine.getState() != previousState) {
|
if (stateMachine.getState() != previousState) {
|
||||||
/*
|
|
||||||
* Diagnostic à distance (retour v0.11.0 "IA pourrie") : chaque
|
|
||||||
* transition logue QUI, l'état, la cible, les positions et la
|
|
||||||
* distance — 1 ligne par CHANGEMENT d'état seulement (politique
|
|
||||||
* AGENTS.md : jamais par frame brute).
|
|
||||||
*/
|
|
||||||
GameLog.d("LS-AI", (transform.gameObject.name) + " : " + previousState
|
GameLog.d("LS-AI", (transform.gameObject.name) + " : " + previousState
|
||||||
+ " -> " + stateMachine.getState()
|
+ " -> " + stateMachine.getState()
|
||||||
+ (target != null ? " cible=" + target.gameObject.name
|
+ (target != null ? " (cible " + target.gameObject.name + ")" : ""));
|
||||||
+ " ennemi=" + transform.position
|
|
||||||
+ " ciblePos=" + target.position
|
|
||||||
+ " dist=" + (int) Vector2.distance(transform.position, target.position)
|
|
||||||
: " (sans cible)"));
|
|
||||||
}
|
}
|
||||||
if (Time.frameCount % 60 == 0) {
|
if (Time.frameCount % 60 == 0) {
|
||||||
// Réévaluation systématique (et non plus seulement quand la cible
|
if (targetIsObjective || path == null || path.length == 0) {
|
||||||
// est un objectif ou que le chemin est vide) : c'est ce qui
|
visionCheck();
|
||||||
// permet la garde-fou "cible morte/disparue -> retour IDLE".
|
}
|
||||||
visionCheck();
|
|
||||||
if (target == null && objectives != null) {
|
if (target == null && objectives != null) {
|
||||||
target = getObjectiveTarget();
|
target = getObjectiveTarget();
|
||||||
if (target != null) {
|
targetIsObjective = true;
|
||||||
targetIsObjective = true;
|
|
||||||
// Curseur de chemin remis à zéro : une re-acquisition
|
|
||||||
// (même cible) avec un chemin déjà consommé en cache
|
|
||||||
// repartirait sinon d'un index au bout du chemin
|
|
||||||
// (immobilité silencieuse).
|
|
||||||
pathIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (stateMachine.getState()) {
|
switch (stateMachine.getState()) {
|
||||||
case IDLE:
|
case IDLE:
|
||||||
// IDLE vivant : micro-patrouille NavMesh si aucune cible (le
|
animationState = AnimationState.IDLE;
|
||||||
// fallback objectif pose une cible en <= 1 s en Defend, la
|
|
||||||
// patrouille n'a donc le temps de vivre que sans objectifs —
|
|
||||||
// Exterminate, ou entre deux acquisitions).
|
|
||||||
animationState = willPatrol && target == null ? patrol() : AnimationState.IDLE;
|
|
||||||
break;
|
break;
|
||||||
case TRACKING:
|
case TRACKING:
|
||||||
animationState = move();
|
animationState = move();
|
||||||
@ -238,16 +172,6 @@ public abstract class Behaviour {
|
|||||||
private NavPoint[] getPath() {
|
private NavPoint[] getPath() {
|
||||||
NavPoint self = NavMesh.getNavPoint(transform.position.x, transform.position.y);
|
NavPoint self = NavMesh.getNavPoint(transform.position.x, transform.position.y);
|
||||||
NavPoint targetNavPoint = NavMesh.getNavPoint(target.position);
|
NavPoint targetNavPoint = NavMesh.getNavPoint(target.position);
|
||||||
/*
|
|
||||||
* Hors grille (v0.12.x) : getNavPoint renvoie null pour une position
|
|
||||||
* hors du graphe. Pas de recalcul ni de NPE — l'ennemi reste sur place
|
|
||||||
* (comportement dégradé documenté) et le log "aucun chemin" de move()
|
|
||||||
* (throttlé /300 frames) trace les positions pour le diagnostic.
|
|
||||||
*/
|
|
||||||
if (self == null || targetNavPoint == null) {
|
|
||||||
path = null;
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
if ((!self.equals(currentNavPoint) || !targetNavPoint.equals(currentTargetNavPoint)) && !self.links.isEmpty()) {
|
if ((!self.equals(currentNavPoint) || !targetNavPoint.equals(currentTargetNavPoint)) && !self.links.isEmpty()) {
|
||||||
currentNavPoint = self;
|
currentNavPoint = self;
|
||||||
currentTargetNavPoint = targetNavPoint;
|
currentTargetNavPoint = targetNavPoint;
|
||||||
@ -259,153 +183,29 @@ public abstract class Behaviour {
|
|||||||
|
|
||||||
private AnimationState move() {
|
private AnimationState move() {
|
||||||
path = getPath();
|
path = getPath();
|
||||||
if (path == null || path.length == 0) {
|
if (path != null && path.length > 0) {
|
||||||
/*
|
if (pathIndex < path.length - 1) {
|
||||||
* Cible injoignable (aucun chemin NavMesh, cellule hors graphe ou
|
float direction = Mathf.clamp(path[pathIndex + 1].position.x - path[pathIndex].position.x, -1, 1);
|
||||||
* isolée) : on laisse un délai de grâce (chute en cours, cellule
|
transform.translate(moveSpeed * direction * Time.fpsScaling60, 0);
|
||||||
* en transition) puis on ABANDONNE la cible au lieu de rester
|
transform.scale.x = direction;
|
||||||
* planté indéfiniment — le fallback objectif reprend la main.
|
|
||||||
* Prouvé en repro desktop v0.12.x : des ennemis restaient figés
|
|
||||||
* en "aucun chemin NavMesh vers Player" quand le joueur se
|
|
||||||
* tenait sur une étagère non joignable (cellule (40,24) de
|
|
||||||
* defense0, joignable par aucun lien du graphe).
|
|
||||||
*/
|
|
||||||
if (pathFailStart == 0) {
|
|
||||||
pathFailStart = System.currentTimeMillis();
|
|
||||||
} else if (System.currentTimeMillis() - pathFailStart > PATH_FAIL_DROP_TIME) {
|
|
||||||
GameLog.d("LS-AI", transform.gameObject.name + " : cible "
|
|
||||||
+ (target != null ? target.gameObject.name : "?")
|
|
||||||
+ " injoignable (aucun chemin NavMesh depuis "
|
|
||||||
+ PATH_FAIL_DROP_TIME / 1000 + " s), cible abandonnée");
|
|
||||||
target = null;
|
|
||||||
targetIsObjective = false;
|
|
||||||
pathFailStart = 0;
|
|
||||||
}
|
|
||||||
if (target != null && Time.frameCount % 300 == 0) {
|
|
||||||
GameLog.d("LS-AI", transform.gameObject.name + " : aucun chemin NavMesh vers "
|
|
||||||
+ target.gameObject.name + " ennemi=" + transform.position
|
|
||||||
+ " ciblePos=" + target.position);
|
|
||||||
}
|
|
||||||
return AnimationState.IDLE;
|
|
||||||
}
|
|
||||||
pathFailStart = 0;
|
|
||||||
if (pathIndex < path.length - 1) {
|
|
||||||
float direction = Mathf.clamp(path[pathIndex + 1].position.x - path[pathIndex].position.x, -1, 1);
|
|
||||||
transform.translate(moveSpeed * direction * Time.fpsScaling60, 0);
|
|
||||||
transform.scale.x = direction;
|
|
||||||
|
|
||||||
if (transform.gameObject.rigidbody.velocity.y > transform.gameObject.rigidbody.gravity) {
|
if (transform.gameObject.rigidbody.velocity.y > transform.gameObject.rigidbody.gravity) {
|
||||||
return AnimationState.FALLING;
|
return AnimationState.FALLING;
|
||||||
} else if (path[pathIndex + 1].position.y < path[pathIndex].position.y) {
|
} else if (path[pathIndex + 1].position.y < path[pathIndex].position.y) {
|
||||||
if (animationState != AnimationState.JUMPING) {
|
if (animationState != AnimationState.JUMPING) {
|
||||||
jump(Math.abs(path[pathIndex + 1].position.y - path[pathIndex].position.y));
|
jump(Math.abs(path[pathIndex + 1].position.y - path[pathIndex].position.y));
|
||||||
}
|
}
|
||||||
return AnimationState.JUMPING;
|
return AnimationState.JUMPING;
|
||||||
} else if (direction == 0) {
|
} else if (direction == 0) {
|
||||||
return AnimationState.IDLE;
|
|
||||||
} else {
|
|
||||||
return AnimationState.MOVING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Chemin consommé (cible sur la cellule finale ou adjacente) : la
|
|
||||||
* transition ATTACKING (portée + LOS) prend le relais ; sinon on
|
|
||||||
* attend immobile sans loguer en boucle.
|
|
||||||
*/
|
|
||||||
return AnimationState.IDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IDLE vivant : micro-patrouille NavMesh (retour utilisateur v0.12.0).
|
|
||||||
* Marche le long d'un chemin vers un NavPoint aléatoire proche ; nouveau
|
|
||||||
* choix seulement à l'arrivée ou après PATROL_INTERVAL. La reprise de
|
|
||||||
* poursuite (acquisition joueur/objectif) coupe la patrouille sans état
|
|
||||||
* résiduel : move() recalcule son propre chemin via getPath().
|
|
||||||
*/
|
|
||||||
private AnimationState patrol() {
|
|
||||||
if (patrolPath == null || patrolIndex >= patrolPath.length - 1) {
|
|
||||||
// Arrivé (ou jamais parti) : nouveau choix seulement au prochain
|
|
||||||
// créneau — l'anim idle tourne entre deux déplacements.
|
|
||||||
if (System.currentTimeMillis() < nextPatrolChoice) return AnimationState.IDLE;
|
|
||||||
choosePatrolDestination();
|
|
||||||
nextPatrolChoice = System.currentTimeMillis() + PATROL_INTERVAL;
|
|
||||||
if (patrolPath == null || patrolPath.length < 2) return AnimationState.IDLE;
|
|
||||||
} else {
|
|
||||||
// Cellule courante changée (en marche / chute) : chemin recalcule
|
|
||||||
// depuis la cellule réelle vers la MÊME destination.
|
|
||||||
NavPoint self = NavMesh.getNavPoint(transform.position.x, transform.position.y);
|
|
||||||
if (self != null && !self.equals(patrolFrom)) {
|
|
||||||
patrolFrom = self;
|
|
||||||
patrolPath = NavMesh.getPath(self, patrolDestination);
|
|
||||||
patrolIndex = 0;
|
|
||||||
if (patrolPath.length < 2) {
|
|
||||||
patrolPath = null;
|
|
||||||
return AnimationState.IDLE;
|
return AnimationState.IDLE;
|
||||||
|
} else {
|
||||||
|
return AnimationState.MOVING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (patrolIndex < patrolPath.length - 1) {
|
|
||||||
float direction = Mathf.clamp(
|
|
||||||
patrolPath[patrolIndex + 1].position.x - patrolPath[patrolIndex].position.x, -1, 1);
|
|
||||||
transform.translate(moveSpeed * direction * Time.fpsScaling60, 0);
|
|
||||||
transform.scale.x = direction;
|
|
||||||
|
|
||||||
if (transform.gameObject.rigidbody.velocity.y > transform.gameObject.rigidbody.gravity) {
|
|
||||||
return AnimationState.FALLING;
|
|
||||||
} else if (patrolPath[patrolIndex + 1].position.y < patrolPath[patrolIndex].position.y) {
|
|
||||||
if (animationState != AnimationState.JUMPING) {
|
|
||||||
jump(Math.abs(patrolPath[patrolIndex + 1].position.y - patrolPath[patrolIndex].position.y));
|
|
||||||
}
|
|
||||||
return AnimationState.JUMPING;
|
|
||||||
} else if (direction == 0) {
|
|
||||||
return AnimationState.IDLE;
|
|
||||||
} else {
|
|
||||||
return AnimationState.MOVING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return AnimationState.IDLE;
|
return AnimationState.IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void choosePatrolDestination() {
|
|
||||||
patrolPath = null;
|
|
||||||
patrolDestination = null;
|
|
||||||
NavPoint self = NavMesh.getNavPoint(transform.position.x, transform.position.y);
|
|
||||||
if (self == null) return;
|
|
||||||
NavPoint[] candidates = NavMesh.getReachableNavPoints(self, PATROL_RADIUS);
|
|
||||||
if (candidates.length == 0) return;
|
|
||||||
// Filtre géométrique : un lien FALL peut traverser 16 cellules en un
|
|
||||||
// seul saut de graphe — sans ce filtre la "patrouille à ~5 cellules"
|
|
||||||
// envoyait l'ennemi tomber d'un étage à l'autre.
|
|
||||||
ArrayList<NavPoint> proches = new ArrayList<>();
|
|
||||||
for (NavPoint c : candidates) {
|
|
||||||
if (Math.abs(c.position.x - self.position.x) <= PATROL_RADIUS * 100f
|
|
||||||
&& Math.abs(c.position.y - self.position.y) <= PATROL_RADIUS * 100f) {
|
|
||||||
proches.add(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (proches.isEmpty()) return;
|
|
||||||
NavPoint dest = proches.get((int) (Math.random() * proches.size()));
|
|
||||||
NavPoint[] p = NavMesh.getPath(self, dest);
|
|
||||||
if (p.length == 1) {
|
|
||||||
// Cellule adjacente : getPath rend [dest] (non "marchable" par la
|
|
||||||
// boucle ci-dessus) — on synthétise le pas direct.
|
|
||||||
p = new NavPoint[]{
|
|
||||||
self,
|
|
||||||
dest
|
|
||||||
};
|
|
||||||
} else if (p.length == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
patrolDestination = dest;
|
|
||||||
patrolFrom = self;
|
|
||||||
patrolPath = p;
|
|
||||||
patrolIndex = 0;
|
|
||||||
// 1 ligne PAR CHOIX de destination (toutes les ~4 s max) : trace QUI
|
|
||||||
// patrouille, OÙ il va et la longueur du chemin (politique AGENTS.md).
|
|
||||||
GameLog.d("LS-AI", transform.gameObject.name + " : idle -> patrouille vers navpoint "
|
|
||||||
+ dest.id + " " + dest.position + " (" + p.length + " pas)");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void jump(float distance) {
|
private void jump(float distance) {
|
||||||
transform.gameObject.rigidbody.velocity.y = (float) -Math.sqrt(2.5 * distance) - 2;
|
transform.gameObject.rigidbody.velocity.y = (float) -Math.sqrt(2.5 * distance) - 2;
|
||||||
}
|
}
|
||||||
@ -419,46 +219,16 @@ public abstract class Behaviour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean canSeeEnemy() {
|
private boolean canSeeEnemy() {
|
||||||
return target != null && hasLineOfSight(target);
|
if (target == null) {
|
||||||
}
|
return false;
|
||||||
|
} else {
|
||||||
/**
|
Vector2 origin = transform.position.offset(100, 100);
|
||||||
* Ligne de vue ennemi -> cible par raycast dirigé (œil = centre du
|
Vector2 temp = target.position.offset(100, 100);
|
||||||
* collider, offset (100,100) convention reprise du code 2017).
|
Vector2 direction = new Vector2(temp.x - origin.x, temp.y - origin.y);
|
||||||
*
|
RaycastHit hit = Physics.raycast(origin, direction, (float) Vector2.distance(origin, temp),
|
||||||
* POURQUOI cette méthode remplace les 2 rayons horizontaux de l'upstream :
|
visionLayerMask);
|
||||||
* les rayons horizontaux à y+100 fixe ne touchent le collider joueur que
|
return hit != null && hit.transform == target;
|
||||||
* si les deux se chevauchent sur CETTE ligne (le collider joueur s'étend
|
|
||||||
* de position.y+43.75 à position.y+200, celui de l'ennemi de position.y à
|
|
||||||
* position.y+200) : un joueur une tuile plus bas (p.y = e.y+100) ou plus
|
|
||||||
* de 2 tuiles plus haut n'est JAMAIS touché — angle mort vertical tracé
|
|
||||||
* TODO depuis v0.10.0. Un rayon dirigé vers la cible règle aussi les cas
|
|
||||||
* diagonaux sans rendre l'IA omni-perceptrice : les murs (layer "Solid")
|
|
||||||
* restent dans le masque et bloquent le rayon.
|
|
||||||
*
|
|
||||||
* Point blanc corps à corps : RectF.intersect ne teste que les 4 CÔTÉS du
|
|
||||||
* rectangle — un segment dont l'origine est déjà DANS les bounds de la
|
|
||||||
* cible ne traverse aucun côté et renvoie null. Un ennemi collé au joueur
|
|
||||||
* était donc "aveugle" précisément au moment de frapper (l'origine du
|
|
||||||
* raycast tombe dans le collider joueur). Correctif : overshoot de 50 sur
|
|
||||||
* la longueur (l'extrémité sort des bounds et traverse un côté), plus
|
|
||||||
* fallback chevauchement physique des deux colliders (contact direct =
|
|
||||||
* vision acquise).
|
|
||||||
*/
|
|
||||||
private boolean hasLineOfSight(Transform target) {
|
|
||||||
Vector2 origin = transform.position.offset(100, 100);
|
|
||||||
Vector2 destination = target.position.offset(100, 100);
|
|
||||||
Vector2 direction = new Vector2(destination.x - origin.x, destination.y - origin.y);
|
|
||||||
float distance = (float) Vector2.distance(origin, destination);
|
|
||||||
if (distance == 0) return true;
|
|
||||||
RaycastHit hit = Physics.raycast(origin, direction, distance + 50, visionLayerMask);
|
|
||||||
if (hit != null && hit.transform == target) return true;
|
|
||||||
if (distance < 250) {
|
|
||||||
Collider self = transform.gameObject.getComponentOfType(Collider.class);
|
|
||||||
Collider other = target.gameObject.getComponentOfType(Collider.class);
|
|
||||||
return self != null && other != null && RectF.intersects(self.getBounds(), other.getBounds());
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract boolean inRange(Transform self, Transform enemy);
|
abstract boolean inRange(Transform self, Transform enemy);
|
||||||
@ -467,79 +237,37 @@ public abstract class Behaviour {
|
|||||||
|
|
||||||
private void visionCheck() {
|
private void visionCheck() {
|
||||||
/*
|
/*
|
||||||
* Acquisition par PROXIMITÉ (v0.11.x) : on énumère les joueurs
|
* Vision BIDIRECTIONNELLE : le raycast d'origine ne testait QUE la
|
||||||
* (findAllWithTag — retourne un tableau vide au menu, aucun crash ;
|
* direction du regard (scale.x) — un ennemi spawné dos au joueur ne
|
||||||
* fonctionne aussi bien en solo qu'en multi) et on acquiert le plus
|
* le voyait JAMAIS (target = null -> IDLE éternel, feedback v0.9.0 :
|
||||||
* proche sous visionRange SANS exiger de ligne de vue.
|
* "les ennemis n'attaquent plus et ne cherchent plus à aller taper
|
||||||
* POURQUOI pas de LOS ici : le LOS-only laissait les ennemis IDLE
|
* les joueurs", flagrant en Exterminate où les spawns se font des
|
||||||
* pour toujours quand le joueur spawnait derrière un mur (retour
|
* deux côtés du joueur). On teste les deux directions et on garde le
|
||||||
* v0.11.0 "ils tentent pas de venir me chercher par pathfinding,
|
* hit le plus proche.
|
||||||
* ils restent plantés là") — sur les cartes multi-niveaux la LOS
|
|
||||||
* initiale est presque toujours coupée. L'ennemi avec une cible
|
|
||||||
* acquise POURSUIT via NavMesh (le chemin contourne les murs) ;
|
|
||||||
* les murs continuent de bloquer le TIR : ATTACKING exige
|
|
||||||
* canSeeEnemy() (LOS) et la melee reste gardée par le fallback AABB
|
|
||||||
* de hasLineOfSight. Fini aussi les angles morts verticaux et la
|
|
||||||
* bande morte frontale (hasLineOfSight dirigé).
|
|
||||||
*/
|
*/
|
||||||
GameObject[] players = GameObject.findAllWithTag("player");
|
RaycastHit right = Physics.raycast(
|
||||||
Transform best = null;
|
transform.position.offset(transform.scale.x > 0 ? 200 : 0, 100),
|
||||||
float bestDist = Float.MAX_VALUE;
|
new Vector2(1, 0), visionRange, visionLayerMaskTarget);
|
||||||
for (GameObject player : players) {
|
RaycastHit left = Physics.raycast(
|
||||||
float dist = (float) Vector2.distance(transform.position, player.transform.position);
|
transform.position.offset(transform.scale.x > 0 ? 200 : 0, 100),
|
||||||
if (dist <= visionRange && dist < bestDist) {
|
new Vector2(-1, 0), visionRange, visionLayerMaskTarget);
|
||||||
best = player.transform;
|
RaycastHit hit = null;
|
||||||
bestDist = dist;
|
if (right != null && left != null) {
|
||||||
}
|
hit = right.transform.gameObject.transform.position.x - transform.position.x <
|
||||||
|
Math.abs(left.transform.gameObject.transform.position.x - transform.position.x)
|
||||||
|
? right : left;
|
||||||
|
} else if (right != null) {
|
||||||
|
hit = right;
|
||||||
|
} else if (left != null) {
|
||||||
|
hit = left;
|
||||||
}
|
}
|
||||||
if (best != null) {
|
if (hit == null) {
|
||||||
if (target != best) {
|
|
||||||
// Acquisition / changement de cible : 1 ligne max par seconde
|
|
||||||
// (le check tourne / 60 frames), sur changement seulement.
|
|
||||||
GameLog.d("LS-AI", transform.gameObject.name + " : acquisition cible "
|
|
||||||
+ best.gameObject.name + " dist=" + (int) bestDist
|
|
||||||
+ " ennemi=" + transform.position + " ciblePos=" + best.position);
|
|
||||||
}
|
|
||||||
target = best;
|
|
||||||
targetIsObjective = false;
|
|
||||||
// Curseur de chemin remis à zéro (cf. fallback objectif : une
|
|
||||||
// re-acquisition sur un chemin consommé restait sinon figée).
|
|
||||||
pathIndex = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (targetIsObjective) {
|
|
||||||
// Cible objectif (cryopode) : maintenue tant qu'elle vit ; si
|
|
||||||
// détruite, on la lâche et le fallback objectif repartira.
|
|
||||||
Entity objective = target != null
|
|
||||||
? target.gameObject.getComponentOfType(Entity.class) : null;
|
|
||||||
if (objective == null || !objective.isDead()) return;
|
|
||||||
GameLog.d("LS-AI", transform.gameObject.name + " : objectif détruit, cible lâchée");
|
|
||||||
target = null;
|
target = null;
|
||||||
targetIsObjective = false;
|
targetIsObjective = false;
|
||||||
return;
|
} else if ((hit.transform.gameObject.getLayerMask() & visionLayerMaskTarget) ==
|
||||||
}
|
hit.transform.gameObject.getLayerMask()) {
|
||||||
if (target == null) return;
|
target = hit.transform;
|
||||||
/*
|
targetIsObjective = false;
|
||||||
* Persistance de la cible joueur : on NE la lâche pas au premier
|
|
||||||
* échec de LOS (sinon clignotement IDLE/TRACKING dès qu'un coin
|
|
||||||
* coupe la vue pendant 1 s). Garde-fou : cible lâchée si morte ou
|
|
||||||
* sortie de portée élargie (1.25 x visionRange) -> retour IDLE via
|
|
||||||
* la transition TRACKING -> IDLE.
|
|
||||||
* Limite documentée : le joueur n'est pas une Entity (Player extends
|
|
||||||
* Script), sa "mort" n'est pas détectable ici — s'il respawn ailleurs
|
|
||||||
* la poursuite continue vers sa position actuelle (comportement
|
|
||||||
* retenu : les ennemis viennent chercher le joueur).
|
|
||||||
*/
|
|
||||||
float dist = (float) Vector2.distance(transform.position, target.position);
|
|
||||||
Entity entity = target.gameObject.getComponentOfType(Entity.class);
|
|
||||||
if (entity != null && entity.isDead()) {
|
|
||||||
GameLog.d("LS-AI", transform.gameObject.name + " : cible " + target.gameObject.name
|
|
||||||
+ " morte, retour à l'état précédent");
|
|
||||||
target = null;
|
|
||||||
} else if (dist > visionRange * 1.25f) {
|
|
||||||
GameLog.d("LS-AI", transform.gameObject.name + " : cible " + target.gameObject.name
|
|
||||||
+ " hors de portée (" + (int) dist + "), cible lâchée");
|
|
||||||
target = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,18 +332,7 @@ public abstract class Behaviour {
|
|||||||
case COLD:
|
case COLD:
|
||||||
return "FROZEN_SHATTER";
|
return "FROZEN_SHATTER";
|
||||||
case KUBROW:
|
case KUBROW:
|
||||||
/*
|
return "DIE_KUBROW_" + getDirection(attackOrigin);
|
||||||
* POURQUOI pas de "DIE_KUBROW_*" : l'atlas ennemi
|
|
||||||
* (data/enemies/anim.json) ne contient AUCUNE animation de
|
|
||||||
* mort kubrow — le retour "DIE_KUBROW_FRONT" plantait
|
|
||||||
* AnimationState.valueOf en IllegalArgumentException FATALE
|
|
||||||
* dès qu'un ennemi mourait sous les crocs du Kubrow (crash
|
|
||||||
* de la mission Defense prouvé en repro desktop v0.12.x).
|
|
||||||
* Réutilisation de l'anim de mort au corps à corps (une
|
|
||||||
* morsure est un coup de près) en attendant un art dédié
|
|
||||||
* (TODO art : die_kubrow_front/back).
|
|
||||||
*/
|
|
||||||
return "DIE_SLASH_" + getDirection(attackOrigin);
|
|
||||||
default:
|
default:
|
||||||
System.err.println("Unknown damage type: " + damageType);
|
System.err.println("Unknown damage type: " + damageType);
|
||||||
return null;
|
return null;
|
||||||
@ -642,15 +359,7 @@ public abstract class Behaviour {
|
|||||||
protected abstract static class Builder<T extends Builder> {
|
protected abstract static class Builder<T extends Builder> {
|
||||||
float moveSpeed = 10;
|
float moveSpeed = 10;
|
||||||
float visionRange = 2000;
|
float visionRange = 2000;
|
||||||
/*
|
boolean willPatrol = false;
|
||||||
* POURQUOI le défaut passe à true (v0.12.x) : willPatrol était un
|
|
||||||
* champ mort 2017 (stocké, jamais lu) et tous les ennemis passaient
|
|
||||||
* explicitement false — d'où le retour "aucun idle pattern, plantés
|
|
||||||
* là". Un ennemi patrouille désormais PAR DÉFAUT en IDLE ; un
|
|
||||||
* comportement statique reste possible via setWillPatrol(false)
|
|
||||||
* (ex : WereDrahk, qui garde son false explicite).
|
|
||||||
*/
|
|
||||||
boolean willPatrol = true;
|
|
||||||
|
|
||||||
public T setMoveSpeed(float moveSpeed) {
|
public T setMoveSpeed(float moveSpeed) {
|
||||||
this.moveSpeed = moveSpeed;
|
this.moveSpeed = moveSpeed;
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package com.ezardlabs.lostsector.levels;
|
|||||||
|
|
||||||
import com.ezardlabs.dethsquare.Camera;
|
import com.ezardlabs.dethsquare.Camera;
|
||||||
import com.ezardlabs.dethsquare.GameObject;
|
import com.ezardlabs.dethsquare.GameObject;
|
||||||
import com.ezardlabs.dethsquare.GuiRenderer;
|
|
||||||
import com.ezardlabs.dethsquare.GuiText;
|
import com.ezardlabs.dethsquare.GuiText;
|
||||||
import com.ezardlabs.dethsquare.Input;
|
import com.ezardlabs.dethsquare.Input;
|
||||||
import com.ezardlabs.dethsquare.Input.KeyCode;
|
import com.ezardlabs.dethsquare.Input.KeyCode;
|
||||||
@ -33,28 +32,9 @@ import java.net.UnknownHostException;
|
|||||||
* persisté en PlayerPrefs (mp_host/mp_port) et repris par MultiplayerLevel.
|
* persisté en PlayerPrefs (mp_host/mp_port) et repris par MultiplayerLevel.
|
||||||
* LS_MP_HOST/LS_MP_PORT (env) restent prioritaires pour le desktop (test).
|
* LS_MP_HOST/LS_MP_PORT (env) restent prioritaires pour le desktop (test).
|
||||||
*
|
*
|
||||||
* DA (retour v0.11.0 : "le menu multijoueur est dégeulasse et ne respecte
|
|
||||||
* pas la DA du reste des menus") : le lobby reprenait le rendu "texte nu" du
|
|
||||||
* tout premier jet — plus aucune pièce du menu principal. Désormais il est
|
|
||||||
* construit avec LES MÊMES SPRITES que MainMenu (cadres bleus néon biseautés
|
|
||||||
* images/menus/main/top|middle|bottom.png + surlignages dorés), même typo
|
|
||||||
* (fonte pixel 8-bit), même mécanique d'échelle et de clic. Seul sprite
|
|
||||||
* nouveau : le cadre d'ERREUR rouge (images/menus/lobby/error_frame.png),
|
|
||||||
* dérivé de top.png par échange de palette — méthode documentée dans
|
|
||||||
* scripts/gen-lobby-sprites.py (même approche que les flèches de boussole
|
|
||||||
* v0.10.0 : sprites pixel-art générés dans la palette du jeu).
|
|
||||||
*
|
|
||||||
* Interaction : TouchControls est attaché et MASQUÉ (aucun bouton de jeu
|
* Interaction : TouchControls est attaché et MASQUÉ (aucun bouton de jeu
|
||||||
* n'a de sens ici) mais son écoute "tap hors bouton = clic" reste active :
|
* n'a de sens ici) mais son écoute "tap hors bouton = clic" reste active :
|
||||||
* les barres ci-dessous se cliquent comme les items du menu principal.
|
* les libellés ci-dessous se cliquent comme les items du menu principal.
|
||||||
* Les textes DYNAMIQUES (serveur, statut, erreur) restent alignés à gauche
|
|
||||||
* sur la colonne des libellés de barres (x + 150*s) : le rendu de GuiText
|
|
||||||
* ne repositionne PAS ses caractères existants au setText (seul le sprite
|
|
||||||
* change), un texte variable doit donc avoir une position fixe.
|
|
||||||
*
|
|
||||||
* Les textes affichés sont sans accents ni apostrophes : l'atlas de police
|
|
||||||
* 2017 n'a aucun glyphe accentué (GuiText les SAUTE avec un warning, cf.
|
|
||||||
* son patch "glyphe absent") — "réessayez" se rendait "r essayez".
|
|
||||||
*/
|
*/
|
||||||
public class MultiplayerLobbyLevel extends Level {
|
public class MultiplayerLobbyLevel extends Level {
|
||||||
private static final String[][] PRESETS = {
|
private static final String[][] PRESETS = {
|
||||||
@ -62,197 +42,48 @@ public class MultiplayerLobbyLevel extends Level {
|
|||||||
{"10.0.2.2", "3000"},
|
{"10.0.2.2", "3000"},
|
||||||
{"8bitwarframe.com", "3000"},
|
{"8bitwarframe.com", "3000"},
|
||||||
};
|
};
|
||||||
/** Libellé "humain" de chaque préréglage (ligne de statut, sans accents :
|
|
||||||
* atlas de police 2017 sans glyphes accentués). */
|
|
||||||
private static final String[] PRESET_LABELS = {"local", "emulateur", "serveur historique"};
|
|
||||||
private static final String TAG = "LS-MISSION";
|
private static final String TAG = "LS-MISSION";
|
||||||
|
|
||||||
/*
|
|
||||||
* Disposition (repère GUI 1920x1080, comme Menu) :
|
|
||||||
* titre MULTIJOUEUR y=40 (fonte 60, centré)
|
|
||||||
* adresse "Serveur : host:port" y=130 (fonte 40, colonne des barres)
|
|
||||||
* barres SERVEUR / LANCER / RETOUR y0=190, pas 156*s (pieces Menu)
|
|
||||||
* statut "Serveur n/3 : libellé" sous les barres + 45
|
|
||||||
* cadre d'erreur rouge + message même emplacement que le statut
|
|
||||||
*/
|
|
||||||
private static final float TITLE_Y = 40f;
|
|
||||||
private static final float TITLE_FONT = 60f;
|
|
||||||
private static final float ADDRESS_Y = 130f;
|
|
||||||
private static final float HEADER_BOTTOM = 190f; // y0 des barres (miroir du LOGO_BOTTOM du Menu)
|
|
||||||
private static final float BOTTOM_MARGIN = 40f; // idem Menu : geste Android
|
|
||||||
private static final float ERROR_GAP = 30f; // espace barres -> zone statut/erreur
|
|
||||||
|
|
||||||
private int presetIndex;
|
private int presetIndex;
|
||||||
// Géométrie partagée rendu <-> zones cliquables (calculée dans onLoad).
|
|
||||||
private float barX, barWidth, pieceHeight, spacing, s, y0, barsBottom, errorY;
|
|
||||||
private RectF[] barZones;
|
|
||||||
|
|
||||||
private GuiText serverText;
|
private GuiText serverText;
|
||||||
private GuiText statusText;
|
|
||||||
private GuiText errorText;
|
private GuiText errorText;
|
||||||
private GameObject errorFrame;
|
|
||||||
private GameObject[] highlights;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
TouchControls.attach(); // EN PREMIER (ordre d'update) — écoute "clic"
|
TouchControls.attach(); // EN PREMIER (ordre d'update) — écoute "clic"
|
||||||
TouchControls.setButtonsVisible(false); // pas de boutons de jeu au lobby
|
TouchControls.setButtonsVisible(false); // pas de boutons de jeu au lobby
|
||||||
|
|
||||||
/*
|
|
||||||
* LS_MP_AUTOJOIN=1 : lancement automatique de la recherche au
|
|
||||||
* chargement du lobby (outil de test : la coop desktop <-> émulateur
|
|
||||||
* nécessitait un clic sur LANCER — impossible à simuler côté desktop
|
|
||||||
* sans accès d'aide macOS ; cf. scripts de test). Désactivé par
|
|
||||||
* défaut : le joueur garde le contrôle du lancement.
|
|
||||||
*/
|
|
||||||
if ("1".equals(System.getenv("LS_MP_AUTOJOIN"))) {
|
|
||||||
GameLog.i(TAG, "LS_MP_AUTOJOIN : lancement automatique de la recherche");
|
|
||||||
connecting = true;
|
|
||||||
launch();
|
|
||||||
}
|
|
||||||
|
|
||||||
GameObject.instantiate(new GameObject("Camera", new Camera(true)), new Vector2());
|
GameObject.instantiate(new GameObject("Camera", new Camera(true)), new Vector2());
|
||||||
|
|
||||||
TextureAtlas font = TextureAtlas.load("fonts");
|
TextureAtlas font = TextureAtlas.load("fonts");
|
||||||
|
|
||||||
/*
|
// Positions en unités GUI PURES (repère 1920x1080, comme le Menu) :
|
||||||
* Même mécanique d'échelle que Menu.start : l'espace GUI réellement
|
// le repère est multiplié par refScale au rendu, indépendant de la
|
||||||
* visible dépend du ratio d'écran (Android 20:9 -> 864 GUI de haut) —
|
// résolution réelle.
|
||||||
* les barres sont reserrées uniformément si nécessaire.
|
GameObject.instantiate(new GameObject("Lobby Title", new GuiText("MULTIJOUEUR", font, 60)),
|
||||||
*/
|
new Vector2(660, 60));
|
||||||
float guiVisibleHeight = Screen.width == 0
|
|
||||||
? 1080f // garde : Screen pas encore resizé (div/0), repère GUI par défaut
|
|
||||||
: Screen.height / (Screen.width / 1920f);
|
|
||||||
float stackHeight = (PRESETS.length - 1) * 156 + 144;
|
|
||||||
s = Math.min(1f, (guiVisibleHeight - HEADER_BOTTOM - BOTTOM_MARGIN) / stackHeight);
|
|
||||||
y0 = HEADER_BOTTOM;
|
|
||||||
barX = 960 - 816 * s / 2;
|
|
||||||
barWidth = 816 * s;
|
|
||||||
pieceHeight = 156 * s;
|
|
||||||
spacing = 156 * s;
|
|
||||||
barsBottom = y0 + (PRESETS.length - 1) * spacing + 144 * s;
|
|
||||||
errorY = barsBottom + ERROR_GAP;
|
|
||||||
|
|
||||||
// Titre centré : texte STATIQUE, getWidth() est sûr ici (GuiText ne
|
// Affichage du serveur courant (PlayerPrefs, env prioritaire).
|
||||||
// recalcule la largeur qu'au setText — un texte dynamique centré
|
|
||||||
// dériverait, d'où l'alignement à gauche des textes variables).
|
|
||||||
GuiText title = new GuiText("MULTIJOUEUR", font, TITLE_FONT, 10);
|
|
||||||
GameObject.instantiate(new GameObject("Lobby Title", title),
|
|
||||||
new Vector2(960 - title.getWidth() / 2, TITLE_Y));
|
|
||||||
|
|
||||||
// Affichage du serveur courant (PlayerPrefs, env prioritaire), aligné
|
|
||||||
// sur la colonne des libellés des barres (x + 150*s, comme Menu).
|
|
||||||
String host = currentHost();
|
String host = currentHost();
|
||||||
int port = currentPort();
|
int port = currentPort();
|
||||||
// presetIndex aligné sur le serveur PERSISTÉ : sans ça, le premier clic
|
// presetIndex aligné sur le serveur PERSISTÉ : sans ça, le premier clic
|
||||||
// "SERVEUR" proposait le préréglage 0 au lieu du suivant (QA v0.10.0).
|
// "SERVEUR" proposait le préréglage 0 au lieu du suivant (QA v0.10.0).
|
||||||
presetIndex = matchPreset(host, port);
|
presetIndex = matchPreset(host, port);
|
||||||
serverText = new GuiText("Serveur : " + host + ":" + port, font, 40, 10);
|
serverText = new GuiText("Serveur: " + host + ":" + port, font, 40);
|
||||||
GameObject.instantiate(new GameObject("Server Text", serverText),
|
GameObject.instantiate(new GameObject("Server Text", serverText), new Vector2(660, 300));
|
||||||
new Vector2(barX + 150 * s, ADDRESS_Y));
|
|
||||||
|
|
||||||
/*
|
GameObject.instantiate(new GameObject("Server Change Hint",
|
||||||
* Barres du menu principal (top/middle/bottom + surlignages) : depths
|
new GuiText("SERVEUR : changer de préréglage", font, 30)), new Vector2(660, 420));
|
||||||
* 8/9/10 identiques au Menu — le tri GUI secondaire à depth égal se
|
|
||||||
* fait sur l'ID de texture, donc dépend de l'ordre de chargement.
|
|
||||||
*/
|
|
||||||
String[] pieceImages = {
|
|
||||||
"images/menus/main/top.png",
|
|
||||||
"images/menus/main/middle.png",
|
|
||||||
"images/menus/main/bottom.png",
|
|
||||||
};
|
|
||||||
String[] barLabels = {"SERVEUR", "LANCER", "RETOUR"};
|
|
||||||
GameObject[] pieces = new GameObject[pieceImages.length];
|
|
||||||
for (int i = 0; i < pieces.length; i++) {
|
|
||||||
float h = i == pieces.length - 1 ? 144 * s : pieceHeight;
|
|
||||||
GuiRenderer renderer = new GuiRenderer(pieceImages[i], barWidth, h);
|
|
||||||
renderer.setDepth(8);
|
|
||||||
pieces[i] = GameObject.instantiate(new GameObject("Lobby Piece " + i, renderer),
|
|
||||||
new Vector2(barX, y0 + spacing * i));
|
|
||||||
}
|
|
||||||
// Surlignage doré au survol : mêmes formules d'ancrage que Menu
|
|
||||||
// (chevron droit + variante élargie pour la dernière barre).
|
|
||||||
highlights = new GameObject[pieces.length];
|
|
||||||
for (int i = 0; i < highlights.length; i++) {
|
|
||||||
boolean last = i == highlights.length - 1;
|
|
||||||
GuiRenderer renderer = new GuiRenderer(
|
|
||||||
last ? "images/menus/main/highlight_bottom.png" : "images/menus/main/highlight.png",
|
|
||||||
(last ? 414 : 156) * s, 66 * s);
|
|
||||||
renderer.setDepth(9);
|
|
||||||
highlights[i] = GameObject.instantiate(
|
|
||||||
new GameObject("Lobby Highlight", renderer),
|
|
||||||
pieces[i].transform.position.offset((last ? 66 : 636) * s, (last ? 54 : 25) * s));
|
|
||||||
highlights[i].setActive(false);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < barLabels.length; i++) {
|
|
||||||
// +28 sur la dernière barre : la pièce "bottom" fait 144 de haut
|
|
||||||
// (au lieu de 156) — recentrage identique au Menu.
|
|
||||||
GameObject.instantiate(new GameObject("Lobby Bar Text",
|
|
||||||
new GuiText(barLabels[i], font, 50 * s, 10)),
|
|
||||||
pieces[i].transform.position.offset(150 * s, (40 + (i == barLabels.length - 1 ? 28 : 0)) * s));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
GameObject.instantiate(new GameObject("Launch Hint",
|
||||||
* Ligne de statut / zone d'erreur : une recherche échouée (hôte
|
new GuiText("LANCER : chercher une partie", font, 30)), new Vector2(660, 530));
|
||||||
* injoignable) rendait le lobby DÉFINITIVEMENT mort sans feedback
|
|
||||||
* (QA v0.10.0 P2). Le cadre rouge (généré, cf. en-tête de classe)
|
|
||||||
* rend l'erreur visible ET dans la DA ; le statut simple la remplace
|
|
||||||
* tant que tout va bien (Jamais les deux en même temps).
|
|
||||||
*/
|
|
||||||
GuiRenderer errorRenderer = new GuiRenderer("images/menus/lobby/error_frame.png", 1400 * s, 110 * s);
|
|
||||||
errorRenderer.setDepth(8);
|
|
||||||
errorFrame = GameObject.instantiate(new GameObject("Lobby Error Frame", errorRenderer),
|
|
||||||
new Vector2(960 - 700 * s, errorY));
|
|
||||||
errorFrame.setActive(false);
|
|
||||||
errorText = new GuiText("", font, 30, 10);
|
|
||||||
GameObject.instantiate(new GameObject("Lobby Error Text", errorText),
|
|
||||||
new Vector2(960 - 700 * s + 150 * s, errorY + 38 * s));
|
|
||||||
|
|
||||||
statusText = new GuiText(defaultStatus(host), font, 30, 10);
|
GameObject.instantiate(new GameObject("Back Hint",
|
||||||
GameObject.instantiate(new GameObject("Lobby Status", statusText),
|
new GuiText("RETOUR : menu principal", font, 30)), new Vector2(660, 640));
|
||||||
new Vector2(barX + 150 * s, errorY + 15 * s));
|
|
||||||
|
|
||||||
// Zones cliquables : les barres ENTIÈRES (816 GUI de large), cibles
|
|
||||||
// larges pour le tactile — les textes seuls (50 GUI) étaient trop
|
|
||||||
// fins sur mobile.
|
|
||||||
barZones = new RectF[pieces.length];
|
|
||||||
for (int i = 0; i < barZones.length; i++) {
|
|
||||||
barZones[i] = new RectF(barX, y0 + spacing * i, barX + barWidth, y0 + spacing * i + pieceHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameObject.instantiate(new GameObject("Lobby Click Handler", new LobbyClicks()), new Vector2());
|
GameObject.instantiate(new GameObject("Lobby Click Handler", new LobbyClicks()), new Vector2());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Statut initial : libellé du préréglage courant, sauf hôte forcé par env (desktop). */
|
|
||||||
private String defaultStatus(String host) {
|
|
||||||
if (System.getenv("LS_MP_HOST") != null && !System.getenv("LS_MP_HOST").isEmpty()) {
|
|
||||||
return "Serveur defini par LS_MP_HOST";
|
|
||||||
}
|
|
||||||
int idx = matchPreset(host, currentPort());
|
|
||||||
// matchPreset rend 0 aussi quand rien ne correspond : on ne nome le
|
|
||||||
// préréglage que si le couple host:port correspond VRAIMENT.
|
|
||||||
if (PRESETS[idx][0].equals(host)) {
|
|
||||||
// Tiret et pas "/" : le glyphe "/" est ABSENT de l'atlas de fonte
|
|
||||||
// 2017 — il rendait "Serveur 1 3" (trou dans le texte, et un
|
|
||||||
// null dans characters qui crashait setText, cf. GuiText).
|
|
||||||
return "Serveur " + (idx + 1) + "-" + PRESETS.length + " : " + PRESET_LABELS[idx];
|
|
||||||
}
|
|
||||||
return "Serveur : " + host;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Bascule l'affichage statut (par défaut) <-> erreur (cadre rouge). */
|
|
||||||
private void afficherStatus(String message) {
|
|
||||||
errorFrame.setActive(false);
|
|
||||||
errorText.setText("");
|
|
||||||
statusText.setText(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void afficherErreur(String message) {
|
|
||||||
statusText.setText("");
|
|
||||||
errorFrame.setActive(true);
|
|
||||||
errorText.setText(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drapeau de recherche (classe externe : partagé entre LobbyClicks et le
|
// Drapeau de recherche (classe externe : partagé entre LobbyClicks et le
|
||||||
// listener anonyme de launch() — onError doit pouvoir le réinitialiser).
|
// listener anonyme de launch() — onError doit pouvoir le réinitialiser).
|
||||||
private boolean connecting = false;
|
private boolean connecting = false;
|
||||||
@ -281,40 +112,22 @@ public class MultiplayerLobbyLevel extends Level {
|
|||||||
|
|
||||||
/** Gestionnaire de clics du lobby (même modèle que Menu). */
|
/** Gestionnaire de clics du lobby (même modèle que Menu). */
|
||||||
private class LobbyClicks extends Script {
|
private class LobbyClicks extends Script {
|
||||||
|
private TextureAtlas font;
|
||||||
private long lastClick = 0;
|
private long lastClick = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
runWhenPaused = true;
|
runWhenPaused = true;
|
||||||
|
font = TextureAtlas.load("fonts");
|
||||||
|
// Zone d'erreur : une recherche échouée (hôte injoignable) rendait
|
||||||
|
// le lobby DÉFINITIVEMENT mort sans feedback (QA v0.10.0 P2).
|
||||||
|
errorText = new GuiText("", font, 30);
|
||||||
|
GameObject.instantiate(new GameObject("Lobby Error", errorText), new Vector2(660, 750));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timeout "serveur ne répond pas du tout" (preset 8bitwarframe.com
|
|
||||||
// mort : UDP sans réponse, onError jamais invoqué, lobby gelé — QA
|
|
||||||
// v0.11.0 P2). MatchmakingListener n'a pas de callback timeout, le
|
|
||||||
// watchdog est géré ici.
|
|
||||||
private long connectingSince = 0;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
if (connecting) {
|
if (connecting) return;
|
||||||
// Recherche en cours : ni clics ni survol (le lobby "gèle"
|
|
||||||
// visuellement aussi — les surlignages s'éteignent).
|
|
||||||
for (GameObject highlight : highlights) {
|
|
||||||
highlight.setActive(false);
|
|
||||||
}
|
|
||||||
if (connectingSince == 0) {
|
|
||||||
connectingSince = System.currentTimeMillis();
|
|
||||||
} else if (System.currentTimeMillis() - connectingSince > 8000) {
|
|
||||||
connecting = false;
|
|
||||||
connectingSince = 0;
|
|
||||||
// Message court : le cadre d'erreur fait 1400 GUI de large,
|
|
||||||
// une ligne trop longue en sortirait (affiche sur le noir).
|
|
||||||
afficherErreur("Erreur : le serveur ne repond pas - reessayez");
|
|
||||||
GameLog.e(TAG, "Multiplayer : timeout serveur 8s");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
connectingSince = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Zones cliquables en unités GUI ; la souris (Input.mousePosition)
|
* Zones cliquables en unités GUI ; la souris (Input.mousePosition)
|
||||||
@ -325,40 +138,46 @@ public class MultiplayerLobbyLevel extends Level {
|
|||||||
if (scale <= 0) return;
|
if (scale <= 0) return;
|
||||||
float mouseX = Input.mousePosition.x / scale;
|
float mouseX = Input.mousePosition.x / scale;
|
||||||
float mouseY = Input.mousePosition.y / scale;
|
float mouseY = Input.mousePosition.y / scale;
|
||||||
|
RectF serverZone = rect(660, 420, 800, 50);
|
||||||
|
RectF launchZone = rect(660, 530, 800, 50);
|
||||||
|
RectF backZone = rect(660, 640, 800, 50);
|
||||||
|
|
||||||
|
boolean clicked = Input.getKeyDown(KeyCode.MOUSE_LEFT)
|
||||||
|
&& serverText != null && hitZone(new Vector2(mouseX, mouseY), serverZone, launchZone, backZone);
|
||||||
|
if (!clicked) return;
|
||||||
|
|
||||||
|
if (System.currentTimeMillis() - lastClick < 500) return;
|
||||||
|
lastClick = System.currentTimeMillis();
|
||||||
|
|
||||||
Vector2 mouseGui = new Vector2(mouseX, mouseY);
|
Vector2 mouseGui = new Vector2(mouseX, mouseY);
|
||||||
|
if (inZone(mouseGui, serverZone)) {
|
||||||
// Surlignage au survol, même feedback que le menu principal.
|
presetIndex = (presetIndex + 1) % PRESETS.length;
|
||||||
int hovered = -1;
|
PlayerPrefs.setInt("mp_port", Integer.parseInt(PRESETS[presetIndex][1]));
|
||||||
for (int i = 0; i < barZones.length; i++) {
|
PlayerPrefs.setString("mp_host", PRESETS[presetIndex][0]);
|
||||||
boolean inside = barZones[i].contains(mouseGui);
|
serverText.setText("Serveur: " + PRESETS[presetIndex][0] + ":" + PRESETS[presetIndex][1]);
|
||||||
highlights[i].setActive(inside);
|
GameLog.i(TAG, "Multiplayer : serveur préréglé -> " + PRESETS[presetIndex][0] + ":"
|
||||||
if (inside && hovered == -1) hovered = i;
|
+ PRESETS[presetIndex][1]);
|
||||||
|
} else if (inZone(mouseGui, launchZone)) {
|
||||||
|
connecting = true;
|
||||||
|
launch();
|
||||||
|
} else if (inZone(mouseGui, backZone)) {
|
||||||
|
LevelManager.loadLevel("main_menu");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Input.getKeyDown(KeyCode.MOUSE_LEFT) && hovered != -1) {
|
private boolean inZone(Vector2 mouse, RectF zone) {
|
||||||
if (System.currentTimeMillis() - lastClick < 500) return;
|
return zone.contains(mouse.x, mouse.y);
|
||||||
lastClick = System.currentTimeMillis();
|
}
|
||||||
|
|
||||||
if (hovered == 0) {
|
private RectF rect(float x, float y, float w, float h) {
|
||||||
presetIndex = (presetIndex + 1) % PRESETS.length;
|
return new RectF(x, y, x + w, y + h);
|
||||||
PlayerPrefs.setInt("mp_port", Integer.parseInt(PRESETS[presetIndex][1]));
|
}
|
||||||
PlayerPrefs.setString("mp_host", PRESETS[presetIndex][0]);
|
|
||||||
serverText.setText("Serveur : " + PRESETS[presetIndex][0] + ":" + PRESETS[presetIndex][1]);
|
private boolean hitZone(Vector2 mouse, RectF... zones) {
|
||||||
// Changer de serveur efface une erreur précédente : le
|
for (RectF z : zones) {
|
||||||
// lobby repart propre (statut = libellé du nouveau preset).
|
if (z.contains(mouse.x, mouse.y)) return true;
|
||||||
afficherStatus("Serveur " + (presetIndex + 1) + "/" + PRESETS.length + " : "
|
|
||||||
+ PRESET_LABELS[presetIndex]);
|
|
||||||
GameLog.i(TAG, "Multiplayer : serveur préréglé -> " + PRESETS[presetIndex][0] + ":"
|
|
||||||
+ PRESETS[presetIndex][1]);
|
|
||||||
} else if (hovered == 1) {
|
|
||||||
connecting = true;
|
|
||||||
connectingSince = System.currentTimeMillis();
|
|
||||||
afficherStatus("Recherche d'une partie...");
|
|
||||||
launch();
|
|
||||||
} else if (hovered == 2) {
|
|
||||||
LevelManager.loadLevel("main_menu");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,30 +190,10 @@ public class MultiplayerLobbyLevel extends Level {
|
|||||||
try {
|
try {
|
||||||
ip = InetAddress.getByName(host);
|
ip = InetAddress.getByName(host);
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
// Réinitialisation + affichage : sans ça, le lobby gelait
|
|
||||||
// silencieusement (QA v0.11.0 P2).
|
|
||||||
connecting = false;
|
|
||||||
afficherErreur("Erreur : hote introuvable : " + host);
|
|
||||||
GameLog.e(TAG, "Multiplayer : hôte '" + host + "' introuvable");
|
GameLog.e(TAG, "Multiplayer : hôte '" + host + "' introuvable");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Matchmaker matchmaker;
|
Matchmaker matchmaker = new Matchmaker(ip, port);
|
||||||
try {
|
|
||||||
matchmaker = new Matchmaker(ip, port);
|
|
||||||
} catch (RuntimeException e) {
|
|
||||||
/*
|
|
||||||
* Défense en profondeur : l'échec de création de la socket
|
|
||||||
* (EPERM sans permission INTERNET, FD épuisés…) ne doit JAMAIS
|
|
||||||
* tuer le thread GL — crash v0.11.0 reproduit sur émulateur
|
|
||||||
* ("crash dès la sélection d'une recherche de partie"). La
|
|
||||||
* permission INTERNET (manifest) est le fix racine ; ce catch
|
|
||||||
* rend l'échec AFFICHABLE et le lobby réutilisable.
|
|
||||||
*/
|
|
||||||
GameLog.e(TAG, "Multiplayer : création de la socket impossible", e);
|
|
||||||
connecting = false;
|
|
||||||
afficherErreur("Erreur : connexion au serveur impossible");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
matchmaker.findGame(new MatchmakingListener() {
|
matchmaker.findGame(new MatchmakingListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateGame() {
|
public boolean onCreateGame() {
|
||||||
@ -411,7 +210,7 @@ public class MultiplayerLobbyLevel extends Level {
|
|||||||
public void onError(String error) {
|
public void onError(String error) {
|
||||||
GameLog.e(TAG, "Multiplayer : " + error);
|
GameLog.e(TAG, "Multiplayer : " + error);
|
||||||
connecting = false; // le lobby redevient utilisable (retry)
|
connecting = false; // le lobby redevient utilisable (retry)
|
||||||
afficherErreur("Erreur : " + error + " - reessayez ou changez de serveur");
|
errorText.setText("Erreur: " + error + " (réessayez ou changez de serveur)");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,13 +69,7 @@ public class MapManager {
|
|||||||
// proceduralSeed = 1479363189995L; // Testing
|
// proceduralSeed = 1479363189995L; // Testing
|
||||||
}
|
}
|
||||||
rand = new Random(proceduralSeed);
|
rand = new Random(proceduralSeed);
|
||||||
// POURQUOI GameLog au lieu de System.out : sur Android System.out va
|
System.out.println("Procedural Seed: " + proceduralSeed);
|
||||||
// dans logcat sous un tag inexploitable, et HORS du tampon GameLog —
|
|
||||||
// un crash pendant la génération perdra tout l'historique de la
|
|
||||||
// génération sans ces lignes. Le seed est loggué pour REPRODUIRE une
|
|
||||||
// map fautive (MapConfig.proceduralSeed).
|
|
||||||
GameLog.i("LS-MAP", "génération procédurale : seed=" + proceduralSeed
|
|
||||||
+ " rooms=" + mapCfg.numRooms + " type=" + mapCfg.type);
|
|
||||||
|
|
||||||
// Keep a list of added sections
|
// Keep a list of added sections
|
||||||
ArrayList<MapSegment> renderSegments = new ArrayList<>();
|
ArrayList<MapSegment> renderSegments = new ArrayList<>();
|
||||||
@ -99,30 +93,16 @@ public class MapManager {
|
|||||||
Object[] objStartSeg = mapCfg.spawnSegments.values().toArray();
|
Object[] objStartSeg = mapCfg.spawnSegments.values().toArray();
|
||||||
ArrayList<MapSegment> spawnSegs = (ArrayList<MapSegment>) getRandObj(objStartSeg);
|
ArrayList<MapSegment> spawnSegs = (ArrayList<MapSegment>) getRandObj(objStartSeg);
|
||||||
nextSeg = getRandObj(spawnSegs);
|
nextSeg = getRandObj(spawnSegs);
|
||||||
/*
|
System.out.print("Next Segment " + i + ": " + nextSeg.map.getFilePath()
|
||||||
* Garde de survie : getRandObj renvoie null si aucune liste
|
+ "\n offset: " + nextOffset.toString()
|
||||||
* n'est vide-sûre (aucun segment de spawn chargé, ex : assets
|
);
|
||||||
* manquants sur Android). Depuis 2017 ça faisait un NPE
|
|
||||||
* anonyme à nextSeg.map — le suspect n°1 des crashs Android
|
|
||||||
* en Exterminate/Defend procédural. On loggue le POURQUOI et
|
|
||||||
* on saute ce segment au lieu de crasher sans information.
|
|
||||||
*/
|
|
||||||
if (nextSeg == null) {
|
|
||||||
GameLog.e("LS-MAP", "génération : AUCUN segment de spawn disponible"
|
|
||||||
+ " (spawnSegments=" + mapCfg.spawnSegments.size() + " entrées)"
|
|
||||||
+ " — vérifier maps/procedural/ dans les assets");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
GameLog.i("LS-MAP", "segment 0 (spawn) : '" + nextSeg.map.getFilePath()
|
|
||||||
+ "' offset=" + nextOffset);
|
|
||||||
} else {
|
} else {
|
||||||
MapSegmentConnector currConn = getRandomValidConnector(mapCfg, currSeg, mapSegGrid, true);
|
MapSegmentConnector currConn = getRandomValidConnector(mapCfg, currSeg, mapSegGrid, true);
|
||||||
if (currConn == null) {
|
if (currConn == null) {
|
||||||
GameLog.e("LS-MAP", "segment #" + i + " : aucun connecteur valide sur '"
|
System.err.println("Null connector found on segment #" + i);
|
||||||
+ (currSeg == null ? "null" : currSeg.map.getFilePath())
|
|
||||||
+ "' — segment sauté");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
System.out.println(" Exit From: " + currConn.toString());
|
||||||
if(i == mapCfg.numRooms - 1) {
|
if(i == mapCfg.numRooms - 1) {
|
||||||
// Extraction segment
|
// Extraction segment
|
||||||
nextSeg = getRandomValidSegment(mapCfg, mapCfg.extractSegments,currSeg, currConn, mapSegGrid, true);
|
nextSeg = getRandomValidSegment(mapCfg, mapCfg.extractSegments,currSeg, currConn, mapSegGrid, true);
|
||||||
@ -130,15 +110,6 @@ public class MapManager {
|
|||||||
// Main segments.
|
// Main segments.
|
||||||
nextSeg = getRandomValidSegment(mapCfg, mapCfg.mainSegments, currSeg, currConn, mapSegGrid, true);
|
nextSeg = getRandomValidSegment(mapCfg, mapCfg.mainSegments, currSeg, currConn, mapSegGrid, true);
|
||||||
}
|
}
|
||||||
if (nextSeg == null) {
|
|
||||||
// POURQUOI : la sélection peut renvoyer null (aucun segment
|
|
||||||
// valide pour ce type de connecteur) — crash NPE anonyme en
|
|
||||||
// 2017. On trace le connecteur fautif et on saute.
|
|
||||||
GameLog.e("LS-MAP", "segment #" + i + " : aucun segment valide pour '"
|
|
||||||
+ currConn + "' (sortie de '" + currSeg.map.getFilePath() + "') — segment sauté");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
GameLog.d("LS-MAP", "segment #" + i + " : sortie de " + currConn);
|
|
||||||
|
|
||||||
ArrayList<MapSegmentConnector> nextValidConns = new ArrayList<>();
|
ArrayList<MapSegmentConnector> nextValidConns = new ArrayList<>();
|
||||||
for (MapSegmentConnector c : nextSeg.connectors) {
|
for (MapSegmentConnector c : nextSeg.connectors) {
|
||||||
@ -172,8 +143,9 @@ public class MapManager {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GameLog.d("LS-MAP", "segment #" + i + " : '" + nextSeg.map.getFilePath()
|
System.out.println("Next Segment " + i + ": " + nextSeg.map.getFilePath()
|
||||||
+ "' entrée depuis " + nextConn + " offset=" + nextOffset);
|
+ "\n Enter From: " + nextConn.toString() + " offset: " + nextOffset.toString()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
nextSeg.pos = new Vector2(nextOffset.x, nextOffset.y);
|
nextSeg.pos = new Vector2(nextOffset.x, nextOffset.y);
|
||||||
renderSegments.add(nextSeg);
|
renderSegments.add(nextSeg);
|
||||||
@ -181,16 +153,8 @@ public class MapManager {
|
|||||||
currSeg = nextSeg;
|
currSeg = nextSeg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grille du chemin principal en UN message (un println par ligne
|
System.out.println("Main Path Grid:");
|
||||||
// polluerait le tampon/journal sans valeur de debug supplémentaire).
|
printMapSegmentGrid(mapSegGrid, mapSegGridW, mapSegGridH);
|
||||||
StringBuilder gridSb = new StringBuilder("grille segments :\n");
|
|
||||||
for(int y = 0; y < mapSegGridH; y++) {
|
|
||||||
for(int x = 0; x < mapSegGridW; x++) {
|
|
||||||
gridSb.append(mapSegGrid[x][y] != null ? " *" : " ");
|
|
||||||
}
|
|
||||||
gridSb.append('\n');
|
|
||||||
}
|
|
||||||
GameLog.d("LS-MAP", gridSb.toString());
|
|
||||||
|
|
||||||
// Find "free" connectors and fill them up.
|
// Find "free" connectors and fill them up.
|
||||||
ArrayList<MapSegment> lockSegmentsToRender = new ArrayList<>();
|
ArrayList<MapSegment> lockSegmentsToRender = new ArrayList<>();
|
||||||
@ -208,11 +172,7 @@ public class MapManager {
|
|||||||
lockSeg.pos = seg.pos;
|
lockSeg.pos = seg.pos;
|
||||||
if(lockSeg.connectors.size() != 1)
|
if(lockSeg.connectors.size() != 1)
|
||||||
{
|
{
|
||||||
// POURQUOI : un segment de verrou mal câblé casse le
|
System.err.println("Lock segment '" + lockSeg.map.getFilePath() + "' has more than one connector!");
|
||||||
// remplissage des connecteurs libres en silence — en
|
|
||||||
// procédural, ça se voit plus tard comme un couloir mort.
|
|
||||||
GameLog.e("LS-MAP", "segment de verrou '" + lockSeg.map.getFilePath()
|
|
||||||
+ "' a " + lockSeg.connectors.size() + " connecteur(s) au lieu d'1 !");
|
|
||||||
}
|
}
|
||||||
conn.connect(lockSeg.connectors.get(0));
|
conn.connect(lockSeg.connectors.get(0));
|
||||||
lockSegmentsToRender.add(lockSeg);
|
lockSegmentsToRender.add(lockSeg);
|
||||||
@ -227,10 +187,6 @@ public class MapManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NavMesh.init(solidityMap);
|
NavMesh.init(solidityMap);
|
||||||
// Résumé de fin de génération : la première ligne à lire quand une
|
|
||||||
// mission procédurale plante ou spawn dans le vide.
|
|
||||||
GameLog.i("LS-MAP", "génération procédurale done : segments=" + renderSegments.size()
|
|
||||||
+ " seed=" + proceduralSeed);
|
|
||||||
|
|
||||||
// printSolidityMapArray();
|
// printSolidityMapArray();
|
||||||
|
|
||||||
@ -273,16 +229,6 @@ public class MapManager {
|
|||||||
|
|
||||||
private static MapSegment getRandomValidSegment(MapConfig mapCfg, HashMap<String, ArrayList<MapSegment>> mapSegments, MapSegment mapSeg, MapSegmentConnector conn, MapSegment[][] mapSegmentGrid, boolean forMainPath) {
|
private static MapSegment getRandomValidSegment(MapConfig mapCfg, HashMap<String, ArrayList<MapSegment>> mapSegments, MapSegment mapSeg, MapSegmentConnector conn, MapSegment[][] mapSegmentGrid, boolean forMainPath) {
|
||||||
ArrayList<MapSegment> arrSegments = mapSegments.get(conn.getMatchingSideType());
|
ArrayList<MapSegment> arrSegments = mapSegments.get(conn.getMatchingSideType());
|
||||||
/*
|
|
||||||
* POURQUOI ce log : un type de connecteur sans segment correspondant
|
|
||||||
* (dictionnaire vide) renvoie null plus bas — depuis 2017 c'était un
|
|
||||||
* NPE anonyme 10 lignes plus loin, indifférenciable d'un bug de
|
|
||||||
* rendu. Le type fautif est maintenant nommé noir sur blanc.
|
|
||||||
*/
|
|
||||||
if (arrSegments == null || arrSegments.isEmpty()) {
|
|
||||||
GameLog.e("LS-MAP", "AUCUN segment pour connecteurs de type '"
|
|
||||||
+ conn.getMatchingSideType() + "' — sélection renverra null");
|
|
||||||
}
|
|
||||||
ArrayList<MapSegment> validSegments = new ArrayList<>();
|
ArrayList<MapSegment> validSegments = new ArrayList<>();
|
||||||
for(MapSegment seg : arrSegments) {
|
for(MapSegment seg : arrSegments) {
|
||||||
if(forMainPath) {
|
if(forMainPath) {
|
||||||
@ -319,9 +265,6 @@ public class MapManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void loadMapSegment(MapSegment seg) {
|
private static void loadMapSegment(MapSegment seg) {
|
||||||
// Une ligne par segment : en cas de crash/écran noir, on sait
|
|
||||||
// exactement quel TMX de la chaîne procédurale était en cours.
|
|
||||||
GameLog.d("LS-MAP", "loadTMX segment '" + seg.map.getFilePath() + "' à " + seg.pos);
|
|
||||||
loadTMX(seg.map, seg.pos);
|
loadTMX(seg.map, seg.pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,11 +275,7 @@ public class MapManager {
|
|||||||
try {
|
try {
|
||||||
retMapSeg = mapSegGrid[gridX][gridY];
|
retMapSeg = mapSegGrid[gridX][gridY];
|
||||||
} catch(ArrayIndexOutOfBoundsException ex) {
|
} catch(ArrayIndexOutOfBoundsException ex) {
|
||||||
// POURQUOI GameLog.e : l'exception originale avalait l'info dans
|
ex.printStackTrace();
|
||||||
// stderr, invisible dans le tampon GameLog du crash report.
|
|
||||||
GameLog.e("LS-MAP", "getMapSegment hors grille : [" + gridX + "][" + gridY
|
|
||||||
+ "] (pos=" + pos + ", grille=" + mapSegGrid.length + "x"
|
|
||||||
+ (mapSegGrid.length > 0 ? mapSegGrid[0].length : 0) + ")");
|
|
||||||
}
|
}
|
||||||
return retMapSeg;
|
return retMapSeg;
|
||||||
}
|
}
|
||||||
@ -353,6 +292,37 @@ public class MapManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void printMapSegmentGrid(MapSegment[][] mapSegGrid, int mapSegGridW, int mapSegGridH) {
|
||||||
|
int spaces = 3;
|
||||||
|
for(int x = 0; x < mapSegGridW + 1; x++) {
|
||||||
|
String col = x + "";
|
||||||
|
System.out.print("|" + col);
|
||||||
|
for(int i = col.length(); i < spaces; i++) {
|
||||||
|
System.out.print(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
for(int y = 0; y < mapSegGridH; y++) {
|
||||||
|
String row = (y + 1) + "";
|
||||||
|
System.out.print("|" + row);
|
||||||
|
for(int j = row.length(); j < spaces; j++) {
|
||||||
|
System.out.print(" ");
|
||||||
|
}
|
||||||
|
for(int x = 0; x < mapSegGridW; x++) {
|
||||||
|
String str = "";
|
||||||
|
if(mapSegGrid[x][y] != null) {
|
||||||
|
str += " *";
|
||||||
|
}
|
||||||
|
System.out.print("|" + str);
|
||||||
|
for(int i = str.length(); i < spaces; i++) {
|
||||||
|
System.out.print(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void printSolidityMap() {
|
private static void printSolidityMap() {
|
||||||
System.out.print("{");
|
System.out.print("{");
|
||||||
for(int i = 0; i < solidityMap.length; i++) {
|
for(int i = 0; i < solidityMap.length; i++) {
|
||||||
@ -390,11 +360,7 @@ public class MapManager {
|
|||||||
|
|
||||||
private static void loadTMX(Map map, Vector2 offset) {
|
private static void loadTMX(Map map, Vector2 offset) {
|
||||||
if(map == null) {
|
if(map == null) {
|
||||||
// POURQUOI ce log est critique : map == null signifie que
|
System.err.println("MapManager.loadTMX: Map provided is null");
|
||||||
// TMXLoader a échoué SILENCIEUSEMENT (asset absent, XML cassé) —
|
|
||||||
// sans ça, le crash arrive plus loin (NPE loadTMX ligne suivante)
|
|
||||||
// et ne dit rien de la vraie cause.
|
|
||||||
GameLog.e("LS-MAP", "loadTMX : map NULL (TMXLoader a échoué — lire les erreurs LS-MAP précédentes)");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ArrayList<TileSet> tileSets = map.getTileSets();
|
ArrayList<TileSet> tileSets = map.getTileSets();
|
||||||
@ -450,16 +416,6 @@ public class MapManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void instantiateTiles(Tile[] tiles, boolean collision, float tileWidth, float tileHeight, int zindex, Map map, ArrayList<TileSet> tileSets, ArrayList<TextureAtlas> textureAtlases, Vector2 offset) {
|
public static void instantiateTiles(Tile[] tiles, boolean collision, float tileWidth, float tileHeight, int zindex, Map map, ArrayList<TileSet> tileSets, ArrayList<TextureAtlas> textureAtlases, Vector2 offset) {
|
||||||
/*
|
|
||||||
* Compteurs par couche : un gid sans tileset ou un sprite manquant
|
|
||||||
* faisait un `continue` silencieux — en procédural Android, une
|
|
||||||
* texture de tileset non chargée donnait des zones invisibles sans
|
|
||||||
* AUCUN indice. Une ligne de synthèse par couche (pas par tuile :
|
|
||||||
* politiquement interdit, 10k+ tuiles par map).
|
|
||||||
*/
|
|
||||||
int placees = 0;
|
|
||||||
int solides = 0;
|
|
||||||
int gidsOrphelins = 0;
|
|
||||||
for (int i = 0; i < tiles.length; i++) {
|
for (int i = 0; i < tiles.length; i++) {
|
||||||
Tile t = tiles[i];
|
Tile t = tiles[i];
|
||||||
long gid = t.getGid();
|
long gid = t.getGid();
|
||||||
@ -482,16 +438,13 @@ public class MapManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ts == null) {
|
if(ts == null) {
|
||||||
gidsOrphelins++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
TextureAtlas ta = textureAtlases.get(tileSetIdx);
|
TextureAtlas ta = textureAtlases.get(tileSetIdx);
|
||||||
Sprite sprite = ta.getSprite(String.valueOf(gid - ts.getFirstGid()));
|
Sprite sprite = ta.getSprite(String.valueOf(gid - ts.getFirstGid()));
|
||||||
Renderer renderer = new Renderer(ta, sprite, tileWidth, tileHeight);
|
Renderer renderer = new Renderer(ta, sprite, tileWidth, tileHeight);
|
||||||
renderer.setDepth(zindex);
|
renderer.setDepth(zindex);
|
||||||
placees++;
|
|
||||||
if(collision) {
|
if(collision) {
|
||||||
solides++;
|
|
||||||
GameObject tile = GameObject.instantiate(
|
GameObject tile = GameObject.instantiate(
|
||||||
new GameObject("Tile", true, renderer, new Collider(tileWidth, tileHeight)), new Vector2(x, y),
|
new GameObject("Tile", true, renderer, new Collider(tileWidth, tileHeight)), new Vector2(x, y),
|
||||||
new Vector2(t.isFlippedHorizontal() ? -1 : 1, t.isFlippedVertical() ? -1 : 1));
|
new Vector2(t.isFlippedHorizontal() ? -1 : 1, t.isFlippedVertical() ? -1 : 1));
|
||||||
@ -499,32 +452,16 @@ public class MapManager {
|
|||||||
try {
|
try {
|
||||||
solidityMap[(int)(col + offset.x)][(int)(row + offset.y)] = 1;
|
solidityMap[(int)(col + offset.x)][(int)(row + offset.y)] = 1;
|
||||||
} catch(ArrayIndexOutOfBoundsException ex) {
|
} catch(ArrayIndexOutOfBoundsException ex) {
|
||||||
// Tuile SANS collision silencieuse depuis 2017 : un mur
|
System.out.println("Error setting solidityMap at index [" + col + "][" + row + "]");
|
||||||
// percé dans la solidité = IA qui sort de la map. La
|
|
||||||
// position exacte va maintenant dans le journal.
|
|
||||||
GameLog.e("LS-MAP", "solidityMap hors bornes [" + (int)(col + offset.x) + "]["
|
|
||||||
+ (int)(row + offset.y) + "] (taille " + solidityMap.length + "x"
|
|
||||||
+ (solidityMap.length > 0 ? solidityMap[0].length : 0)
|
|
||||||
+ ") — tuile non solide à " + x + "," + y);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GameObject.instantiate(new GameObject("Tile", true, renderer), new Vector2(x, y),
|
GameObject.instantiate(new GameObject("Tile", true, renderer), new Vector2(x, y),
|
||||||
new Vector2(t.isFlippedHorizontal() ? -1 : 1, t.isFlippedVertical() ? -1 : 1));
|
new Vector2(t.isFlippedHorizontal() ? -1 : 1, t.isFlippedVertical() ? -1 : 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GameLog.d("LS-MAP", "tuiles z=" + zindex + " offset=" + offset + " : "
|
|
||||||
+ placees + " instanciées (" + solides + " solides), "
|
|
||||||
+ gidsOrphelins + " gid(s) sans tileset");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void instantiateObjects(TMXObject[] objects, TextureAtlas ta, Vector2 offset) {
|
public static void instantiateObjects(TMXObject[] objects, TextureAtlas ta, Vector2 offset) {
|
||||||
// Synthèse en fin de boucle : combien d'objets reconnus/ignorés — le
|
|
||||||
// "0 spawn" est LE symptôme d'un type inconnu dans le TMX.
|
|
||||||
int spawns = 0;
|
|
||||||
int portes = 0;
|
|
||||||
int casiers = 0;
|
|
||||||
int cryopods = 0;
|
|
||||||
int typesInconnus = 0;
|
|
||||||
for(TMXObject object : objects) {
|
for(TMXObject object : objects) {
|
||||||
Vector2 pos = new Vector2((object.getX() + offset.x * TILE_SIZE) * MAP_SCALE, (object.getY() + offset.y * TILE_SIZE) * MAP_SCALE);
|
Vector2 pos = new Vector2((object.getX() + offset.x * TILE_SIZE) * MAP_SCALE, (object.getY() + offset.y * TILE_SIZE) * MAP_SCALE);
|
||||||
float w = object.getWidth() * MAP_SCALE;
|
float w = object.getWidth() * MAP_SCALE;
|
||||||
@ -533,11 +470,9 @@ public class MapManager {
|
|||||||
boolean flipV = Boolean.parseBoolean(object.getProperty("flipV", "false"));
|
boolean flipV = Boolean.parseBoolean(object.getProperty("flipV", "false"));
|
||||||
switch(object.getType()) {
|
switch(object.getType()) {
|
||||||
case "player_spawn":
|
case "player_spawn":
|
||||||
spawns++;
|
|
||||||
playerSpawn = new Vector2(pos.x, pos.y);
|
playerSpawn = new Vector2(pos.x, pos.y);
|
||||||
break;
|
break;
|
||||||
case "locker":
|
case "locker":
|
||||||
casiers++;
|
|
||||||
if (Network.isHost()) {
|
if (Network.isHost()) {
|
||||||
if ((int) (Math.random() * 2) == 0) {
|
if ((int) (Math.random() * 2) == 0) {
|
||||||
Network.instantiate("locker_locked", pos);
|
Network.instantiate("locker_locked", pos);
|
||||||
@ -547,81 +482,57 @@ public class MapManager {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "locker_locked":
|
case "locker_locked":
|
||||||
casiers++;
|
|
||||||
GameObject.instantiate(PrefabManager.loadPrefab("locker_locked"), pos);
|
GameObject.instantiate(PrefabManager.loadPrefab("locker_locked"), pos);
|
||||||
break;
|
break;
|
||||||
case "locker_unlocked":
|
case "locker_unlocked":
|
||||||
casiers++;
|
|
||||||
if (Network.isHost()) Network.instantiate("locker_unlocked", pos);
|
if (Network.isHost()) Network.instantiate("locker_unlocked", pos);
|
||||||
break;
|
break;
|
||||||
case "door":
|
case "door":
|
||||||
portes++;
|
|
||||||
GameObject.instantiate(PrefabManager.loadPrefab("door"), pos);
|
GameObject.instantiate(PrefabManager.loadPrefab("door"), pos);
|
||||||
break;
|
break;
|
||||||
case "ldoor":
|
case "ldoor":
|
||||||
portes++;
|
|
||||||
GameObject.instantiate(PrefabManager.loadPrefab("laser_door"), pos);
|
GameObject.instantiate(PrefabManager.loadPrefab("laser_door"), pos);
|
||||||
break;
|
break;
|
||||||
case "cryopod":
|
case "cryopod":
|
||||||
cryopods++;
|
|
||||||
GameObject.instantiate(
|
GameObject.instantiate(
|
||||||
new GameObject("Cryopod", "cryopod", new Renderer(), new Collider(300, 100), new Cryopod()),
|
new GameObject("Cryopod", "cryopod", new Renderer(), new Collider(300, 100), new Cryopod()),
|
||||||
pos);
|
pos);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
typesInconnus++;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For doors
|
// For doors
|
||||||
if(object.getType().contains("door")) {
|
if(object.getType().contains("door")) {
|
||||||
try {
|
solidityMap[((int) (pos.x / 100))][((int) (pos.y / 100))] = 1;
|
||||||
solidityMap[((int) (pos.x / 100))][((int) (pos.y / 100))] = 1;
|
solidityMap[((int) (pos.x / 100)) + 1][((int) (pos.y / 100))] = 1;
|
||||||
solidityMap[((int) (pos.x / 100)) + 1][((int) (pos.y / 100))] = 1;
|
solidityMap[((int) (pos.x / 100))][((int) (pos.y / 100)) + 4] = 1;
|
||||||
solidityMap[((int) (pos.x / 100))][((int) (pos.y / 100)) + 4] = 1;
|
solidityMap[((int) (pos.x / 100)) + 1][((int) (pos.y / 100)) + 4] = 1;
|
||||||
solidityMap[((int) (pos.x / 100)) + 1][((int) (pos.y / 100)) + 4] = 1;
|
|
||||||
} catch (ArrayIndexOutOfBoundsException ex) {
|
|
||||||
// POURQUOI : en procédural les offsets de segments peuvent
|
|
||||||
// dépasser la grille de solidité — une porte hors bornes
|
|
||||||
// crashait tout le chargement au lieu de dégrader.
|
|
||||||
GameLog.e("LS-MAP", "solidité de porte hors bornes : type=" + object.getType()
|
|
||||||
+ " pos=" + pos + " (grille " + solidityMap.length + "x"
|
|
||||||
+ (solidityMap.length > 0 ? solidityMap[0].length : 0) + ")");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GameLog.d("LS-MAP", "objets offset=" + offset + " : " + spawns + " spawn(s) joueur, "
|
|
||||||
+ portes + " porte(s), " + casiers + " casier(s), " + cryopods + " cryopod(s), "
|
|
||||||
+ typesInconnus + " type(s) inconnu(s)"
|
|
||||||
+ (spawns == 0 ? " — ATTENTION : aucun player_spawn !" : ""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void instantiateEnemies(TMXObject[] objects, Vector2 offset) {
|
public static void instantiateEnemies(TMXObject[] objects, Vector2 offset) {
|
||||||
GameLog.i("LS-MAP", "instantiateEnemies : " + objects.length + " objet(s) dans l'objectgroup");
|
GameLog.i("LS-MAP", "instantiateEnemies : " + objects.length + " objet(s) dans l'objectgroup");
|
||||||
int spawns = 0;
|
|
||||||
int ennemisDedies = 0;
|
|
||||||
for(TMXObject object : objects) {
|
for(TMXObject object : objects) {
|
||||||
Vector2 pos = new Vector2((object.getX() + offset.x * TILE_SIZE) * MAP_SCALE, (object.getY() + offset.y * TILE_SIZE) * MAP_SCALE);
|
Vector2 pos = new Vector2((object.getX() + offset.x * TILE_SIZE) * MAP_SCALE, (object.getY() + offset.y * TILE_SIZE) * MAP_SCALE);
|
||||||
switch(object.getType()) {
|
switch(object.getType()) {
|
||||||
case "spawn":
|
case "spawn":
|
||||||
spawns++;
|
|
||||||
enemySpawns.add(pos);
|
enemySpawns.add(pos);
|
||||||
GameObject.instantiate(PrefabManager.loadPrefab("spawn_point"), pos);
|
GameObject.instantiate(PrefabManager.loadPrefab("spawn_point"), pos);
|
||||||
break;
|
break;
|
||||||
case "prova_crewman":
|
case "prova_crewman":
|
||||||
|
if (Network.isHost()) Network.instantiate("prova_crewman", pos);
|
||||||
|
break;
|
||||||
case "dera_crewman":
|
case "dera_crewman":
|
||||||
|
if (Network.isHost()) Network.instantiate("dera_crewman", pos);
|
||||||
|
break;
|
||||||
case "supra_crewman":
|
case "supra_crewman":
|
||||||
ennemisDedies++;
|
if (Network.isHost()) Network.instantiate("supra_crewman", pos);
|
||||||
if (Network.isHost()) Network.instantiate(object.getType(), pos);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// POURQUOI : "0 spawn" + "0 ennemi dédié" = le symptomatique du
|
|
||||||
// dédoublement de nom d'objectgroup (enemies vs spawns, cf. loadTMX)
|
|
||||||
// — diagnostic immédiat au lieu d'une mission vide.
|
|
||||||
GameLog.i("LS-MAP", "instantiateEnemies : " + spawns + " point(s) de spawn, "
|
|
||||||
+ ennemisDedies + " ennemi(s) placé(s) dans le TMX");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package com.ezardlabs.lostsector.map.procedural;
|
|||||||
|
|
||||||
import com.ezardlabs.dethsquare.tmx.Map;
|
import com.ezardlabs.dethsquare.tmx.Map;
|
||||||
import com.ezardlabs.dethsquare.tmx.TMXLoader;
|
import com.ezardlabs.dethsquare.tmx.TMXLoader;
|
||||||
import com.ezardlabs.dethsquare.util.GameLog;
|
|
||||||
import com.ezardlabs.lostsector.map.MapManager;
|
import com.ezardlabs.lostsector.map.MapManager;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -71,20 +70,12 @@ public class MapConfig {
|
|||||||
loadSegments(this.extractSegments, this.strExtractDir);
|
loadSegments(this.extractSegments, this.strExtractDir);
|
||||||
loadSegments(this.lockSegments, this.strLockDir);
|
loadSegments(this.lockSegments, this.strLockDir);
|
||||||
|
|
||||||
/*
|
|
||||||
* Listing en UN message debug (au lieu de 2 println par entrée) :
|
|
||||||
* l'inventaire des segments disponibles est la première chose à
|
|
||||||
* comparer quand une génération procédurale échoue côté Android
|
|
||||||
* (assets absents => dictionnaires vides => NPE plus loin).
|
|
||||||
*/
|
|
||||||
StringBuilder inventaire = new StringBuilder("segments chargés :\n");
|
|
||||||
for(String key : this.mainSegments.keySet()) {
|
for(String key : this.mainSegments.keySet()) {
|
||||||
inventaire.append(" ").append(key).append(" :\n");
|
System.out.println(key);
|
||||||
for(MapSegment seg : this.mainSegments.get(key)) {
|
for(MapSegment seg : this.mainSegments.get(key)) {
|
||||||
inventaire.append(" ").append(seg.map.getFilePath()).append('\n');
|
System.out.println("\t" + seg.map.getFilePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GameLog.d("LS-MAP", inventaire.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeString() {
|
public String getTypeString() {
|
||||||
@ -97,37 +88,21 @@ public class MapConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadSegments(HashMap<String, ArrayList<MapSegment>> segments, String dirPath) {
|
private void loadSegments(HashMap<String, ArrayList<MapSegment>> segments, String dirPath) {
|
||||||
// Une ligne par catégorie de segments : si listFileNames renvoie vide
|
System.out.println("Loading TMX MapSegments: " + dirPath);
|
||||||
// (index files.lsd absent des assets Android), le diagnostic est
|
|
||||||
// immédiat — sinon on le découvre via un NPE dans la génération.
|
|
||||||
String[] strFileNames = IO.listFileNames(dirPath);
|
|
||||||
GameLog.i("LS-MAP", "chargement segments '" + dirPath + "' : " + strFileNames.length + " fichier(s) indexé(s)");
|
|
||||||
TMXLoader tmxLoader;
|
TMXLoader tmxLoader;
|
||||||
int valides = 0;
|
String[] strFileNames = IO.listFileNames(dirPath);
|
||||||
for(int i = 0; i < strFileNames.length; i++) {
|
for(int i = 0; i < strFileNames.length; i++) {
|
||||||
if(strFileNames[i] == null || !strFileNames[i].endsWith(".tmx")) {
|
if(strFileNames[i] == null || !strFileNames[i].endsWith(".tmx")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
tmxLoader = new TMXLoader(dirPath + "/" + strFileNames[i], false);
|
tmxLoader = new TMXLoader(dirPath + "/" + strFileNames[i], false);
|
||||||
Map newMap = tmxLoader.getMap();
|
Map newMap = tmxLoader.getMap();
|
||||||
if(newMap == null) {
|
|
||||||
// POURQUOI : TMXLoader avale ses exceptions en log seulement —
|
|
||||||
// un TMX cassé/absent faisait un NPE ici (getWidth sur null).
|
|
||||||
GameLog.e("LS-MAP", "segment '" + dirPath + "/" + strFileNames[i]
|
|
||||||
+ "' : chargement TMX échoué (asset absent ou XML invalide) — segment ignoré");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(newMap.getWidth() % MapManager.MAP_SEGMENT_SIZE != 0 || newMap.getHeight() % MapManager.MAP_SEGMENT_SIZE != 0) {
|
if(newMap.getWidth() % MapManager.MAP_SEGMENT_SIZE != 0 || newMap.getHeight() % MapManager.MAP_SEGMENT_SIZE != 0) {
|
||||||
GameLog.e("LS-MAP", "dimensions de '" + newMap.getFilePath()
|
System.err.println("The dimensions of '" + newMap.getFilePath() + "' are not a multiple of " + MapManager.MAP_SEGMENT_SIZE + ".");
|
||||||
+ "' (" + newMap.getWidth() + "x" + newMap.getHeight()
|
|
||||||
+ ") non multiple de " + MapManager.MAP_SEGMENT_SIZE + " — segment ignoré");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
addSegment(segments, new MapSegment(newMap), segments == this.lockSegments);
|
addSegment(segments, new MapSegment(newMap), segments == this.lockSegments);
|
||||||
valides++;
|
|
||||||
}
|
}
|
||||||
GameLog.i("LS-MAP", "segments '" + dirPath + "' : " + valides + " valide(s) sur "
|
|
||||||
+ strFileNames.length + " fichier(s)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSegment(HashMap<String, ArrayList<MapSegment>> segments, MapSegment seg, boolean isLockSegment) {
|
private void addSegment(HashMap<String, ArrayList<MapSegment>> segments, MapSegment seg, boolean isLockSegment) {
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import com.ezardlabs.dethsquare.Vector2;
|
|||||||
import com.ezardlabs.dethsquare.tmx.Map;
|
import com.ezardlabs.dethsquare.tmx.Map;
|
||||||
import com.ezardlabs.dethsquare.tmx.ObjectGroup;
|
import com.ezardlabs.dethsquare.tmx.ObjectGroup;
|
||||||
import com.ezardlabs.dethsquare.tmx.TMXObject;
|
import com.ezardlabs.dethsquare.tmx.TMXObject;
|
||||||
import com.ezardlabs.dethsquare.util.GameLog;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -38,11 +37,7 @@ public class MapSegment {
|
|||||||
this.connectors.add(conn);
|
this.connectors.add(conn);
|
||||||
}
|
}
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
// POURQUOI GameLog : sans connecteurs, le segment est inutilisable
|
ex.printStackTrace();
|
||||||
// par la génération procédurale — l'info doit remonter dans le
|
|
||||||
// tampon GameLog (crash report Android), pas rester dans stderr.
|
|
||||||
GameLog.e("LS-MAP", "segment '" + this.map.getFilePath()
|
|
||||||
+ "' : connecteurs introuvables — segment ignoré par la génération", ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -123,45 +123,26 @@ public class ExterminateMission extends Mission implements EnemyStatusListener {
|
|||||||
if (alive >= 3) return;
|
if (alive >= 3) return;
|
||||||
|
|
||||||
String prefab = pickSpecies();
|
String prefab = pickSpecies();
|
||||||
|
float side = Math.random() < 0.5 ? -1f : 1f;
|
||||||
|
// Clamp x >= 200 : un spawn hors carte (x < 0) place l'ennemi
|
||||||
|
// dans le vide à gauche du monde (récupérable grâce au clamp
|
||||||
|
// du NavMesh, mais inutilement pénalisant).
|
||||||
|
float spawnX = Math.max(200f, p.x + side * (600 + (float) Math.random() * 600));
|
||||||
/*
|
/*
|
||||||
* Spawn sur le sol DU JOUEUR (retour v0.11.0 : "ennemis spawn
|
* Spawn SUR LE SOL (feedback v0.10.0 : "les ennemis spawn dans
|
||||||
* en dehors de la map" + "bloqués") : le raycast vertical
|
* les murs") : raycast vertical depuis au-dessus de la carte —
|
||||||
* (feedback v0.10.0) trouve le sol de la colonne, MAIS une
|
* le premier sol touché dans la colonne donne la position de
|
||||||
* colonne hors carte (x > bord droit, pas de clamp) ou un
|
* spawn (100 px au-dessus du centre de la tuile solide). Sans
|
||||||
* autre étage plaçait l'ennemi hors NavMesh -> aucun chemin
|
* sol dans la colonne : chute libre (clamp NavMesh).
|
||||||
* -> ennemi planté à vie ("aucun chemin NavMesh vers
|
|
||||||
* Player" en boucle dans les logs). Fix : 1) raycast au
|
|
||||||
* x du JOUEUR pour connaître son étage (sol de référence) ;
|
|
||||||
* 2) jusqu'à 6 tentatives de colonnes alternées droite/
|
|
||||||
* gauche : le sol de la colonne doit exister ET être à
|
|
||||||
* moins de 300 px du sol du joueur (même étage — donc
|
|
||||||
* couvert par le NavMesh que le joueur piétine). Aucune
|
|
||||||
* colonne correcte : fallback aérien (dernier recours).
|
|
||||||
*/
|
*/
|
||||||
int solidLayer = com.ezardlabs.dethsquare.Layers.getLayerMask("Solid");
|
float spawnY = p.y - 150 - (float) Math.random() * 100;
|
||||||
// getLayerMask (BITMASK 1 << layer) et PAS getLayer (INDEX) :
|
int solidLayer = com.ezardlabs.dethsquare.Layers.getLayer("Solid");
|
||||||
// Physics.raycast compare (mask du collider & layerMask) ==
|
com.ezardlabs.dethsquare.Physics.RaycastHit ground = Physics.raycast(new Vector2(spawnX, p.y - 5000f),
|
||||||
// mask — avec l'index 11 la condition était toujours fausse
|
new Vector2(0, 1), 30000f, solidLayer);
|
||||||
// et le raycast ne trouvait JAMAIS le sol (fallback aérien =
|
if (ground != null) {
|
||||||
// le bug "spawn dans les murs" silencieusement no-op, QA
|
spawnY = ground.transform.position.y - 100f;
|
||||||
// v0.11.0 P1). Convention du codebase : LankaBeam / Behaviour.
|
|
||||||
Physics.RaycastHit playerFloor = Physics.raycast(
|
|
||||||
new Vector2(p.x, p.y - 5000f), new Vector2(0, 1), 30000f, solidLayer);
|
|
||||||
Vector2 pos = new Vector2(p.x, p.y - 150 - (float) Math.random() * 100);
|
|
||||||
for (int attempt = 0; attempt < 6; attempt++) {
|
|
||||||
// Alternance droite/gauche : si un côté est hors carte
|
|
||||||
// (pas de sol), l'autre côté reste tentable.
|
|
||||||
float side = attempt % 2 == 0 ? 1f : -1f;
|
|
||||||
float spawnX = p.x + side * (600 + (float) Math.random() * 600);
|
|
||||||
if (spawnX < 200f) continue;
|
|
||||||
Physics.RaycastHit ground = Physics.raycast(
|
|
||||||
new Vector2(spawnX, p.y - 5000f), new Vector2(0, 1), 30000f, solidLayer);
|
|
||||||
if (ground != null && playerFloor != null
|
|
||||||
&& Math.abs(ground.transform.position.y - playerFloor.transform.position.y) <= 300f) {
|
|
||||||
pos = new Vector2(spawnX, ground.transform.position.y - 100f);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Vector2 pos = new Vector2(spawnX, spawnY);
|
||||||
GameObject.instantiate(PrefabManager.loadPrefab(prefab), pos);
|
GameObject.instantiate(PrefabManager.loadPrefab(prefab), pos);
|
||||||
spawned++;
|
spawned++;
|
||||||
nextSpawn = System.currentTimeMillis() + 2000 + (long) (Math.random() * 4000);
|
nextSpawn = System.currentTimeMillis() + 2000 + (long) (Math.random() * 4000);
|
||||||
|
|||||||
@ -38,7 +38,7 @@ public class DeraCrewman extends Crewman {
|
|||||||
fired = false;
|
fired = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).setMoveSpeed(10).setVisionRange(2000).create());
|
}).setMoveSpeed(10).setVisionRange(2000).setWillPatrol(false).create());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -11,6 +11,7 @@ public class ProvaCrewman extends Crewman {
|
|||||||
.setDamageFrame(2)
|
.setDamageFrame(2)
|
||||||
.setMoveSpeed(10)
|
.setMoveSpeed(10)
|
||||||
.setVisionRange(2000)
|
.setVisionRange(2000)
|
||||||
|
.setWillPatrol(false)
|
||||||
.create());
|
.create());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@ public class SupraCrewman extends Crewman {
|
|||||||
fired = false;
|
fired = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).setMoveSpeed(10).setVisionRange(2000).create());
|
}).setMoveSpeed(10).setVisionRange(2000).setWillPatrol(false).create());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -26,6 +26,7 @@ public class ShockwaveMoa extends Moa {
|
|||||||
.setDamageFrame(7)
|
.setDamageFrame(7)
|
||||||
.setMoveSpeed(10)
|
.setMoveSpeed(10)
|
||||||
.setVisionRange(2000)
|
.setVisionRange(2000)
|
||||||
|
.setWillPatrol(false)
|
||||||
.create());
|
.create());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import com.ezardlabs.dethsquare.Input.KeyCode;
|
|||||||
import com.ezardlabs.dethsquare.Script;
|
import com.ezardlabs.dethsquare.Script;
|
||||||
import com.ezardlabs.dethsquare.Screen;
|
import com.ezardlabs.dethsquare.Screen;
|
||||||
import com.ezardlabs.dethsquare.TextureAtlas;
|
import com.ezardlabs.dethsquare.TextureAtlas;
|
||||||
import com.ezardlabs.dethsquare.Time;
|
|
||||||
import com.ezardlabs.dethsquare.Touch;
|
import com.ezardlabs.dethsquare.Touch;
|
||||||
import com.ezardlabs.dethsquare.util.Dethsquare;
|
import com.ezardlabs.dethsquare.util.Dethsquare;
|
||||||
import com.ezardlabs.dethsquare.util.Dethsquare.Platform;
|
import com.ezardlabs.dethsquare.util.Dethsquare.Platform;
|
||||||
@ -69,17 +68,6 @@ public class TouchControls extends Script {
|
|||||||
|
|
||||||
private boolean mouseDown = false;
|
private boolean mouseDown = false;
|
||||||
|
|
||||||
/*
|
|
||||||
* Diagnostic qa v0.11.0 (menu principal inerte) : prouve sur logcat que
|
|
||||||
* update() tourne ET voit les touches brutes du launcher. Log sur
|
|
||||||
* CHANGEMENT du compte uniquement (politique logs du dépôt : jamais par
|
|
||||||
* frame brute). Lecture attendue au prochain test émulateur : un tap ->
|
|
||||||
* "touches visibles=1" puis la synthèse ("touch action -> MOUSE_LEFT
|
|
||||||
* down"). Si le tap est logué par AndroidLauncher mais que cette ligne
|
|
||||||
* n'apparaît jamais, update() ne tourne pas ou ne voit toujours rien.
|
|
||||||
*/
|
|
||||||
private int lastSeenTouchCount = -1;
|
|
||||||
|
|
||||||
private enum HSide {
|
private enum HSide {
|
||||||
LEFT, CENTRE, RIGHT
|
LEFT, CENTRE, RIGHT
|
||||||
}
|
}
|
||||||
@ -225,11 +213,6 @@ public class TouchControls extends Script {
|
|||||||
releaseAllButtons();
|
releaseAllButtons();
|
||||||
}
|
}
|
||||||
layout();
|
layout();
|
||||||
int touchCount = Input.touches.length;
|
|
||||||
if (touchCount != lastSeenTouchCount) {
|
|
||||||
GameLog.d(TAG, "touches visibles=" + touchCount);
|
|
||||||
lastSeenTouchCount = touchCount;
|
|
||||||
}
|
|
||||||
for (Button b : buttons) {
|
for (Button b : buttons) {
|
||||||
if (b.objects != null) {
|
if (b.objects != null) {
|
||||||
for (GameObject o : b.objects) {
|
for (GameObject o : b.objects) {
|
||||||
@ -246,21 +229,9 @@ public class TouchControls extends Script {
|
|||||||
boolean hasActionTouch = false;
|
boolean hasActionTouch = false;
|
||||||
Vector2 actionTouchPosition = null;
|
Vector2 actionTouchPosition = null;
|
||||||
for (Touch touch : Input.touches) {
|
for (Touch touch : Input.touches) {
|
||||||
if (touch.phase == Touch.TouchPhase.CANCELLED) {
|
if (touch.phase == Touch.TouchPhase.ENDED || touch.phase == Touch.TouchPhase.CANCELLED) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (touch.phase == Touch.TouchPhase.ENDED && touch.lastModified < Time.frameCount) {
|
|
||||||
/*
|
|
||||||
* ENDED depuis une frame antérieure : déjà consommé, on
|
|
||||||
* ignore. MAIS une touche ENDED CETTE FRAME doit compter :
|
|
||||||
* avec le marshaling queueEvent, un tap court produit
|
|
||||||
* down+up DANS LA MÊME frame — le toucher naît et meurt
|
|
||||||
* avant qu'aucune frame ne le voie "actif" (symptôme :
|
|
||||||
* "touches visibles=1" puis =0, jamais de synthèse clic).
|
|
||||||
* Il est traité comme un clic (hit-test + action) une
|
|
||||||
* dernière fois, position = dernier point connu.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
if (buttonsActive) {
|
if (buttonsActive) {
|
||||||
Button hit = null;
|
Button hit = null;
|
||||||
for (Button b : buttons) {
|
for (Button b : buttons) {
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import com.ezardlabs.dethsquare.Input.KeyCode;
|
|||||||
import com.ezardlabs.dethsquare.LevelManager;
|
import com.ezardlabs.dethsquare.LevelManager;
|
||||||
import com.ezardlabs.dethsquare.Screen;
|
import com.ezardlabs.dethsquare.Screen;
|
||||||
import com.ezardlabs.dethsquare.Vector2;
|
import com.ezardlabs.dethsquare.Vector2;
|
||||||
import com.ezardlabs.lostsector.objects.hud.TouchControls;
|
|
||||||
|
|
||||||
public class EscMenu extends Menu {
|
public class EscMenu extends Menu {
|
||||||
private GameObject settingsMenu;
|
private GameObject settingsMenu;
|
||||||
@ -19,14 +18,7 @@ public class EscMenu extends Menu {
|
|||||||
menu.gameObject.setActive(false);
|
menu.gameObject.setActive(false);
|
||||||
open();
|
open();
|
||||||
})),
|
})),
|
||||||
/*
|
new Vector2(Screen.width / 2 - 600, Screen.height / 2 - 500));
|
||||||
* Position en référentiel GUI comme MainMenu (960-600,
|
|
||||||
* 540-500) — l'original utilisait Screen.width/2-600 en
|
|
||||||
* PIXELS BRUTS : le panneau du pause était décentré dès que
|
|
||||||
* scale != 1 (QA v0.12.0 P2 : panneau décalé à droite sur
|
|
||||||
* Android 2400px vs desktop 1920).
|
|
||||||
*/
|
|
||||||
new Vector2(960 - 600, 540 - 500));
|
|
||||||
settingsMenu.setActive(false);
|
settingsMenu.setActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,10 +56,6 @@ public class EscMenu extends Menu {
|
|||||||
(menu, index, text) -> menu.close(),
|
(menu, index, text) -> menu.close(),
|
||||||
(menu, index, text) -> {
|
(menu, index, text) -> {
|
||||||
close();
|
close();
|
||||||
// close() révèle le HUD tactile : le masquer pendant le
|
|
||||||
// panneau Settings (sinon les boutons virtuels chevauchent
|
|
||||||
// le panneau, cf. MainMenu.onMenuItemSelected "Settings").
|
|
||||||
TouchControls.setButtonsVisible(false);
|
|
||||||
settingsMenu.setActive(true);
|
settingsMenu.setActive(true);
|
||||||
},
|
},
|
||||||
(menu, index, text) -> LevelManager.loadLevel("main_menu")
|
(menu, index, text) -> LevelManager.loadLevel("main_menu")
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import com.ezardlabs.dethsquare.Input.KeyCode;
|
|||||||
import com.ezardlabs.dethsquare.LevelManager;
|
import com.ezardlabs.dethsquare.LevelManager;
|
||||||
import com.ezardlabs.dethsquare.Screen;
|
import com.ezardlabs.dethsquare.Screen;
|
||||||
import com.ezardlabs.dethsquare.Vector2;
|
import com.ezardlabs.dethsquare.Vector2;
|
||||||
import com.ezardlabs.lostsector.objects.hud.TouchControls;
|
|
||||||
|
|
||||||
public class MainMenu extends Menu {
|
public class MainMenu extends Menu {
|
||||||
private GameObject settingsMenu;
|
private GameObject settingsMenu;
|
||||||
@ -59,15 +58,6 @@ public class MainMenu extends Menu {
|
|||||||
@Override
|
@Override
|
||||||
public void onMenuItemSelected(Menu menu, int index, String text) {
|
public void onMenuItemSelected(Menu menu, int index, String text) {
|
||||||
close();
|
close();
|
||||||
/*
|
|
||||||
* close() révèle le HUD tactile (comportement "pause en
|
|
||||||
* jeu") : dans le MENU PRINCIPAL ça réaffichait les
|
|
||||||
* boutons virtuels par-dessus le panneau Settings
|
|
||||||
* (depth 900/910 > 12). On les re-masque le temps du
|
|
||||||
* panneau ; le retour au menu (backAction) repasse par
|
|
||||||
* open() qui les masque à nouveau.
|
|
||||||
*/
|
|
||||||
TouchControls.setButtonsVisible(false);
|
|
||||||
settingsMenu.setActive(true);
|
settingsMenu.setActive(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import com.ezardlabs.dethsquare.GuiRenderer;
|
|||||||
import com.ezardlabs.dethsquare.GuiText;
|
import com.ezardlabs.dethsquare.GuiText;
|
||||||
import com.ezardlabs.dethsquare.Input;
|
import com.ezardlabs.dethsquare.Input;
|
||||||
import com.ezardlabs.dethsquare.Input.KeyCode;
|
import com.ezardlabs.dethsquare.Input.KeyCode;
|
||||||
import com.ezardlabs.dethsquare.RectF;
|
|
||||||
import com.ezardlabs.dethsquare.Screen;
|
import com.ezardlabs.dethsquare.Screen;
|
||||||
import com.ezardlabs.dethsquare.Script;
|
import com.ezardlabs.dethsquare.Script;
|
||||||
import com.ezardlabs.dethsquare.TextureAtlas;
|
import com.ezardlabs.dethsquare.TextureAtlas;
|
||||||
@ -13,8 +12,6 @@ import com.ezardlabs.dethsquare.Time;
|
|||||||
import com.ezardlabs.dethsquare.Vector2;
|
import com.ezardlabs.dethsquare.Vector2;
|
||||||
import com.ezardlabs.lostsector.objects.hud.TouchControls;
|
import com.ezardlabs.lostsector.objects.hud.TouchControls;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class Menu extends Script {
|
public class Menu extends Script {
|
||||||
private final String[] options;
|
private final String[] options;
|
||||||
private final MenuAction[] actions;
|
private final MenuAction[] actions;
|
||||||
@ -24,17 +21,6 @@ public class Menu extends Script {
|
|||||||
private GameObject[] texts;
|
private GameObject[] texts;
|
||||||
private GuiText[] guiTexts;
|
private GuiText[] guiTexts;
|
||||||
private GameObject[] highlights;
|
private GameObject[] highlights;
|
||||||
/*
|
|
||||||
* Zone de clic de CHAQUE option = la barre ENTIÈRE (pièce 816x156·s),
|
|
||||||
* pas le seul texte (retour v0.11.0 Android : dans le menu pause,
|
|
||||||
* "Settings" est un texte court — un tap au centre de la barre visuelle
|
|
||||||
* ne hit-testait que les bounds du texte et l'option ne réagissait pas ;
|
|
||||||
* le menu principal ne marchait que par chance, ses textes étant plus
|
|
||||||
* longs). Coordonnées référentielles 1920x1080, scalées par
|
|
||||||
* referenceScreenScale au hit-test (même convention que GuiText
|
|
||||||
* .getBounds).
|
|
||||||
*/
|
|
||||||
private final ArrayList<RectF> optionRects = new ArrayList<>();
|
|
||||||
|
|
||||||
private boolean startOpen = false;
|
private boolean startOpen = false;
|
||||||
private boolean open = false;
|
private boolean open = false;
|
||||||
@ -140,13 +126,6 @@ public class Menu extends Script {
|
|||||||
(i == texts.length - 1 ? 66 : 636) * s, (i == texts.length - 1 ? 54 : 25) * s));
|
(i == texts.length - 1 ? 66 : 636) * s, (i == texts.length - 1 ? 54 : 25) * s));
|
||||||
texts[i].transform.position.set(
|
texts[i].transform.position.set(
|
||||||
pieces[i].transform.position.offset(150 * s, (40 + (i == texts.length - 1 ? 28 : 0)) * s));
|
pieces[i].transform.position.offset(150 * s, (40 + (i == texts.length - 1 ? 28 : 0)) * s));
|
||||||
// Barre entière cliquable (cf. commentaire du champ optionRects) ;
|
|
||||||
// la dernière pièce est plus basse (144·s au lieu de 156·s).
|
|
||||||
optionRects.add(new RectF(
|
|
||||||
pieces[i].transform.position.x,
|
|
||||||
pieces[i].transform.position.y,
|
|
||||||
pieces[i].transform.position.x + pieceWidth,
|
|
||||||
pieces[i].transform.position.y + (i == options.length - 1 ? 144f : 156f) * s));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startOpen) {
|
if (startOpen) {
|
||||||
@ -176,10 +155,7 @@ public class Menu extends Script {
|
|||||||
public void update() {
|
public void update() {
|
||||||
if (open && guiTexts != null) {
|
if (open && guiTexts != null) {
|
||||||
for (int i = 0; i < guiTexts.length; i++) {
|
for (int i = 0; i < guiTexts.length; i++) {
|
||||||
// Barre entière cliquable (hitOption), highlight au survol sur
|
if (guiTexts[i].hitTest(Input.mousePosition)) {
|
||||||
// la même zone — un tap au centre de la barre DOIT sélecter
|
|
||||||
// l'option (retour v0.11.0 Android, cf. optionRects).
|
|
||||||
if (hitOption(i, Input.mousePosition)) {
|
|
||||||
highlights[i].setActive(true);
|
highlights[i].setActive(true);
|
||||||
if (Input.getKeyDown(KeyCode.MOUSE_LEFT)) {
|
if (Input.getKeyDown(KeyCode.MOUSE_LEFT)) {
|
||||||
actions[i].onMenuItemSelected(this, i, options[i]);
|
actions[i].onMenuItemSelected(this, i, options[i]);
|
||||||
@ -191,25 +167,6 @@ public class Menu extends Script {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Hit-test d'une option sur sa barre ENTIÈRE : rect référentiel scalé en
|
|
||||||
* espace écran (même convention que GuiText.getBounds), avec repli sur
|
|
||||||
* les bounds du texte si le rect n'existe pas encore (menu construit par
|
|
||||||
* une sous-classe sans passer par start() — défensif).
|
|
||||||
*/
|
|
||||||
private boolean hitOption(int i, Vector2 position) {
|
|
||||||
if (i < optionRects.size()) {
|
|
||||||
RectF r = optionRects.get(i);
|
|
||||||
// Screen.scale == GuiRenderer.referenceScreenScale (tous deux
|
|
||||||
// Screen.width/1920 en ScaleMode.WIDTH) — mais seul Screen.scale
|
|
||||||
// est public.
|
|
||||||
float sc = Screen.scale;
|
|
||||||
return position.x >= r.left * sc && position.x <= r.right * sc
|
|
||||||
&& position.y >= r.top * sc && position.y <= r.bottom * sc;
|
|
||||||
}
|
|
||||||
return guiTexts[i].hitTest(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void open() {
|
public void open() {
|
||||||
open = true;
|
open = true;
|
||||||
// Masquer le HUD tactile : les boutons chevauchaient le menu (et un
|
// Masquer le HUD tactile : les boutons chevauchaient le menu (et un
|
||||||
|
|||||||
@ -17,8 +17,7 @@ public class SettingsMenu extends Script {
|
|||||||
private static final String AUDIO_SFX_VOLUME = "audio_sfx_volume";
|
private static final String AUDIO_SFX_VOLUME = "audio_sfx_volume";
|
||||||
private final TextureAtlas font = TextureAtlas.load("fonts");
|
private final TextureAtlas font = TextureAtlas.load("fonts");
|
||||||
private final BackButtonAction backButtonAction;
|
private final BackButtonAction backButtonAction;
|
||||||
// Depth 12 : au-dessus du fond du panneau (depth 10), cf. start().
|
private final GuiText menuText = new GuiText("MENU", font, 31.25f);
|
||||||
private final GuiText menuText = new GuiText("MENU", font, 31.25f, 12);
|
|
||||||
|
|
||||||
SettingsMenu(BackButtonAction backButtonAction) {
|
SettingsMenu(BackButtonAction backButtonAction) {
|
||||||
this.backButtonAction = backButtonAction;
|
this.backButtonAction = backButtonAction;
|
||||||
@ -28,45 +27,36 @@ public class SettingsMenu extends Script {
|
|||||||
public void start() {
|
public void start() {
|
||||||
runWhenPaused = true;
|
runWhenPaused = true;
|
||||||
/*
|
/*
|
||||||
* Depths explicites (fond=10, contenu=12, logo=5 côté MainMenuLevel) :
|
* Depth 10 explicite : à depth ÉGAL le tri GUI se fait sur l'ID de
|
||||||
* le tri GUI est layer << 61 | depth << 24 | textureName. ATTENTION :
|
* texture (instable après destroyAll) — le logo (depth 5) passait
|
||||||
* le "walk" v0.9.0 via gameObject.getComponentsOfType(GuiRenderer
|
* DEVANT ce panneau quand on entrait dans les Settings (feedback
|
||||||
* .class) ne marchait PAS — cette méthode ne retourne que les
|
* v0.9.0). Le contenu du panneau est poussé à 12 par le walk ci-dessous.
|
||||||
* composants du SEUL GameObject (GameObject.java:297-303), pas la
|
|
||||||
* hiérarchie : le contenu restait à depth 0, CACHÉ sous le fond opaque
|
|
||||||
* (depth 10) — "les settings ne s'affichent plus" (retour v0.11.0).
|
|
||||||
* Désormais chaque élément de contenu porte son depth 12 À LA CRÉATION
|
|
||||||
* (le contenu instancié plus tard — caractères GuiText, sliders,
|
|
||||||
* cercles de tab — serait raté par un walk de toute façon).
|
|
||||||
*/
|
*/
|
||||||
GuiRenderer backgroundRenderer = new GuiRenderer("images/menus/settings/base.png", 1200, 1000);
|
GuiRenderer backgroundRenderer = new GuiRenderer("images/menus/settings/base.png", 1200, 1000);
|
||||||
backgroundRenderer.setDepth(10);
|
backgroundRenderer.setDepth(10);
|
||||||
GameObject.instantiate(new GameObject("Settings Background", backgroundRenderer),
|
GameObject.instantiate(new GameObject("Settings Background", backgroundRenderer),
|
||||||
transform.position).transform.setParent(transform);
|
transform.position).transform.setParent(transform);
|
||||||
|
|
||||||
GuiRenderer menuButtonRenderer = new GuiRenderer("images/menus/settings/menu.png", 575, 118.75f);
|
|
||||||
menuButtonRenderer.setDepth(12);
|
|
||||||
GameObject.instantiate(
|
GameObject.instantiate(
|
||||||
new GameObject("Menu Button", menuButtonRenderer),
|
new GameObject("Menu Button", new GuiRenderer("images/menus/settings/menu.png", 575, 118.75f)),
|
||||||
new Vector2(transform.position.offset(550, 881.25f))).transform.setParent(transform);
|
new Vector2(transform.position.offset(550, 881.25f))).transform.setParent(transform);
|
||||||
|
|
||||||
GameObject.instantiate(new GameObject("Menu Button Text", menuText), new Vector2(
|
GameObject.instantiate(new GameObject("Menu Button Text", menuText), new Vector2(
|
||||||
/*
|
|
||||||
* Position HAUT-DROITE du panneau (offset y 132 = y GUI ~172,
|
|
||||||
* device ~215) : l'original (offset y 943.75 -> y GUI ~984)
|
|
||||||
* sortait de la zone visible Android (864 GUI sur un écran
|
|
||||||
* 20:9) — l'utilisateur était ENFERMÉ dans les Settings
|
|
||||||
* (bouton MENU incliquable + TouchControls masqué + pas
|
|
||||||
* d'ESCAPE au touch, QA v0.12.0 P1). Sur desktop la position
|
|
||||||
* passe du bas au haut du panneau : sortie naturelle en
|
|
||||||
* haut à droite, comme les cercles de tabs.
|
|
||||||
*/
|
|
||||||
transform.position.offset(837.5f - menuText.getWidth() / 2,
|
transform.position.offset(837.5f - menuText.getWidth() / 2,
|
||||||
132f - menuText.getFontSize() / 2))).transform.setParent(transform);
|
943.75f - menuText.getFontSize() / 2))).transform.setParent(transform);
|
||||||
|
|
||||||
GameObject.instantiate(new GameObject("Settings Tab Manager",
|
GameObject.instantiate(new GameObject("Settings Tab Manager",
|
||||||
new SettingsTabManager(new AudioSettingsTab(), new GraphicsSettingsTab(), new ControlsSettingsTab())),
|
new SettingsTabManager(new AudioSettingsTab(), new GraphicsSettingsTab(), new ControlsSettingsTab())),
|
||||||
new Vector2(transform.position)).transform.setParent(transform);
|
new Vector2(transform.position)).transform.setParent(transform);
|
||||||
|
/*
|
||||||
|
* Contenu du panneau au-dessus du fond (depth 12 > 10) :
|
||||||
|
* getComponentsOfType(GuiRenderer) couvre toute la hiérarchie (le
|
||||||
|
* walk enfants de Transform est package-private côté moteur).
|
||||||
|
*/
|
||||||
|
for (com.ezardlabs.dethsquare.GuiRenderer r : gameObject
|
||||||
|
.getComponentsOfType(com.ezardlabs.dethsquare.GuiRenderer.class)) {
|
||||||
|
r.setDepth(12);
|
||||||
|
}
|
||||||
gameObject.setActive(false);
|
gameObject.setActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +85,7 @@ public class SettingsMenu extends Script {
|
|||||||
public void start() {
|
public void start() {
|
||||||
runWhenPaused = true;
|
runWhenPaused = true;
|
||||||
for (int i = 0; i < tabs.length; i++) {
|
for (int i = 0; i < tabs.length; i++) {
|
||||||
titles[i] = new GuiText(tabs[i].getTitle(), font, 31.25f, 12);
|
titles[i] = new GuiText(tabs[i].getTitle(), font, 31.25f);
|
||||||
GameObject.instantiate(new GameObject(null, titles[i]),
|
GameObject.instantiate(new GameObject(null, titles[i]),
|
||||||
transform.position.offset(212.5f + (i * 343.75f) - (titles[i].getWidth() / 2f),
|
transform.position.offset(212.5f + (i * 343.75f) - (titles[i].getWidth() / 2f),
|
||||||
77.5f - (titles[i].getFontSize() / 2))).transform.setParent(transform);
|
77.5f - (titles[i].getFontSize() / 2))).transform.setParent(transform);
|
||||||
@ -104,13 +94,8 @@ public class SettingsMenu extends Script {
|
|||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
roots[i].setActive(false);
|
roots[i].setActive(false);
|
||||||
}
|
}
|
||||||
GuiRenderer circleRenderer = new GuiRenderer("images/menus/settings/circle" + i + ".png",
|
GameObject.instantiate(new GameObject("Circle " + i,
|
||||||
81.25f, 81.25f);
|
new GuiRenderer("images/menus/settings/circle" + i + ".png", 81.25f, 81.25f)),
|
||||||
// Depth 12 : au-dessus du fond du panneau (10) — le walk v0.9.0
|
|
||||||
// était un no-op (cf. SettingsMenu.start), les cercles restaient
|
|
||||||
// à depth 0, cachés sous le fond.
|
|
||||||
circleRenderer.setDepth(12);
|
|
||||||
GameObject.instantiate(new GameObject("Circle " + i, circleRenderer),
|
|
||||||
transform.position.offset(1106.25f, 125)).transform.setParent(roots[i].transform);
|
transform.position.offset(1106.25f, 125)).transform.setParent(roots[i].transform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,63 +41,47 @@ public class Slider extends Script {
|
|||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
runWhenPaused = true;
|
runWhenPaused = true;
|
||||||
/*
|
|
||||||
* Depth 12 sur TOUT le contenu : ce HUD est rendu au-dessus du fond du
|
|
||||||
* panneau Settings (depth 10). Le "walk" v0.9.0 censé pousser le
|
|
||||||
* contenu à 12 était un no-op (getComponentsOfType ne couvre pas la
|
|
||||||
* hiérarchie, cf. SettingsMenu.start) — les sliders restaient à depth
|
|
||||||
* 0, invisibles sous le fond opaque.
|
|
||||||
*/
|
|
||||||
GameObject.instantiate(new GameObject("Slider Background",
|
GameObject.instantiate(new GameObject("Slider Background",
|
||||||
sliderRenderer("images/menus/settings/slider_base.png", 662.5f, 87.5f)),
|
new GuiRenderer("images/menus/settings/slider_base.png", 662.5f, 87.5f)),
|
||||||
new Vector2(transform.position)).transform.setParent(transform);
|
new Vector2(transform.position)).transform.setParent(transform);
|
||||||
|
|
||||||
GameObject.instantiate(new GameObject("Slider Icon",
|
GameObject.instantiate(new GameObject("Slider Icon", new GuiRenderer(iconPath, 65, 65)),
|
||||||
sliderRenderer(iconPath, 65, 65)),
|
|
||||||
transform.position.offset(12.5f, 12.5f)).transform.setParent(transform);
|
transform.position.offset(12.5f, 12.5f)).transform.setParent(transform);
|
||||||
|
|
||||||
TextureAtlas font = TextureAtlas.load("fonts/atlas.png", "fonts/atlas.txt");
|
TextureAtlas font = TextureAtlas.load("fonts/atlas.png", "fonts/atlas.txt");
|
||||||
GameObject.instantiate(new GameObject("Slider Text",
|
GameObject.instantiate(new GameObject("Slider Text", new GuiText(text, font, 31.25f)),
|
||||||
new GuiText(text, font, 31.25f, 12)),
|
|
||||||
new Vector2(transform.position.offset(93.75f, -56.25f))).transform
|
new Vector2(transform.position.offset(93.75f, -56.25f))).transform
|
||||||
.setParent(transform);
|
.setParent(transform);
|
||||||
|
|
||||||
GameObject.instantiate(new GameObject("Slider Decrease",
|
GameObject.instantiate(new GameObject("Slider Decrease",
|
||||||
decrease = sliderRenderer("images/menus/settings/slider_decrease" + ".png", 68.75f,
|
decrease = new GuiRenderer("images/menus/settings/slider_decrease" + ".png", 68.75f,
|
||||||
31.25f)), transform.position.offset(493.75f, 31.25f)).transform
|
31.25f)), transform.position.offset(493.75f, 31.25f)).transform
|
||||||
.setParent(transform);
|
.setParent(transform);
|
||||||
|
|
||||||
GameObject.instantiate(new GameObject("Slider Increase",
|
GameObject.instantiate(new GameObject("Slider Increase",
|
||||||
increase = sliderRenderer("images/menus/settings/slider_increase" + ".png", 68.75f,
|
increase = new GuiRenderer("images/menus/settings/slider_increase" + ".png", 68.75f,
|
||||||
31.25f)), transform.position.offset(543.75f, 31.25f)).transform
|
31.25f)), transform.position.offset(543.75f, 31.25f)).transform
|
||||||
.setParent(transform);
|
.setParent(transform);
|
||||||
|
|
||||||
for (int i = 0; i < bars.length; i++) {
|
for (int i = 0; i < bars.length; i++) {
|
||||||
bars[i] = GameObject.instantiate(new GameObject("Slider Bar",
|
bars[i] = GameObject.instantiate(new GameObject("Slider Bar",
|
||||||
sliderRenderer("images/menus/settings/slider_bar_white.png", 37.5f, 25f)),
|
new GuiRenderer("images/menus/settings/slider_bar_white.png", 37.5f, 25f)),
|
||||||
new Vector2(10000, 10000));
|
new Vector2(10000, 10000));
|
||||||
bars[i].transform.setParent(transform);
|
bars[i].transform.setParent(transform);
|
||||||
}
|
}
|
||||||
valueBar = GameObject.instantiate(new GameObject("Slider Bar",
|
valueBar = GameObject.instantiate(new GameObject("Slider Bar",
|
||||||
sliderRenderer("images/menus/settings/slider_bar_yellow.png", 37.5f, 25f)),
|
new GuiRenderer("images/menus/settings/slider_bar_yellow.png", 37.5f, 25f)),
|
||||||
new Vector2(10000, 10000));
|
new Vector2(10000, 10000));
|
||||||
valueBar.transform.setParent(transform);
|
valueBar.transform.setParent(transform);
|
||||||
|
|
||||||
liset = GameObject.instantiate(new GameObject("Slider Liset",
|
liset = GameObject.instantiate(new GameObject("Slider Liset",
|
||||||
sliderRenderer("images/menus/settings/mini_liset.png", 68.75f, 31.25f)),
|
new GuiRenderer("images/menus/settings/mini_liset.png", 68.75f, 31.25f)),
|
||||||
new Vector2(10000, 10000));
|
new Vector2(10000, 10000));
|
||||||
liset.transform.setParent(transform);
|
liset.transform.setParent(transform);
|
||||||
|
|
||||||
moveBars();
|
moveBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** GuiRenderer de slider, depth 12 (au-dessus du fond du panneau Settings). */
|
|
||||||
private static GuiRenderer sliderRenderer(String imagePath, float width, float height) {
|
|
||||||
GuiRenderer renderer = new GuiRenderer(imagePath, width, height);
|
|
||||||
renderer.setDepth(12);
|
|
||||||
return renderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
if (Input.getKey(KeyCode.MOUSE_LEFT) && decrease.hitTest(Input.mousePosition) &&
|
if (Input.getKey(KeyCode.MOUSE_LEFT) && decrease.hitTest(Input.mousePosition) &&
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 502 B |
@ -1,76 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""
|
|
||||||
Génération des sprites du lobby multijoueur (pixel-art, palette du jeu).
|
|
||||||
|
|
||||||
Méthode identique aux flèches de boussole v0.10.0 ("sprites pixel-art
|
|
||||||
générés dans la palette du jeu") : on part des sprites EXISTANTS de la DA
|
|
||||||
(cadres bleus néon biseautés de images/menus/main/) et on les dérive :
|
|
||||||
1. échange de palette cyan -> rouge (cadre d'erreur, lisible sur fond noir) ;
|
|
||||||
2. extension horizontale du tronçon plat du cadre (technique 9-slice
|
|
||||||
artisanale) pour obtenir un cadre d'erreur PLUS LARGE que les barres de
|
|
||||||
menu, sans déformer l'épaisseur du liseré (un simple étirement GUI
|
|
||||||
136x26 -> 1400x156 aurait aplati la bordure : 2 px de source rendus
|
|
||||||
8,75 px de large contre 12 px de haut).
|
|
||||||
|
|
||||||
Idempotent : relancer le script régénère exactement les mêmes fichiers.
|
|
||||||
Exécution : python3 scripts/gen-lobby-sprites.py (depuis la racine du dépôt)
|
|
||||||
Sortie : lost-sector/src/main/resources/images/menus/lobby/error_frame.png
|
|
||||||
"""
|
|
||||||
|
|
||||||
from PIL import Image
|
|
||||||
|
|
||||||
REPO = "lost-sector/src/main/resources"
|
|
||||||
SRC = f"{REPO}/images/menus/main/top.png"
|
|
||||||
OUT_DIR = f"{REPO}/images/menus/lobby"
|
|
||||||
|
|
||||||
# Palette extraite de top.png (comptage des pixels opaques) :
|
|
||||||
# (50, 63, 63) : remplissage ardoise sombre
|
|
||||||
# (0, 64, 88) : ombre intérieure bleutée du liseré
|
|
||||||
# (0, 0, 0) : contour noir
|
|
||||||
# (60, 188, 252) : bordure néon cyan — LA signature de la DA
|
|
||||||
# Le rouge d'erreur garde les MÊMES luminosités : le cadre reste "en relief"
|
|
||||||
# comme les barres bleues, seule la teinte change.
|
|
||||||
PALETTE_ROUGE = {
|
|
||||||
(60, 188, 252, 255): (252, 60, 60, 255), # néon cyan -> néon rouge
|
|
||||||
(0, 64, 88, 255): (88, 16, 16, 255), # ombre bleutée -> ombre rouge
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def cadre_erreur():
|
|
||||||
"""Cadre d'erreur : top.png recoloré en rouge + tronçon central allongé.
|
|
||||||
|
|
||||||
Le tronçon source (colonnes TRANCHE_DEB..TRANCHE_FIN) est une zone plate
|
|
||||||
(bandes horizontales bordure/remplissage) située entre le décrochement
|
|
||||||
gauche du cadre et la coupe en biais droite : on peut la dupliquer sans
|
|
||||||
couture visible.
|
|
||||||
"""
|
|
||||||
TRANCHE_DEB, TRANCHE_FIN = 40, 60 # colonnes plates de top.png (136x26)
|
|
||||||
NB_COPIES = 14 # 136 + 20*14 = 416 px de large -> affiché 1400x156 (x4.4/x6)
|
|
||||||
|
|
||||||
img = Image.open(SRC).convert("RGBA")
|
|
||||||
l, h = img.size
|
|
||||||
px = img.load()
|
|
||||||
for y in range(h):
|
|
||||||
for x in range(l):
|
|
||||||
# .get() : pixel absent de la table (ardoise/noir/alpha) -> inchangé
|
|
||||||
px[x, y] = PALETTE_ROUGE.get(px[x, y], px[x, y])
|
|
||||||
|
|
||||||
# Extension : on insère NB_COPIES copies du tronçon plat avant la coupe
|
|
||||||
# en biais (le tronçon est découpé APRÈS recolorie pour tout couvrir).
|
|
||||||
troncon = img.crop((TRANCHE_DEB, 0, TRANCHE_FIN, h))
|
|
||||||
out = Image.new("RGBA", (l + (TRANCHE_FIN - TRANCHE_DEB) * NB_COPIES, h))
|
|
||||||
out.paste(img.crop((0, 0, TRANCHE_FIN, h)), (0, 0))
|
|
||||||
for i in range(NB_COPIES):
|
|
||||||
out.paste(troncon, (TRANCHE_FIN + (TRANCHE_FIN - TRANCHE_DEB) * i, 0))
|
|
||||||
out.paste(img.crop((TRANCHE_FIN, 0, l, h)),
|
|
||||||
(TRANCHE_FIN + (TRANCHE_FIN - TRANCHE_DEB) * NB_COPIES, 0))
|
|
||||||
|
|
||||||
import os
|
|
||||||
os.makedirs(OUT_DIR, exist_ok=True)
|
|
||||||
out.save(f"{OUT_DIR}/error_frame.png")
|
|
||||||
print(f"OK {OUT_DIR}/error_frame.png {out.size[0]}x{out.size[1]}")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
cadre_erreur()
|
|
||||||
@ -1,288 +1,88 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# test-android.sh — batterie d'anti-régression Android (retour v0.11.0 :
|
# test-android.sh — anti-régression Android : installe le build courant,
|
||||||
# "teste bien tout les modes de jeu de façon extensive", "fais de l'anti
|
# lance une séquence de touches réelles sur l'émulateur et vérifie les logs
|
||||||
# régression").
|
# GameLog attendus (tir, mélée, pouvoirs, wall glide).
|
||||||
#
|
#
|
||||||
# Usage : scripts/test-android.sh [pattern-de-versions] (défaut : tous les checks)
|
# Usage : scripts/test-android.sh [version] (défaut : titre du commit)
|
||||||
#
|
#
|
||||||
# Prérequis :
|
# Prérequis : émulateur Android démarré + adb accessible, APK déjà construit
|
||||||
# - émulateur démarré + adb accessible (adb get-state) ;
|
# (./gradlew :android-app:assembleDebug).
|
||||||
# - APK construit : ./gradlew :android-app:assembleDebug ;
|
|
||||||
# - écran 2400x1080 landscape (AVD ls05) — coordonnées calibrées le 15/11,
|
|
||||||
# à recalibrer si l'AVD change (cf. constantes TAP_* ci-dessous).
|
|
||||||
#
|
#
|
||||||
# Chaque check = séquence de taps réels + assertion sur logcat + capture
|
# Ce que la séquence vérifie (logs logcat) :
|
||||||
# d'écran /tmp/test-android-<check>.png (revue VISUELLE obligatoire :
|
# - "tir primaire" -> bouton FIRE -> MOUSE_RIGHT (anti-régression
|
||||||
# discipline AGENTS.md n°6 — les logs ne remplacent pas l'œil).
|
# feedback v4.0.0 : tir injoignable)
|
||||||
|
# - "touch button" -> hit-test des boutons du HUD tactile
|
||||||
|
# - "TouchControls" -> HUD attaché
|
||||||
|
# - "glyphe" absent -> tolérance des caractères manquants
|
||||||
#
|
#
|
||||||
# Ce que la batterie couvre (chaque check cible un bug corrigé et référencé) :
|
# Sortie : PASS/FAIL par check, code retour 1 si un check échoue.
|
||||||
# 1 menu principal chargé sans crash
|
# Idempotent : relançable à volonté (force-stop avant chaque lancement).
|
||||||
# 2 menu INPUT Android (marshaling queueEvent + tap court) : tap Defend
|
|
||||||
# -> loadLevel('defense') [fix v0.11.0-menu inerte]
|
|
||||||
# 3 tir primaire via FIRE + pouvoir 1 (HUD tactile) [feedback v4.0.0]
|
|
||||||
# 4 pause II : down+up dans la même frame -> menu ouvert
|
|
||||||
# [fix machine à états Input]
|
|
||||||
# 5 retour au menu via Quit du pause
|
|
||||||
# 6 Exterminate : génération procédurale complète + spawn SUR LE SOL
|
|
||||||
# (raycast vertical getLayerMask) [feedback v0.10.0 + QA P1 v0.11.0]
|
|
||||||
# 7 Survival : chargé + rendu non vide (LS-RENDER visible>0)
|
|
||||||
# 8 Settings menu principal affiché (fix depths) [retour v0.11.0]
|
|
||||||
# 9 Settings menu pause affiché (fix zone de clic barre entière)
|
|
||||||
# 10 lobby multi : DA + LANCER sur serveur mort -> AUCUN crash, timeout
|
|
||||||
# 8s + cadre rouge [permission INTERNET + catch socket + watchdog]
|
|
||||||
# 11 export de logs : gamelog-latest.txt présent et alimenté
|
|
||||||
# [retour v0.11.0 "des logs que je pourrai partager"]
|
|
||||||
#
|
|
||||||
# Sortie : PASS/FAIL par check + captures, code retour 1 si un échec.
|
|
||||||
# Idempotent : force-stop avant chaque scénario de niveau.
|
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
PKG="fr.siphonight.lostsectorport"
|
PKG="fr.siphonight.lostsectorport"
|
||||||
ACTIVITY="$PKG/com.ezardlabs.lostsector.AndroidGameActivity"
|
ACTIVITY="$PKG/com.ezardlabs.lostsector.AndroidGameActivity"
|
||||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
LOG=/tmp/test-android.log
|
|
||||||
SHOT=/tmp/test-android
|
|
||||||
|
|
||||||
# --- Coordonnées (device landscape 2400x1080, calibrées 15/11) --------------
|
|
||||||
# Menu principal : centres des barres (bands de texte mesurées au screencap)
|
|
||||||
TAP_DEFEND="1140 360"
|
|
||||||
TAP_EXTERMINATE="1140 477"
|
|
||||||
TAP_SURVIVAL="1140 603"
|
|
||||||
TAP_MULTIPLAYER="1140 720"
|
|
||||||
TAP_SETTINGS="1140 842"
|
|
||||||
# HUD tactile en jeu
|
|
||||||
TAP_PAUSE="135 100" # bouton II (haut gauche)
|
|
||||||
# Rects EXACTS (Button.rect : size=min(w,h)*0.15*factor, ancré bas/droite ;
|
|
||||||
# le LABEL est dessiné en haut-gauche du rect — le tap sur le label ne
|
|
||||||
# hit-testait PAS, batterie v0.11.0) : FIRE size=1080*0.15*1.25=202.5 ->
|
|
||||||
# rect x 2113-2316 y 840-1042 ; pouvoir 1 size=105.3 -> x 931-1037 y 937-1042
|
|
||||||
TAP_FIRE="2215 941"
|
|
||||||
TAP_POW1="984 989"
|
|
||||||
# Menu pause (barres : Resume 313-449, Settings 509-643, Quit 741-877)
|
|
||||||
TAP_PAUSE_SETTINGS="1140 576"
|
|
||||||
TAP_PAUSE_QUIT="1140 809"
|
|
||||||
# Lobby multi (barres SERVEUR/LANCER/RETOUR)
|
|
||||||
TAP_LOBBY_LANCER="1140 435"
|
|
||||||
TAP_LOBBY_RETOUR="1140 630"
|
|
||||||
|
|
||||||
fails=0
|
|
||||||
|
|
||||||
log_snapshot() { adb logcat -d >"$LOG" 2>/dev/null; }
|
|
||||||
|
|
||||||
check() {
|
|
||||||
# check <nom> <motif-grep-logcat>
|
|
||||||
log_snapshot
|
|
||||||
if grep -qE "$2" "$LOG" 2>/dev/null; then
|
|
||||||
echo "PASS : $1"
|
|
||||||
else
|
|
||||||
echo "FAIL : $1 (motif '$2' absent des logs)" >&2
|
|
||||||
fails=$((fails + 1))
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
check_not() {
|
|
||||||
# check_not <nom> <motif qui ne doit PAS être dans logcat>
|
|
||||||
log_snapshot
|
|
||||||
if grep -qE "$2" "$LOG" 2>/dev/null; then
|
|
||||||
echo "FAIL : $1 (motif '$2' PRÉSENT — crash/régression)" >&2
|
|
||||||
fails=$((fails + 1))
|
|
||||||
else
|
|
||||||
echo "PASS : $1"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
tap() {
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
# la paire "x y" DOIT etre splittée en 2 args (emule "input tap x y")
|
|
||||||
adb shell input tap $1
|
|
||||||
}
|
|
||||||
shot() { adb exec-out screencap -p >"$1" 2>/dev/null; }
|
|
||||||
pid_alive() {
|
|
||||||
PID=$(adb shell pidof "$PKG" 2>/dev/null | tr -d '[:space:]')
|
|
||||||
[ -n "$PID" ] && [ "$PID" != "$(cat /tmp/test-android-dead-pid 2>/dev/null)" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
wait_log() {
|
|
||||||
# wait_log <motif> [secondes=20]
|
|
||||||
deadline=$(($(date +%s) + ${2:-20}))
|
|
||||||
while [ "$(date +%s)" -lt "$deadline" ]; do
|
|
||||||
log_snapshot
|
|
||||||
if grep -qE "$1" "$LOG"; then return 0; fi
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
fresh_launch() {
|
|
||||||
# fresh_launch : niveau propre (force-stop -> lancement -> menu chargé)
|
|
||||||
adb shell am force-stop "$PKG" 2>/dev/null || true
|
|
||||||
sleep 2
|
|
||||||
adb logcat -c
|
|
||||||
adb shell am start -n "$ACTIVITY" >/dev/null
|
|
||||||
wait_log "LS-LEVEL: Level 'main_menu' fully loaded" 25 \
|
|
||||||
|| {
|
|
||||||
echo "FAIL : menu principal jamais chargé" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# --- Pré-vol ---------------------------------------------------------------
|
# --- Pré-vol ---------------------------------------------------------------
|
||||||
adb get-state >/dev/null 2>&1 || {
|
adb get-state >/dev/null 2>&1 || {
|
||||||
echo "ERREUR : aucun émulateur/device adb" >&2
|
echo "ERREUR : aucun émulateur/device adb" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
[ -f "$ROOT/android-app/build/outputs/apk/debug/android-app-debug.apk" ] || {
|
[ -f "$ROOT/android-app/build/outputs/apk/debug/android-app-debug.apk" ] || {
|
||||||
echo "ERREUR : APK absent — lancer './gradlew :android-app:assembleDebug'" >&2
|
echo "ERREUR : APK absent — lancer './gradlew :android-app:assembleDebug'" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# --- Installation et lancement ---------------------------------------------
|
||||||
echo "==> Installation de l'APK"
|
echo "==> Installation de l'APK"
|
||||||
adb install -r "$ROOT/android-app/build/outputs/apk/debug/android-app-debug.apk" >/dev/null
|
adb install -r "$ROOT/android-app/build/outputs/apk/debug/android-app-debug.apk" >/dev/null
|
||||||
|
adb logcat -c
|
||||||
# --- 1-3 : menu -> Defend -> tir + pouvoir -> pause ------------------------
|
|
||||||
echo "==> Scénario Defend (menu, tir, pouvoir, pause)"
|
|
||||||
fresh_launch
|
|
||||||
log_snapshot
|
|
||||||
check "1. menu principal chargé sans crash" "LS-LEVEL: Level 'main_menu' fully loaded"
|
|
||||||
|
|
||||||
tap "$TAP_DEFEND"
|
|
||||||
wait_log "LS-LEVEL: Level 'defense' fully loaded" 25 || echo "WARN : Defend pas confirmé (check 2)"
|
|
||||||
# TouchControls est attaché ~0,2 s APRÈS 'fully loaded' (23:12 : 15.556 ->
|
|
||||||
# 15.736) : taper avant = toucher jamais hit-testé (échecs 3b/3c batterie).
|
|
||||||
sleep 3
|
|
||||||
tap "$TAP_FIRE"
|
|
||||||
sleep 3
|
|
||||||
tap "$TAP_POW1"
|
|
||||||
sleep 3
|
|
||||||
check "2. menu input Android : tap Defend -> niveau chargé" "LS-LEVEL: Loading level 'defense'"
|
|
||||||
check "3a. HUD tactile attaché" "TouchControls attached"
|
|
||||||
check "3b. tir primaire via FIRE" "tir primaire"
|
|
||||||
check "3c. pouvoir 1 déclenché" "pouvoir 1"
|
|
||||||
check_not "3d. aucun crash pendant le tir" "FATAL EXCEPTION"
|
|
||||||
|
|
||||||
tap "$TAP_PAUSE"
|
|
||||||
sleep 4
|
|
||||||
shot "$SHOT-4-pause.png"
|
|
||||||
check "4. pause II : ESCAPE injecté (down+up même frame)" "touch button II -> ESCAPE down"
|
|
||||||
check_not "4b. aucun crash au pause" "FATAL EXCEPTION"
|
|
||||||
|
|
||||||
# Quit du pause -> retour au menu principal (test 5)
|
|
||||||
tap "$TAP_PAUSE_QUIT"
|
|
||||||
sleep 5
|
|
||||||
check "5. Quit du pause -> retour menu" "LS-LEVEL: Loading level 'main_menu'"
|
|
||||||
|
|
||||||
# --- 6-7 : Exterminate (procédural + spawn sol) puis Survival --------------
|
|
||||||
echo "==> Scénario Exterminate (procédural + spawn sol)"
|
|
||||||
fresh_launch
|
|
||||||
tap "$TAP_EXTERMINATE"
|
|
||||||
wait_log "génération procédurale done" 30 || echo "WARN : procédural pas confirmé (check 6)"
|
|
||||||
sleep 8 # laisser le spawner poser des ennemis
|
|
||||||
check "6a. génération procédurale complète" "génération procédurale done"
|
|
||||||
check "6b. spawn sur le sol (raycast vertical)" "Exterminate spawner"
|
|
||||||
check_not "6c. aucun crash en Exterminate" "FATAL EXCEPTION"
|
|
||||||
# Vérification chiffrée du Y de spawn (sol ~25500-25600, jamais aéroporté)
|
|
||||||
log_snapshot
|
|
||||||
if grep -a "Exterminate spawner" "$LOG" | grep -qE "25600.0\)|25500.0\)|25619.0\)|25519.0\)"; then
|
|
||||||
echo "PASS : 6d. positions de spawn au niveau du sol"
|
|
||||||
else
|
|
||||||
echo "FAIL : 6d. aucune position de spawn au niveau du sol (25500/25600)" >&2
|
|
||||||
fails=$((fails + 1))
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "==> Scénario Survival (timer HUD)"
|
|
||||||
fresh_launch
|
|
||||||
tap "$TAP_SURVIVAL"
|
|
||||||
wait_log "LS-LEVEL: Level 'survival' fully loaded" 25 || echo "WARN : Survival pas confirmé (check 7)"
|
|
||||||
sleep 25 # la stat LS-RENDER est 1 ligne/300 frames — à ~15 fps
|
|
||||||
# (swiftshader) ça fait 12-20 s entre deux lignes
|
|
||||||
shot "$SHOT-7-survival.png"
|
|
||||||
check "7a. Survival chargé" "LS-LEVEL: Loading level 'survival'"
|
|
||||||
# 7b via le gamelog pullé (ring 4000 lignes) : la stat logcat peut être
|
|
||||||
# évacuée par la rotation du buffer système pendant le scénario.
|
|
||||||
adb pull "/sdcard/Android/data/$PKG/files/gamelog-latest.txt" /tmp/gamelog-7b.txt >/dev/null 2>&1
|
|
||||||
if grep -qE "LS-RENDER: visible=[1-9]" /tmp/gamelog-7b.txt 2>/dev/null; then
|
|
||||||
echo "PASS : 7b. rendu non vide (visible>0, stat dans gamelog)"
|
|
||||||
else
|
|
||||||
echo "FAIL : 7b. aucune stat LS-RENDER positive (voir capture)" >&2
|
|
||||||
fails=$((fails + 1))
|
|
||||||
fi
|
|
||||||
check_not "7c. aucun crash en Survival" "FATAL EXCEPTION"
|
|
||||||
|
|
||||||
# --- 8 : Settings menu principal (fix depths) ------------------------------
|
|
||||||
echo "==> Scénario Settings (menu principal puis pause)"
|
|
||||||
fresh_launch
|
|
||||||
tap "$TAP_SETTINGS"
|
|
||||||
sleep 5
|
|
||||||
shot "$SHOT-8-settings-menu.png"
|
|
||||||
check "8a. Settings ouvre sans crash (menu)" "touch action -> MOUSE_LEFT down"
|
|
||||||
check_not "8b. aucun crash au Settings menu" "FATAL EXCEPTION"
|
|
||||||
# Sortie du panneau : le bouton MENU est en haut à droite (fix QA v0.12.0
|
|
||||||
# P1 : il était à y GUI 984, hors écran 864 -> utilisateur enfermé).
|
|
||||||
adb shell input tap 1497 215
|
|
||||||
sleep 4
|
|
||||||
shot "$SHOT-8c-settings-sortie.png"
|
|
||||||
# 8c via le gamelog pullé (la stat logcat peut être évacuée par rotation)
|
|
||||||
adb pull "/sdcard/Android/data/$PKG/files/gamelog-latest.txt" /tmp/gamelog-8c.txt >/dev/null 2>&1
|
|
||||||
if grep -qE "MOUSE_LEFT down .1497" /tmp/gamelog-8c.txt 2>/dev/null; then
|
|
||||||
echo "PASS : 8c. sortie Settings au bouton MENU (tap haut-droit logué)"
|
|
||||||
else
|
|
||||||
echo "FAIL : 8c. tap MENU (1497,215) jamais reçu (voir capture 8c)" >&2
|
|
||||||
fails=$((fails + 1))
|
|
||||||
fi
|
|
||||||
check_not "8d. aucun crash à la sortie Settings" "FATAL EXCEPTION"
|
|
||||||
adb shell am force-stop "$PKG" 2>/dev/null || true
|
adb shell am force-stop "$PKG" 2>/dev/null || true
|
||||||
|
adb shell am start -n "$ACTIVITY" >/dev/null
|
||||||
|
sleep 14 # menu principal chargé
|
||||||
|
|
||||||
# --- 9 : Settings du menu PAUSE (fix barre entière) ------------------------
|
fails=0
|
||||||
fresh_launch
|
|
||||||
tap "$TAP_DEFEND"
|
|
||||||
wait_log "LS-LEVEL: Level 'defense' fully loaded" 25 || true
|
|
||||||
tap "$TAP_PAUSE"
|
|
||||||
sleep 4
|
|
||||||
tap "$TAP_PAUSE_SETTINGS"
|
|
||||||
sleep 5
|
|
||||||
shot "$SHOT-9-settings-pause.png"
|
|
||||||
check "9a. Settings du pause : clic sur la barre entière" "touch action -> MOUSE_LEFT down"
|
|
||||||
check_not "9b. aucun crash au Settings pause" "FATAL EXCEPTION"
|
|
||||||
|
|
||||||
# --- 10 : lobby multi (DA + LANCER serveur mort -> cadre rouge) ------------
|
check() {
|
||||||
echo "==> Scénario lobby multi (LANCER sur serveur mort)"
|
if grep -q "$2" /tmp/test-android.log 2>/dev/null; then
|
||||||
fresh_launch
|
echo "PASS : $1"
|
||||||
tap "$TAP_MULTIPLAYER"
|
else
|
||||||
wait_log "LS-LEVEL: Level 'multiplayer_lobby' fully loaded" 25 || echo "WARN : lobby pas confirmé"
|
echo "FAIL : $1 (motif '$2' absent des logs)" >&2
|
||||||
|
fails=$((fails + 1))
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- Test 1 : le menu se charge sans crash ---------------------------------
|
||||||
|
adb logcat -d >/tmp/test-android.log
|
||||||
|
check "menu principal chargé sans crash" "LS-LEVEL: Level 'main_menu' fully loaded"
|
||||||
|
|
||||||
|
# --- Test 2 : Defend -> tir primaire via FIRE ------------------------------
|
||||||
|
# (FIRE = bas droite, MOUSE_RIGHT maintenu -> "tir primaire : cadence engagée")
|
||||||
|
adb shell input swipe 1055 375 1055 375 300 # Defend
|
||||||
|
sleep 14
|
||||||
|
(adb shell input swipe 2235 900 2235 900 1200 &)
|
||||||
sleep 3
|
sleep 3
|
||||||
shot "$SHOT-10-lobby.png"
|
adb logcat -d >/tmp/test-android.log
|
||||||
tap "$TAP_LOBBY_LANCER"
|
check "HUD tactile attaché (9 boutons)" "TouchControls attached"
|
||||||
wait_log "timeout serveur 8s" 15 || echo "WARN : timeout pas confirmé (check 10)"
|
check "tir primaire déclenché via FIRE" "tir primaire"
|
||||||
sleep 2
|
|
||||||
shot "$SHOT-10-lobby-erreur.png"
|
|
||||||
check "10a. recherche lancée (socket créée — permission INTERNET)" "recherche de partie sur"
|
|
||||||
check "10b. serveur mort -> timeout 8s (pas de gel éternel)" "timeout serveur 8s"
|
|
||||||
check_not "10c. AUCUN crash au LANCER (le bug v0.11.0)" "FATAL EXCEPTION"
|
|
||||||
tap "$TAP_LOBBY_RETOUR"
|
|
||||||
sleep 5
|
|
||||||
check "10d. RETOUR du lobby -> menu (lobby réutilisable)" "LS-LEVEL: Loading level 'main_menu'"
|
|
||||||
|
|
||||||
# --- 11 : export de logs (crash-<date>.txt + gamelog-latest.txt) -----------
|
# --- Test 3 : pouvoir 1 (rangée horizontale bas centre) --------------------
|
||||||
echo "==> Export de logs partageables"
|
adb shell input swipe 1080 1000 1080 1000 200 # bouton 1
|
||||||
if adb shell ls "/sdcard/Android/data/$PKG/files/gamelog-latest.txt" >/dev/null 2>&1; then
|
sleep 2
|
||||||
echo "PASS : 11a. gamelog-latest.txt présent"
|
adb logcat -d >/tmp/test-android.log
|
||||||
else
|
check "pouvoir 1 déclenché" "pouvoir 1"
|
||||||
echo "FAIL : 11a. gamelog-latest.txt absent" >&2
|
|
||||||
fails=$((fails + 1))
|
# --- Test 4 : pause (II) dans la mission -----------------------------------
|
||||||
fi
|
adb shell input swipe 1080 120 1080 120 200 # bouton II
|
||||||
if adb pull "/sdcard/Android/data/$PKG/files/gamelog-latest.txt" /tmp/gamelog-pulled.txt >/dev/null 2>&1 && grep -qE "LS-" /tmp/gamelog-pulled.txt; then
|
sleep 3
|
||||||
echo "PASS : 11b. journal alimenté (lignes LS-)"
|
adb logcat -d >/tmp/test-android.log
|
||||||
else
|
check "menu pause via II (pas de crash)" "LS-GAMEPLAY\|LS-LEVEL"
|
||||||
echo "FAIL : 11b. journal vide ou illisible" >&2
|
|
||||||
fails=$((fails + 1))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# --- Bilan -----------------------------------------------------------------
|
# --- Bilan -----------------------------------------------------------------
|
||||||
echo "==> Captures écran (revue VISUELLE obligatoire) : $SHOT-*.png"
|
|
||||||
if [ "$fails" -eq 0 ]; then
|
if [ "$fails" -eq 0 ]; then
|
||||||
echo "==> ANTI-RÉGRESSION ANDROID : PASS (tous les checks)"
|
echo "==> ANTI-RÉGRESSION : PASS (4/4)"
|
||||||
else
|
else
|
||||||
echo "==> ANTI-RÉGRESSION ANDROID : FAIL ($fails échec(s))" >&2
|
echo "==> ANTI-RÉGRESSION : FAIL ($fails échec(s))" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user