public static void CenterOn(this ILayoutObject obj1, ILayoutObject rhs) { Point center = obj1.Bounding.GetCenter(); Point centerRhs = obj1.Bounding.GetCenter(); obj1.Shift(centerRhs.x - center.x, centerRhs.y - center.y); }
public static void ShiftOutside(this ILayoutObject obj, ILayoutObject rhs, Point dir, Point hint, bool rough, bool finalShift) { Point reducBase = dir.Reduce(); Point reduc = new Point(reducBase); int xShift, yShift; #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { BigBoss.Debug.printHeader(Logs.LevelGen, "Shift Outside " + obj.ToString()); BigBoss.Debug.w(Logs.LevelGen, "Shifting outside of " + rhs.ToString()); BigBoss.Debug.w(Logs.LevelGen, "Shift " + dir + " Reduc shift: " + reduc); BigBoss.Debug.w(Logs.LevelGen, "Bounds: " + obj.Bounding + " RHS bounds: " + rhs.Bounding); var tmp = new MultiMap <GenSpace>(); tmp.PutAll(rhs.GetGrid()); tmp.PutAll(obj.GetGrid()); tmp.ToLog(Logs.LevelGen, "Before shifting"); } #endregion Point at; while (obj.Intersects(rhs, hint, out at)) { if (rough) { obj.Shift(reduc.x, reduc.y); at.Shift(reduc); hint = at; } else { reduc.Take(out xShift, out yShift); obj.Shift(xShift, yShift); if (reduc.isZero()) { reduc = new Point(reducBase); } at.Shift(xShift, yShift); hint = at; } #region DEBUG if (BigBoss.Debug.Flag(DebugManager.DebugFlag.FineSteps) && BigBoss.Debug.logging(Logs.LevelGen)) { BigBoss.Debug.w(Logs.LevelGen, "Intersected at " + at); var tmp = new MultiMap <GenSpace>(); tmp.PutAll(rhs.GetGrid()); tmp.PutAll(obj.GetGrid()); tmp.ToLog(Logs.LevelGen, "After shifting"); } #endregion } if (finalShift) { obj.Shift(dir.x, dir.y); } #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGen)) { BigBoss.Debug.printFooter(Logs.LevelGen, "Shift Outside " + obj.ToString()); } #endregion }