Beispiel #1
0
        public void Initialize()
        {
            if (ConstellationData == null && Application.isPlaying)
            {
                this.enabled = false;
                throw new NoConstellationAttached(this);
            }

            if (isInitialized) // do not initialize twice
            {
                return;
            }

            if (ConstellationComponent.eventSystem == null)
            {
                eventSystem = new ConstellationEventSystem();
            }

            if (NodesFactory.Current == null)
            {
                nodeFactory = new NodesFactory(ConstellationData?.ScriptAssembly?.GetAllScriptData());
            }
            else
            {
                nodeFactory = NodesFactory.Current;
            }

            var nodes = ConstellationData.GetNodes();

            constellation = new Constellation();
            SetNodes(nodes);

            var links = ConstellationData.GetLinks();

            foreach (LinkData link in links)
            {
                var input  = constellation.GetInput(link.Input.Guid);
                var output = constellation.GetOutput(link.Output.Guid);
                if (input != null && output != null)
                {
                    constellation.AddLink(new Link(constellation.GetInput(link.Input.Guid),
                                                   constellation.GetOutput(link.Output.Guid),
                                                   constellation.GetOutput(link.Output.Guid).Type, link.GUID));
                }
            }

            SetUnityObject();
            constellation.Initialize(System.Guid.NewGuid().ToString(), ConstellationData.name);
            if (constellation.GetInjector() is IAwakable)
            {
                constellation.GetInjector().OnAwake();
            }
            isInitialized = true;
        }
Beispiel #2
0
        public void SetConstellation(ConstellationScript script, ConstellationScriptData[] constellationScripts)
        {
            if (isInitialized) // do not initialize twice
            {
                return;
            }

            constellation = new Constellation();

            if (ConstellationComponent.eventSystem == null)
            {
                eventSystem = new ConstellationEventSystem();
            }

            if (NodesFactory.Current == null)
            {
                nodesFactory = new NodesFactory(constellationScripts);
            }
            else
            {
                nodesFactory = NodesFactory.Current;
            }

            var nodes = ConstellationData.GetNodes();

            constellation = new Constellation();
            //SetNodes(nodes);

            var links = ConstellationData.GetLinks();

            foreach (LinkData link in links)
            {
                var input  = constellation.GetInput(link.Input.Guid);
                var output = constellation.GetOutput(link.Output.Guid);
                if (input != null && output != null)
                {
                    constellation.AddLink(new Link(constellation.GetInput(link.Input.Guid),
                                                   constellation.GetOutput(link.Output.Guid),
                                                   constellation.GetOutput(link.Output.Guid).Type, link.GUID));
                }
            }

            //SetUnityObject();
            constellation.Initialize(System.Guid.NewGuid().ToString(), ConstellationData.name);
            if (constellation.GetInjector() is IAwakable)
            {
                constellation.GetInjector().OnAwake();
            }

            isInitialized = true;
        }
Beispiel #3
0
        public override void Initialize(string _guid, string _name)
        {
            if (Constellation.eventSystem == null)
            {
                eventSystem = new ConstellationEventSystem();
            }
            base.Initialize(_guid, _name);
            Injector = new Injector(this);
            if (Nodes == null)
            {
                Nodes = new List <Node <INode> >();
            }

            SetConstellationEvents();
        }
Beispiel #4
0
        public void Awake()
        {
            if (ConstellationBehaviour.eventSystem == null)
            {
                eventSystem = new ConstellationEventSystem();
            }

            if (NodesFactory.Current == null)
            {
                nodeFactory = new NodesFactory();
            }
            else
            {
                nodeFactory = NodesFactory.Current;
            }

            if (ConstellationData == null && Application.isPlaying)
            {
                this.enabled = false;
                Debug.LogError("Constellation Error: No Constellation attached to " + this.gameObject);
                return;
            }
            var nodes = ConstellationData.GetNodes();

            Constellation = new Constellation();
            SetNodes(nodes);

            var links = ConstellationData.GetLinks();

            foreach (LinkData link in links)
            {
                Constellation.AddLink(new Link(Constellation.GetInput(link.Input.Guid),
                                               Constellation.GetOutput(link.Output.Guid),
                                               Constellation.GetOutput(link.Output.Guid).Type), "none");
            }
            SetUnityObject();
            SetConstellationEvents();
            foreach (var awakables in Awakables)
            {
                awakables.OnAwake();
            }
        }