public static bool contains(this iRlStage self, Vec2i pos) => self.bounds.contains(pos);
// TODO: consider both entities and tiles public bool isDiagonallyPassingForEntity(Vec2i from, Dir9 dir, bool isDiaPassed) { return(isDiaPassed || dir.isCardinal || new [] { dir.xVec, dir.yVec } .Select(v => v.offset(from)) .All(p => !this.cx.stage.isBlocked(p))); }
Dir9(Vec2i offset) : this(offset.x, offset.y) { }
Dir9(int x, int y) { mVec = new Vec2i(x.clamp(-1, 1), y.clamp(-1, 1)); }
// from size public Rect2Di(Vec2i size) : this(Vec2i.zero, size) { }
// TODO: make cache public static Dir9 fromVec2i(Vec2i v) => Dir9.clockwise.FirstOrDefault(d => v == d.vec);
public Rect2Di(Vec2i pos, int width, int height) : this(pos, new Vec2i(width, height)) { }
public Rect2Di(int x, int y, Vec2i size) : this(new Vec2i(x, y), size) { }
public static Rect2Di centerIn(Rect2Di toCenter, Rect2Di main) { Vec2i pos = main.leftUp + ((main.size - toCenter.size) / 2); return(new Rect2Di(pos, toCenter.size)); }
public Rect2Di(Vec2i pos, Vec2i size) { mPos = pos; mSize = size; }
public static Rect2Di col(Vec2i pos, int h) => new Rect2Di(pos.x, pos.y, 1, h);
public static Rect2Di row(Vec2i pos, int w) => new Rect2Di(pos.x, pos.y, w, 1);
public bool contains(Vec2i pos) => this.contains(pos.x, pos.y);
public Rect2Di offset(Vec2i pos, Vec2i size) { return(new Rect2Di(mPos + pos, mSize + size)); }
public Body setPos(Vec2i pos) { this.pos = pos; return(this); }