public WallStub CanInsertWallStub(FPoint p1, float width, ILeveleditorStub ign) { WallStub w0 = CanInsertWallStub(p1, p1 + new Vector2(width, 0), ign); if (w0 != null) { return(w0); } WallStub w1 = CanInsertWallStub(p1, p1 + new Vector2(width, width), ign); if (w1 != null) { return(w1); } WallStub w2 = CanInsertWallStub(p1, p1 + new Vector2(0, width), ign); if (w2 != null) { return(w2); } return(null); }
public WallStub CanInsertWallStub(FPoint p1, FPoint p2, ILeveleditorStub ign) { if (p1.X <= 0 && p2.X <= 0) { return(null); } if (p1.Y <= 0 && p2.Y <= 0) { return(null); } if (p1.X >= LevelData.Width * GDConstants.TILE_WIDTH && p2.X >= LevelData.Width * GDConstants.TILE_WIDTH) { return(null); } if (p1.Y >= LevelData.Height * GDConstants.TILE_WIDTH && p2.Y >= LevelData.Height * GDConstants.TILE_WIDTH) { return(null); } if (p1 == p2) { return(null); } if (p1.X <= (-4) * GDConstants.TILE_WIDTH) { return(null); } if (p1.Y <= (-4) * GDConstants.TILE_WIDTH) { return(null); } if (p1.X >= (LevelData.Width + 4) * GDConstants.TILE_WIDTH) { return(null); } if (p1.Y >= (LevelData.Height + 4) * GDConstants.TILE_WIDTH) { return(null); } if (p2.X <= (-4) * GDConstants.TILE_WIDTH) { return(null); } if (p2.Y <= (-4) * GDConstants.TILE_WIDTH) { return(null); } if (p2.X >= (LevelData.Width + 4) * GDConstants.TILE_WIDTH) { return(null); } if (p2.Y >= (LevelData.Height + 4) * GDConstants.TILE_WIDTH) { return(null); } WallStub s = new WallStub(this, p1, p2); foreach (var stub in GetEntities <ILeveleditorStub>().Where(stub => stub != ign)) { if (stub.CollidesWith(s)) { return(null); } } return(s); }