Exemplo n.º 1
0
        private static bool HasDependence(ShapeBlueprint @from, CanDependOnShapeBlueprint to,
                                          HashSet <ShapeBlueprint> visited)
        {
            if (@from == to)
            {
                return(true);
            }

            if (visited == null)
            {
                visited = new HashSet <ShapeBlueprint>();
            }

            foreach (ShapeBlueprint blueprint in @from.DependenciesOnOtherShapes)
            {
                if (visited.Contains(blueprint))
                {
                    continue;
                }
                visited.Add(blueprint);

                if (blueprint == to)
                {
                    return(true);
                }

                return(HasDependence(blueprint, to, visited));
            }

            return(false);
        }
Exemplo n.º 2
0
 public void RemoveDependence(CanDependOnShapeBlueprint blueprint)
 {
     m_DependentOnMeShapes.Remove(blueprint);
     DependenciesUpdated?.Invoke();
 }
Exemplo n.º 3
0
 public void AddDependence(CanDependOnShapeBlueprint dependentOnMe)
 {
     m_DependentOnMeShapes.Add(dependentOnMe);
     DependenciesUpdated?.Invoke();
 }
Exemplo n.º 4
0
 public static bool CanCreateDependence(CanDependOnShapeBlueprint @from, ShapeData to)
 {
     return(!HasDependence(to.SourceBlueprint, @from, null));
 }