using System.Collections; using System.Collections.Generic; using System.Linq; using BITFALL.Cosmetic; using BITKit; using BITKit.Entities; using UnityEngine; namespace BITFALL.HotFix { public class PlayerSocketService : EntityBehavior { [Inject(true)] private ICosmeticService _cosmeticService; public override void OnAwake() { base.OnAwake(); _cosmeticService.OnCosmeticsChanged += OnCosmeticsChanged; OnCosmeticsChanged(); } public override void OnDestroyComponent() { base.OnDestroyComponent(); _cosmeticService.OnCosmeticsChanged -= OnCosmeticsChanged; } private void OnCosmeticsChanged() { var tags = GetComponentsInChildren(true); foreach (var socketComponent in GetComponentsInChildren()) { var target = tags.FirstOrDefault(x => x.GetTags().Contains(socketComponent.Reference)); if (target is not null) { socketComponent.SetParent(target.transform); } } } } }