public void DrawTargetInfo(ITargetable characterStat) { if (previousTarget != null) { previousTarget.CharacterStatController.OnHPChanged -= DrawHealth; previousTarget.CharacterStatController.OnScratchChanged -= DrawScratch; List<BodyPartController> bodyPart = previousTarget.GetBodyParts(); if (bodyPart != null) { for (int i = 0; i < bodyPart.Count; i++) // Potentiel memoryLeak là (en gros ça ne prend pas en compte les body part remove entre l'abonnement et le désabonnement) { bodyPart[i].StatController.OnHPChanged -= gaugeDrawers[i].DrawHealth; bodyPart[i].StatController.OnScratchChanged -= gaugeDrawers[i].DrawScratch; } } } animator.SetTrigger("Disappear"); if (characterStat == null)// C'est null donc ciao on draw rien { animator.SetBool("Appear", false); previousTarget = null; targetDirection = null; for (int i = 0; i < gaugeDrawers.Count; i++) gaugeDrawers[i].gameObject.SetActive(false); return; } targetDirection = characterStat.TargetDirection; animator.SetBool("Appear", true); textTargetName.text = characterStat.CharacterStatController.CharacterData.CharacterName; if (characterStat.CharacterStatController.Level <= 0) { textTargetLevel.gameObject.SetActive(false); } else { textTargetLevel.gameObject.SetActive(true); textTargetLevelDigit.text = characterStat.CharacterStatController.Level.ToString(); } characterStat.CharacterStatController.OnHPChanged += DrawHealth; characterStat.CharacterStatController.OnScratchChanged += DrawScratch; previousTarget = characterStat; DrawHealth(characterStat.CharacterStatController.Hp, characterStat.CharacterStatController.GetHPMax()); DrawScratch(characterStat.CharacterStatController.Scratch, characterStat.CharacterStatController.Hp); DrawBodyPart(characterStat.GetBodyParts()); }