/// <summary> /// Gets a character ref or defers to loader event. Here we wait an extra frame to give group time to load. /// </summary> override protected void GetCharacter() { if (attack == null) { if (character != null) { // We only get called if groups was null, so try to find the group foreach (BasicAttacks a in character.GetComponentsInChildren <BasicAttacks>()) { for (int i = 0; i < a.attacks.Count; i++) { if (attack != null) { break; } if (a.attacks[i].name == attackName) { attack = a; attackIndex = i; break; } } } UpdateFromAttackData(); } base.GetCharacter(); } else { if (attackName == null || attackName == "") { attackName = attack.attacks[0].name; attackIndex = 0; } else { for (int i = 0; i < attack.attacks.Count; i++) { if (attack.attacks[i].name == attackName) { attackIndex = i; break; } } } UpdateFromAttackData(); } }
/// <summary> /// Handles the character being loaded. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> override protected void HandleCharacterLoaded(object sender, CharacterEventArgs e) { base.HandleCharacterLoaded(sender, e); // We only get called if groups was null, so try to find the group foreach (BasicAttacks a in e.Character.GetComponentsInChildren <BasicAttacks>()) { for (int i = 0; i < a.attacks.Count; i++) { if (attack != null) { break; } if (a.attacks[i].name == attackName) { attack = a; attackIndex = i; break; } } } UpdateFromAttackData(); }