SFX : AudioSource partagé par joueur — fix crash + mêlée + latence
Crash réel en session utilisateur (repro ls-repro8, premier ramassage de pickup après le commit SFX 12c3835) : HealthPickup.onTriggerEnter faisait addComponent(new AudioSource(...)) sur le GameObject du JOUEUR qui en avait déjà un (posé par Lanka.start) — le moteur refuse les composants dupliqués : ComponentAlreadyExistsError, thread GL tué. Architecture corrigée (un seul propriétaire) : - prefab "player" (Game.registerPlayerPrefabs) porte UN AudioSource SFX sans clip initial (aucune lecture au démarrage, volume du groupe appliqué) ; - Lanka.start le RÉUTILISE (getComponentOfType, plus de addComponent) ; - pickups ammo/health/energy : setAudioClip + play sur l'AudioSource du ramasseur (plus de mutation du GameObject du joueur) ; - Nikana (retour : « l'arme de mêlée n'a toujours aucun son ») : asset amont slice.ogg joué au DÉBUT de chaque swing (onAnimatedStarted) via l'AudioSource du porteur — getter protégé MeleeWeapon. getWielder ; - latence du tir (retour : « le son arrive un peu trop tard ») : le son passe du spawn du rayon (frame 2, ~140 ms après le clic — la charge) au DÉBUT de l'anim de tir (case 0), gagé sur les munitions (chargeur vide = pas de rayon = pas de son).
This commit is contained in:
parent
12c3835d13
commit
6ea367253f
@ -1,6 +1,7 @@
|
||||
package com.ezardlabs.lostsector;
|
||||
|
||||
import com.ezardlabs.dethsquare.AudioListener;
|
||||
import com.ezardlabs.dethsquare.AudioSource;
|
||||
import com.ezardlabs.dethsquare.AudioManager;
|
||||
import com.ezardlabs.dethsquare.Collider;
|
||||
import com.ezardlabs.dethsquare.GameObject;
|
||||
@ -104,7 +105,18 @@ public class Game extends BaseGame {
|
||||
PrefabManager.addPrefab("player",
|
||||
() -> new GameObject("Player", "player", new Player(), new HUD(), new Renderer(), new Animator(),
|
||||
new Frost(), new Collider(112.5f, 156.25f, 43.75f, 43.75f), new Rigidbody(),
|
||||
new AudioListener(), new NetworkTransform(), new NetworkRenderer(), new NetworkAnimator()),
|
||||
new AudioListener(), new NetworkTransform(), new NetworkRenderer(), new NetworkAnimator(),
|
||||
/*
|
||||
* AudioSource SFX PARTAGÉ (retour direct v0.15.2 « aucun son ») :
|
||||
* UN SEUL AudioSource SFX par joueur, réutilisé par tout ce qui
|
||||
* joue un son pour lui (tir Lanka, swings Nikana, ramassages
|
||||
* pickups — setAudioClip + play). POURQUOI pas d'AudioSource par
|
||||
* arme/pickup : addComponent d'un 2e AudioSource sur le même
|
||||
* GameObject CRASH le jeu (ComponentAlreadyExistsError, crash
|
||||
* réel v0.15.2 au premier ramassage). Sans clip initial : aucune
|
||||
* lecture au démarrage, le volume du groupe SFX s'applique.
|
||||
*/
|
||||
new AudioSource(AudioManager.AudioGroup.SFX)),
|
||||
() -> new GameObject("Other Player", "player", new Renderer(), new Animator(), new Frost(),
|
||||
new Collider(112.5f, 156.25f, 43.75f, 43.75f), new NetworkTransform(), new NetworkRenderer(),
|
||||
new NetworkAnimator()));
|
||||
|
||||
@ -2,7 +2,6 @@ package com.ezardlabs.lostsector.objects.pickups;
|
||||
|
||||
import com.ezardlabs.dethsquare.AudioSource;
|
||||
import com.ezardlabs.dethsquare.AudioSource.AudioClip;
|
||||
import com.ezardlabs.dethsquare.AudioManager.AudioGroup;
|
||||
import com.ezardlabs.dethsquare.Collider;
|
||||
import com.ezardlabs.dethsquare.multiplayer.Network;
|
||||
import com.ezardlabs.lostsector.objects.warframes.Warframe;
|
||||
@ -43,10 +42,17 @@ public class AmmoPickup extends Pickup {
|
||||
* Un AudioSource par pickup, joué à la consommation — pas de
|
||||
* composant permanent au sol (silence sinon).
|
||||
*/
|
||||
AudioSource audio = new AudioSource(
|
||||
new AudioClip("audio/sfx/pickups/ammo/pickup.ogg"), AudioGroup.SFX);
|
||||
other.gameObject.addComponent(audio);
|
||||
audio.play();
|
||||
AudioSource sfx = other.gameObject.getComponentOfType(AudioSource.class);
|
||||
/*
|
||||
* AudioSource SFX PARTAGÉ du ramasseur (prefab joueur) — JAMAIS
|
||||
* addComponent ici : un 2e AudioSource sur le même GameObject
|
||||
* crashe le jeu (ComponentAlreadyExistsError, crash réel
|
||||
* v0.15.2 au premier ramassage).
|
||||
*/
|
||||
if (sfx != null) {
|
||||
sfx.setAudioClip(new AudioClip("audio/sfx/pickups/ammo/pickup.ogg"));
|
||||
sfx.play();
|
||||
}
|
||||
Network.destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package com.ezardlabs.lostsector.objects.pickups;
|
||||
|
||||
import com.ezardlabs.dethsquare.AudioSource;
|
||||
import com.ezardlabs.dethsquare.AudioSource.AudioClip;
|
||||
import com.ezardlabs.dethsquare.AudioManager.AudioGroup;
|
||||
import com.ezardlabs.dethsquare.Collider;
|
||||
import com.ezardlabs.dethsquare.multiplayer.Network;
|
||||
import com.ezardlabs.lostsector.objects.warframes.Warframe;
|
||||
@ -29,10 +28,17 @@ public class EnergyPickup extends Pickup {
|
||||
* asset amont jamais câblé (TODO « son de ramassage amont
|
||||
* jamais câblé »). AudioSource jetable, joué à la consommation.
|
||||
*/
|
||||
AudioSource audio = new AudioSource(
|
||||
new AudioClip("audio/sfx/pickups/health-energy/pickup.ogg"), AudioGroup.SFX);
|
||||
other.gameObject.addComponent(audio);
|
||||
audio.play();
|
||||
AudioSource sfx = other.gameObject.getComponentOfType(AudioSource.class);
|
||||
/*
|
||||
* AudioSource SFX PARTAGÉ du ramasseur (prefab joueur) — JAMAIS
|
||||
* addComponent ici : un 2e AudioSource sur le même GameObject
|
||||
* crashe le jeu (ComponentAlreadyExistsError, crash réel
|
||||
* v0.15.2 au premier ramassage).
|
||||
*/
|
||||
if (sfx != null) {
|
||||
sfx.setAudioClip(new AudioClip("audio/sfx/pickups/health-energy/pickup.ogg"));
|
||||
sfx.play();
|
||||
}
|
||||
Network.destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package com.ezardlabs.lostsector.objects.pickups;
|
||||
|
||||
import com.ezardlabs.dethsquare.AudioSource;
|
||||
import com.ezardlabs.dethsquare.AudioSource.AudioClip;
|
||||
import com.ezardlabs.dethsquare.AudioManager.AudioGroup;
|
||||
import com.ezardlabs.dethsquare.Collider;
|
||||
import com.ezardlabs.dethsquare.multiplayer.Network;
|
||||
import com.ezardlabs.lostsector.objects.warframes.Warframe;
|
||||
@ -29,10 +28,17 @@ public class HealthPickup extends Pickup {
|
||||
* asset amont jamais câblé (TODO « son de ramassage amont
|
||||
* jamais câblé »). AudioSource jetable, joué à la consommation.
|
||||
*/
|
||||
AudioSource audio = new AudioSource(
|
||||
new AudioClip("audio/sfx/pickups/health-energy/pickup.ogg"), AudioGroup.SFX);
|
||||
other.gameObject.addComponent(audio);
|
||||
audio.play();
|
||||
AudioSource sfx = other.gameObject.getComponentOfType(AudioSource.class);
|
||||
/*
|
||||
* AudioSource SFX PARTAGÉ du ramasseur (prefab joueur) — JAMAIS
|
||||
* addComponent ici : un 2e AudioSource sur le même GameObject
|
||||
* crashe le jeu (ComponentAlreadyExistsError, crash réel
|
||||
* v0.15.2 au premier ramassage).
|
||||
*/
|
||||
if (sfx != null) {
|
||||
sfx.setAudioClip(new AudioClip("audio/sfx/pickups/health-energy/pickup.ogg"));
|
||||
sfx.play();
|
||||
}
|
||||
Network.destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,17 @@ public abstract class MeleeWeapon extends Weapon {
|
||||
|
||||
public abstract boolean isStowed();
|
||||
|
||||
/**
|
||||
* Le GameObject porteur de l'arme (accès protégé pour les SFX — le
|
||||
* porteur porte l'AudioSource SFX partagé du prefab joueur, cf.
|
||||
* Game.registerPlayerPrefabs ; jamais de nouvel AudioSource par arme :
|
||||
* un composant dupliqué fait CRASH le jeu, ComponentAlreadyExistsError,
|
||||
* crash réel v0.15.2).
|
||||
*/
|
||||
protected final GameObject getWielder() {
|
||||
return wielder;
|
||||
}
|
||||
|
||||
public final void reset() {
|
||||
currentAnimation = null;
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.ezardlabs.lostsector.objects.weapons.melee;
|
||||
|
||||
import com.ezardlabs.dethsquare.AudioSource;
|
||||
import com.ezardlabs.dethsquare.AudioSource.AudioClip;
|
||||
import com.ezardlabs.dethsquare.GameObject;
|
||||
import com.ezardlabs.dethsquare.TextureAtlas;
|
||||
import com.ezardlabs.dethsquare.animation.Animation;
|
||||
@ -98,6 +100,20 @@ public class Nikana extends MeleeWeapon implements AnimationListener {
|
||||
public void onAnimatedStarted(Animator animator) {
|
||||
stowed = false;
|
||||
shouldStow = false;
|
||||
/*
|
||||
* SFX de swing (retour direct v0.15.2 : « l'arme de mêlée n'a toujours
|
||||
* aucun son ») : asset amont slice.ogg JAMAIS câblé. Joué au DÉBUT de
|
||||
* CHAQUE swing (slice1-3/dash1-3) via l'AudioSource SFX PARTAGÉ du
|
||||
* porteur (prefab joueur — cf. MeleeWeapon.getWielder) : JAMAIS de
|
||||
* nouvel AudioSource ici, un composant dupliqué crash le jeu
|
||||
* (ComponentAlreadyExistsError, crash réel v0.15.2 sur le même
|
||||
* pattern côté pickups).
|
||||
*/
|
||||
AudioSource sfx = getWielder().getComponentOfType(AudioSource.class);
|
||||
if (sfx != null) {
|
||||
sfx.setAudioClip(new AudioClip("audio/sfx/weapons/melee/nikana/slice.ogg"));
|
||||
sfx.play();
|
||||
}
|
||||
if (t != null) {
|
||||
t.cancel();
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@ package com.ezardlabs.lostsector.objects.weapons.primary;
|
||||
import com.ezardlabs.dethsquare.animation.AnimationType;
|
||||
import com.ezardlabs.dethsquare.AudioSource;
|
||||
import com.ezardlabs.dethsquare.AudioSource.AudioClip;
|
||||
import com.ezardlabs.dethsquare.AudioManager.AudioGroup;
|
||||
import com.ezardlabs.dethsquare.GameObject;
|
||||
import com.ezardlabs.dethsquare.multiplayer.Network;
|
||||
import com.ezardlabs.lostsector.objects.projectiles.LankaBeam;
|
||||
@ -31,9 +30,13 @@ public class Lanka extends PrimaryWeapon {
|
||||
@Override
|
||||
public void start() {
|
||||
super.start();
|
||||
shootSound = new AudioSource(AudioGroup.SFX);
|
||||
shootSound.setAudioClip(new AudioClip("audio/sfx/weapons/ranged/lanka/shoot.ogg"));
|
||||
gameObject.addComponent(shootSound);
|
||||
/*
|
||||
* AudioSource SFX PARTAGÉ du joueur (prefab, cf. Game.
|
||||
* registerPlayerPrefabs) : RÉUTILISÉ, jamais recréé — un 2e
|
||||
* AudioSource sur le GameObject joueur crashe le jeu
|
||||
* (ComponentAlreadyExistsError, crash réel v0.15.2).
|
||||
*/
|
||||
shootSound = gameObject.getComponentOfType(AudioSource.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -52,6 +55,20 @@ public class Lanka extends PrimaryWeapon {
|
||||
switch (currentFrame) {
|
||||
case 0:
|
||||
beamCreated = false;
|
||||
/*
|
||||
* SFX au DÉBUT de l'anim (retour direct v0.15.2 : « le son
|
||||
* arrive un peu trop tard ») : joué au spawn du rayon il
|
||||
* tombait à ~140 ms du clic (charge frame 2, 5 ticks x
|
||||
* 70 ms). Joué ICI, le feedback suit le clic — le rayon
|
||||
* part ensuite (la charge reste un choix de gameplay,
|
||||
* retour v0.13.0). Gage sur les munitions : chargeur vide
|
||||
* = pas de rayon = pas de son de tir.
|
||||
*/
|
||||
if (shootSound != null && getMagazine() > 0) {
|
||||
shootSound.setAudioClip(
|
||||
new AudioClip("audio/sfx/weapons/ranged/lanka/shoot.ogg"));
|
||||
shootSound.play();
|
||||
}
|
||||
case 1:
|
||||
case 3:
|
||||
case 4:
|
||||
@ -92,8 +109,6 @@ public class Lanka extends PrimaryWeapon {
|
||||
lankaBeam.setDirection(transform.scale.x);
|
||||
}
|
||||
beamCreated = true;
|
||||
// SFX au spawn exact du rayon (cf. champ shootSound)
|
||||
if (shootSound != null) shootSound.play();
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user