Beispiel #1
0
        public static void ConvertToPlayer()
        {
            var selection = ConvertToBasicNetObject(null);

            if (selection == null)
            {
                return;
            }

            selection.transform.EnsureComponentExists <SyncAnimator, Animator>(null, null, true);

            selection.EnsureComponentExists <SyncTransform>();

            if (selection.GetComponent <Animator>())
            {
                selection.EnsureComponentExists <SyncAnimator>();
            }

            VitalsAssists.AddVitalsSystem();

            /// Quality of life components
            selection.EnsureComponentExists <AutoOwnerComponentEnable>();

            selection.EnsureComponentExists <ContactTrigger>();

            /// Inventory system
            InventorySystemAssists.AddInventorySystem();

            StateAssists.AddSystem(selection, true);

            selection.EnsureComponentExists <AutoDestroyUnspawned>();
        }
Beispiel #2
0
        public static void AddSystem(this GameObject go, bool add, params MonoBehaviour[] depends)
        {
            if (add)
            {
                go.EnsureComponentExists <SyncVitals>();
                if (!go.transform.GetNestedComponentInChildren <VitalUI, NetObject>(true))
                {
                    VitalsAssists.GenerateVitalsUI(go);
                }
            }

            else
            {
                go.transform.GetNestedComponentsInChildren <SyncVitals, NetObject>(reuseableSyncVitals);
                for (int i = reuseableSyncVitals.Count - 1; i >= 0; --i)
                {
                    Object.DestroyImmediate(reuseableSyncVitals[i]);
                }

                DestroyVitalsUI(go);
            }
        }