public static void ConvertToPlayer() { var selection = ConvertToBasicNetObject(null); if (selection == null) { return; } selection.EnsureComponentExists <SyncTransform>(); //selection.EnsureComponentExists<OnStateChangeKinematic>(); if (selection.GetComponent <Animator>()) { selection.EnsureComponentExists <SyncAnimator>(); } VitalsAssists.AddVitalsSystem(); /// Quality of life components selection.EnsureComponentExists <AutoOwnerComponentEnable>(); /// Inventory system InventorySystemAssists.AddInventorySystem(); StateAssists.AddSystem(selection, true); ///// State System //var syncstate = selection.EnsureComponentExists<SyncState>(); //syncstate.autoOwnerChange = false; //selection.EnsureComponentOnNestedChildren<OnStateChangeToggle>(false); //selection.EnsureComponentExists<SyncSpawnTimer>(); selection.EnsureComponentExists <AutoDestroyUnspawned>(); }
public static void AddSystem(this GameObject go, bool add, params MonoBehaviour[] depends) { if (add) { go.EnsureComponentExists <SyncVitals>(); if (!go.transform.GetNestedComponentInChildren <VitalUI>()) { VitalsAssists.GenerateVitalsUI(go); } } else { go.transform.GetNestedComponentsInChildren(reuseableSyncVitals); for (int i = reuseableSyncVitals.Count - 1; i >= 0; --i) { Object.DestroyImmediate(reuseableSyncVitals[i]); } DestroyVitalsUI(go); } }