// ReSharper disable once InconsistentNaming // ReSharper disable once UnusedMember.Local private static void Postfix(Equipment __instance, ContainerData.Content content) { try { GameManager.local.StartCoroutine(ChangeAnimation(__instance, content)); } catch (Exception exception) { Debug.Log(exception.Message); } }
// ReSharper disable once InconsistentNaming private static IEnumerator ChangeAnimation(Equipment __instance, ContainerData.Content content) { var itemData = content.itemData; if (itemData == null) { yield break; } var itemModuleAnimation = itemData.GetModule <ItemModuleAnimation>(); if (itemModuleAnimation == null) { yield break; } var creature = __instance.creature; Catalog.GetData <ItemData>(itemModuleAnimation.animationContainerItemId).SpawnAsync(item => { AnimatorOverrideController animatorOverrideController = new AnimatorOverrideController(creature.animator.runtimeAnimatorController); var avatarAnimator = item.gameObject.GetComponent <Animator>(); foreach (var animation in itemModuleAnimation.animations) { try { if (string.IsNullOrEmpty(animation.Value)) { continue; } var currentAnimation = animation; animatorOverrideController[currentAnimation.Key] = avatarAnimator.runtimeAnimatorController.animationClips.First( clip => clip.name == currentAnimation.Value); } catch (Exception exception) { Debug.Log(exception.Message); } } creature.animator.runtimeAnimatorController = animatorOverrideController; }); yield return(null); }