Пример #1
0
        public void Collapse(WfcCell <TModule, TPosition> cell,
                             Func <WfcCell <TModule, TPosition>, TModule> moduleSelectionFunc,
                             Action <WfcSpace <TModule, TPosition>, TModule> onModuleSelected)
        {
            TModule selectedModule = moduleSelectionFunc.Invoke(cell);

            cell.AvailableModules.RemoveAll(tile => tile != selectedModule);
            onModuleSelected.Invoke(this, selectedModule);

            PropagateResult(cell);
        }
Пример #2
0
        public void PropagateGlobally()
        {
            Stack <WfcCell <TModule, TPosition> > updateStack = new (GetCells());

            while (updateStack.Any())
            {
                WfcCell <TModule, TPosition> currentCell = updateStack.Pop();
                var wereElementsRemoved = currentCell.RemoveInvalidModules(this);
                if (wereElementsRemoved)
                {
                    GetNeighbors(currentCell).ForEach(wfcCell => updateStack.Push(wfcCell));
                }
            }
        }
Пример #3
0
        protected virtual void PropagateResult(WfcCell <TModule, TPosition> cell)
        {
            Stack <WfcCell <TModule, TPosition> > updateStack = new (GetNeighbors(cell));

            while (updateStack.Any())
            {
                WfcCell <TModule, TPosition> currentCell = updateStack.Pop();
                var wereElementsRemoved = currentCell.RemoveInvalidModules(this);
                if (wereElementsRemoved)
                {
                    GetNeighbors(currentCell).ForEach(wfcCell => updateStack.Push(wfcCell));
                }
            }
        }
Пример #4
0
 public abstract List <WfcCell <TModule, TPosition> > GetNeighbors(WfcCell <TModule, TPosition> cell);
Пример #5
0
 public void Collapse(WfcCell <TModule, TPosition> cell)
 {
     Collapse(cell, wfcCell => RandomSelector(wfcCell.AvailableModules), (space, module) => {});
 }
Пример #6
0
 public void Collapse(WfcCell <TModule, TPosition> cell,
                      Action <WfcSpace <TModule, TPosition>, TModule> onModuleSelected)
 {
     Collapse(cell, wfcCell => RandomSelector(wfcCell.AvailableModules), onModuleSelected);
 }