コード例 #1
0
    public static void Start()
    {
        // Attach an EgoComponent Component to each GameObject
        var gameObjects   = Object.FindObjectsOfType <GameObject>();
        var egoComponents = new List <EgoComponent>();

        foreach (var gameObject in gameObjects)
        {
            var egoComponent = gameObject.GetComponent <EgoComponent>();
            if (!egoComponent)
            {
                egoComponent = gameObject.AddComponent <EgoComponent>();
            }
            egoComponent.CreateMask();
            egoComponents.Add(egoComponent);
        }

        // Create System bundles
        foreach (var system in _systems)
        {
            system.CreateBundles(egoComponents.ToArray());
        }

        // Start all Systems
        foreach (var system in _systems)
        {
            system.Start();
        }

        // Invoke all queued Events
        EgoEvents.Invoke();

        // Clean up Destroyed Components & GameObjects
        EgoCleanUp.CleanUp();
    }
コード例 #2
0
ファイル: Ego.cs プロジェクト: ctxdegithub/EgoCS
    public static void Destroy(GameObject gameObject)
    {
        var egoComponent = gameObject.GetComponent <EgoComponent>();

        EgoEvents <DestroyedGameObject> .AddEvent(new DestroyedGameObject( gameObject, egoComponent ));

        EgoCleanUp.Destroy(gameObject);
    }
コード例 #3
0
ファイル: Ego.cs プロジェクト: theBurningVoid/UnityMagickGame
    public static void DestroyGameObject(EgoComponent egoComponent)
    {
        var gameObject = egoComponent.gameObject;

        EgoEvents <DestroyedGameObject> .AddEvent(new DestroyedGameObject( gameObject, egoComponent ));

        EgoCleanUp.Destroy(egoComponent.gameObject);
    }
コード例 #4
0
    public static void Start()
    {
        var sceneCount = SceneManager.sceneCount;

        for (var sceneIndex = 0; sceneIndex < sceneCount; sceneIndex++)
        {
            var scene           = SceneManager.GetSceneAt(sceneIndex);
            var rootGameObjects = scene.GetRootGameObjects();

            // Attach an EgoComponent Component to every GameObject in the scene
            foreach (var go in rootGameObjects)
            {
                InitEgoComponent(go);
            }

            // Add every GameObject to any relevant system
            foreach (var system in _systems)
            {
                foreach (var go in rootGameObjects)
                {
                    var egoComponent = go.GetComponent <EgoComponent>();
                    system.CreateBundles(egoComponent);
                }
            }
        }

        //     var gameObjects = Object.FindObjectsOfType<GameObject>();
        //     var egoComponents = new List<EgoComponent>();
        //     foreach( var gameObject in gameObjects )
        //     {
        //         var egoComponent = gameObject.GetComponent<EgoComponent>();
        //         if( !egoComponent ) egoComponent = gameObject.AddComponent<EgoComponent>();
        //         egoComponent.CreateMask();
        //egoComponents.Add( egoComponent );
        //     }

        //     // Create System bundles
        //     foreach( var system in _systems )
        //     {
        //         system.CreateBundles( egoComponents.ToArray() );
        //     }

        // Start all Systems
        foreach (var system in _systems)
        {
            system.Start();
        }

        // Invoke all queued Events
        EgoEvents.Invoke();

        // Clean up Destroyed Components & GameObjects
        EgoCleanUp.CleanUp();
    }
コード例 #5
0
ファイル: Ego.cs プロジェクト: ctxdegithub/EgoCS
    public static bool Destroy <C>(GameObject gameObject) where C : Component
    {
        var egoComponent = gameObject.GetComponent <EgoComponent>();
        C   component    = null;

        if (egoComponent.TryGetComponents <C>(out component))
        {
            var e = new DestroyedComponent <C>(component, egoComponent);
            EgoEvents <DestroyedComponent <C> > .AddEvent(e);

            EgoCleanUp <C> .Destroy(egoComponent, component);

            return(true);
        }

        return(false);
    }
コード例 #6
0
ファイル: Ego.cs プロジェクト: theBurningVoid/UnityMagickGame
    public static bool DestroyComponent <C>(EgoComponent egoComponent) where C : Component
    {
        C component = null;

        if (!egoComponent.TryGetComponents <C>(out component))
        {
            return(false);
        }

        var e = new DestroyedComponent <C>(component, egoComponent);

        EgoEvents <DestroyedComponent <C> > .AddEvent(e);

        EgoCleanUp <C> .Destroy(egoComponent, component);

        return(true);
    }
コード例 #7
0
    public static void Update()
    {
        // Update all Systems
        foreach (var system in _systems)
        {
#if UNITY_EDITOR
            if (system.enabled)
            {
                system.Update();
            }
#else
            system.Update();
#endif
        }

        // Invoke all queued Events
        EgoEvents.Invoke();

        // Clean up Destroyed Components & GameObjects
        EgoCleanUp.CleanUp();
    }
コード例 #8
0
    public static void Start()
    {
        var sceneCount = SceneManager.sceneCount;

        for (var sceneIndex = 0; sceneIndex < sceneCount; sceneIndex++)
        {
            var scene           = SceneManager.GetSceneAt(sceneIndex);
            var rootGameObjects = scene.GetRootGameObjects();

            // Attach an EgoComponent Component to every GameObject in the scene
            foreach (var go in rootGameObjects)
            {
                InitEgoComponent(go);
            }

            // Add every GameObject to any relevant system
            foreach (var system in _systems)
            {
                foreach (var go in rootGameObjects)
                {
                    var egoComponent = go.GetComponent <EgoComponent>();
                    system.CreateBundles(egoComponent);
                }
            }
        }

        EgoEvents.Start();

        // Start all Systems
        foreach (var system in _systems)
        {
            system.Start();
        }

        // Invoke all queued Events
        EgoEvents.Invoke();

        // Clean up Destroyed Components & GameObjects
        EgoCleanUp.CleanUp();
    }