private Section makeRoom(Section parent, Section.AdjDirection dir, Section.Archetype type = Section.Archetype.normal) { //check for overlap Collider2D col = Physics2D.OverlapPoint(Section.getDirection(dir) + (Vector2)parent.transform.position, Physics2D.AllLayers); if (col != null) { //found overlap, set link to overlap Section r = col.GetComponent <Section> (); if (r.checkSet(this)) { parent.setAdjRoom(dir, r); } return(null); } //no overlap, make a new room Section child = parent.addAdjRoom(dir); child.gameObject.name += " " + sections.Count; child.assignSet(this); sections.Add(child); return(child); }
private Section TryMakeSection(Region set, Section parent, Section.AdjDirection dir, Section.Archetype type = Section.Archetype.normal) { //check for overlap Collider2D col = Physics2D.OverlapPoint(Section.CalcDirection(dir, parent.IsFlipped()) + (Vector2)parent.transform.position, Physics2D.AllLayers); if (col != null) { //found overlap, set link to overlap Section r = col.GetComponent <Section> (); if (r.CheckSet(set)) { parent.SetAdjRoom(dir, r); } return(null); } //no overlap, make a new room Section child = parent.AddAdjRoom(dir); child.gameObject.name += " " + set.GetSectionCount(); set.AddSection(child); return(child); }