public Graph ExecuteStep(Graph graph)
        {
            Graph      graphCopy      = graph.Clone();
            Blackboard blackboardCopy = _blackboard.Copy();

            WfcGraphSpace <TTileData> wfcGraphSpace = new(graphCopy, _availableModules, blackboardCopy, wfcNeighborLayerName : _wfcNeighborLayerName);

            while (!wfcGraphSpace.GenerationFinished())
            {
                WfcCell <WfcGraphTile <TTileData>, int> selectedCell = SelectCell(wfcGraphSpace);

                Collapse(wfcGraphSpace, selectedCell);

                if (_requiresGlobalPropagation)
                {
                    wfcGraphSpace.PropagateGlobally();
                }
            }

            if (wfcGraphSpace.GenerationSuccessful())
            {
                _blackboard = blackboardCopy;
                wfcGraphSpace.PropagateToGraphAndCleanup();
                return(graphCopy);
            }
            ;

            return(ExecuteStep(graph));
        }
            /// <summary>
            ///
            /// </summary>
            void Start()
            {
                m_instance = this; // initialise singleton

                Blackboard[] blackboards = Resources.FindObjectsOfTypeAll <Blackboard>();

                m_blackboards = new List <Blackboard>();
                for (int i = 0; i < blackboards.Length; i++)
                {
                    Blackboard blackboard = ScriptableObject.CreateInstance <Blackboard>();
                    blackboard.Copy(blackboards[i]);
                    m_blackboards.Add(blackboard);
                }

                // retrieve manager from each component
                if (m_audioComponent != null)
                {
                    m_audioManager = m_audioComponent.GetAudioManager();
                }
                if (m_backgroundComponent != null)
                {
                    m_backgroundManager = m_backgroundComponent.GetBackgroundManager();
                }
                if (m_branchComponent != null)
                {
                    m_branchManager = m_branchComponent.GetBranchManager();
                }
                if (m_characterComponent != null)
                {
                    m_characterManager = m_characterComponent.GetCharacterManager();
                }
                if (m_dialogueComponent != null)
                {
                    m_dialogueManager = m_dialogueComponent.GetDialogueManager();
                }
                if (m_logComponent != null)
                {
                    m_logManager = m_logComponent.GetLogManager();
                }
                if (m_saveComponent != null)
                {
                    m_saveManager = new SaveManager(this, m_saveComponent);
                }

                m_utilityManager  = new UtilityManager();
                m_variableManager = new VariableManager();

                m_nodeEvaluator = new NodeEvaluator(this);

                // delete this later
                NewScene(m_startScene);
            }
Exemplo n.º 3
0
        private void Awake()
        {
            m_instance = this;

            Blackboard[] blackboards = Resources.FindObjectsOfTypeAll <Blackboard>();

            m_blackboards = new List <Blackboard>();
            for (int i = 0; i < blackboards.Length; i++)
            {
                Blackboard blackboard = ScriptableObject.CreateInstance <Blackboard>();
                blackboard.Copy(blackboards[i]);
                m_blackboards.Add(blackboard);
            }

            if (m_audioComponent != null)
            {
                m_audioManager = m_audioComponent.GetAudioManager();
            }
            if (m_backgroundComponent != null)
            {
                m_backgroundManager = m_backgroundComponent.GetBackgroundManager();
            }
            if (m_branchComponent != null)
            {
                m_branchManager = m_branchComponent.GetBranchManager();
            }
            if (m_characterComponent != null)
            {
                m_characterManager = m_characterComponent.GetCharacterManager();
            }
            if (m_dialogueComponent != null)
            {
                m_dialogueManager = m_dialogueComponent.GetDialogueManager();
            }
            if (m_saveComponent != null)
            {
                m_saveManager = new SaveManager(this, m_saveComponent);
            }

            m_utilityManager  = new UtilityManager();
            m_variableManager = new VariableManager();

            m_nodeEvaluator = new NodeEvaluator(this);
        }