Exemple #1
0
 public static bool contains(this iRlStage self, Vec2i pos) =>
 self.bounds.contains(pos);
Exemple #2
0
 // 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)));
 }
Exemple #3
0
 Dir9(Vec2i offset) : this(offset.x, offset.y)
 {
 }
Exemple #4
0
 Dir9(int x, int y)
 {
     mVec = new Vec2i(x.clamp(-1, 1), y.clamp(-1, 1));
 }
Exemple #5
0
 // from size
 public Rect2Di(Vec2i size) : this(Vec2i.zero, size)
 {
 }
Exemple #6
0
 // TODO: make cache
 public static Dir9 fromVec2i(Vec2i v) => Dir9.clockwise.FirstOrDefault(d => v == d.vec);
Exemple #7
0
 public Rect2Di(Vec2i pos, int width, int height) : this(pos, new Vec2i(width, height))
 {
 }
Exemple #8
0
 public Rect2Di(int x, int y, Vec2i size) : this(new Vec2i(x, y), size)
 {
 }
Exemple #9
0
        public static Rect2Di centerIn(Rect2Di toCenter, Rect2Di main)
        {
            Vec2i pos = main.leftUp + ((main.size - toCenter.size) / 2);

            return(new Rect2Di(pos, toCenter.size));
        }
Exemple #10
0
 public Rect2Di(Vec2i pos, Vec2i size)
 {
     mPos  = pos;
     mSize = size;
 }
Exemple #11
0
 public static Rect2Di col(Vec2i pos, int h) => new Rect2Di(pos.x, pos.y, 1, h);
Exemple #12
0
 public static Rect2Di row(Vec2i pos, int w) => new Rect2Di(pos.x, pos.y, w, 1);
Exemple #13
0
 public bool contains(Vec2i pos) => this.contains(pos.x, pos.y);
Exemple #14
0
 public Rect2Di offset(Vec2i pos, Vec2i size)
 {
     return(new Rect2Di(mPos + pos, mSize + size));
 }
Exemple #15
0
 public Body setPos(Vec2i pos)
 {
     this.pos = pos;
     return(this);
 }