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); }
public void RemoveDependence(CanDependOnShapeBlueprint blueprint) { m_DependentOnMeShapes.Remove(blueprint); DependenciesUpdated?.Invoke(); }
public void AddDependence(CanDependOnShapeBlueprint dependentOnMe) { m_DependentOnMeShapes.Add(dependentOnMe); DependenciesUpdated?.Invoke(); }
public static bool CanCreateDependence(CanDependOnShapeBlueprint @from, ShapeData to) { return(!HasDependence(to.SourceBlueprint, @from, null)); }