예제 #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);
 }