using System.Collections.Generic; using HG; using UnityEngine; namespace RoR2; public class TetherVfxOrigin : MonoBehaviour { public GameObject tetherPrefab; private List tetheredTransforms; private List tetherVfxs; protected new Transform transform { get; private set; } protected void Awake() { transform = base.transform; tetheredTransforms = CollectionPool>.RentCollection(); tetherVfxs = CollectionPool>.RentCollection(); } protected void OnDestroy() { for (int num = tetherVfxs.Count - 1; num >= 0; num--) { RemoveTetherAt(num); } tetherVfxs = CollectionPool>.ReturnCollection(tetherVfxs); tetheredTransforms = CollectionPool>.ReturnCollection(tetheredTransforms); } protected void AddTether(Transform target) { if ((bool)target) { TetherVfx tetherVfx = null; if ((bool)tetherPrefab) { tetherVfx = Object.Instantiate(tetherPrefab, transform).GetComponent(); tetherVfx.tetherTargetTransform = target; } tetheredTransforms.Add(target); tetherVfxs.Add(tetherVfx); } } protected void RemoveTetherAt(int i) { TetherVfx tetherVfx = tetherVfxs[i]; if ((bool)tetherVfx) { tetherVfx.transform.SetParent(null); tetherVfx.Terminate(); } tetheredTransforms.RemoveAt(i); tetherVfxs.RemoveAt(i); } public void SetTetheredTransforms(List newTetheredTransforms) { List list = CollectionPool>.RentCollection(); List list2 = CollectionPool>.RentCollection(); ListUtils.FindExclusiveEntriesByReference(tetheredTransforms, newTetheredTransforms, list2, list); int i = 0; for (int count = list2.Count; i < count; i++) { List list3 = tetheredTransforms; Transform value = list2[i]; RemoveTetherAt(ListUtils.FirstOccurrenceByReference(list3, in value)); } int j = 0; for (int count2 = list.Count; j < count2; j++) { AddTether(list[j]); } CollectionPool>.ReturnCollection(list2); CollectionPool>.ReturnCollection(list); } }