public Body(Vec2i pos, Dir9 dir, bool isBlocker, bool isDiagonalBlocker = false) { this.location = Location.OnStage; this.pos = pos; this.facing = dir; this.isBlocker = isBlocker; this.isDiagonalBlocker = isDiagonalBlocker; }
// TODO: separate it in a static class public bool canWalkIn(Entity e, Dir9 dir) { var body = e.get <Body>(); if (this.isBlockingForEntities(body.pos + dir.vec)) { return(false); } return(isDiagonallyPassingForEntity(body.pos, dir, RlLogicPreferences.doEnableCornerWalk)); }
public override void DrawMutable() { var dir = base.GetValue <Dir9>(); if (dir == null) { if (ImGui.Button("Create Object")) { dir = Dir9.fromXy(1, 0); base.SetValue(dir); } } else { ImGui.LabelText("dir", dir.ToString()); } }
// 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))); }
/// <summary> Considers diagonal attack </summary> public bool canAttackIn(Entity e, Dir9 dir) { return(isDiagonallyPassingForEntity(e.get <Body>().pos, dir, RlLogicPreferences.doEnableCornerAttack)); }
public static EDir8 toEDir8(this Dir9 self) => (EDir8)self.asIndexClockwise;
public static EDir8 fromDir9(Dir9 dir) => (EDir8)dir.asIndexClockwise;
public Body setDir(Dir9 dir) { this.facing = dir; return(this); }