feat: added maskbits to paths

pull/40/head
RuiAlonso 4 years ago
parent 06f17d9d8c
commit c049f83eba

@ -14,8 +14,10 @@ class Pathway extends BodyComponent {
Color? color, Color? color,
required Vector2 position, required Vector2 position,
required List<List<Vector2>> paths, required List<List<Vector2>> paths,
int? maskBits,
}) : _position = position, }) : _position = position,
_paths = paths { _paths = paths,
_maskBits = maskBits ?? Filter().maskBits {
paint = Paint() paint = Paint()
..color = color ?? const Color.fromARGB(0, 0, 0, 0) ..color = color ?? const Color.fromARGB(0, 0, 0, 0)
..style = PaintingStyle.stroke; ..style = PaintingStyle.stroke;
@ -36,6 +38,7 @@ class Pathway extends BodyComponent {
required double width, required double width,
double rotation = 0, double rotation = 0,
bool singleWall = false, bool singleWall = false,
int? maskBits,
}) { }) {
final paths = <List<Vector2>>[]; final paths = <List<Vector2>>[];
@ -58,6 +61,7 @@ class Pathway extends BodyComponent {
color: color, color: color,
position: position, position: position,
paths: paths, paths: paths,
maskBits: maskBits,
); );
} }
@ -83,6 +87,7 @@ class Pathway extends BodyComponent {
required double angle, required double angle,
double rotation = 0, double rotation = 0,
bool singleWall = false, bool singleWall = false,
int? maskBits,
}) { }) {
final paths = <List<Vector2>>[]; final paths = <List<Vector2>>[];
@ -109,6 +114,7 @@ class Pathway extends BodyComponent {
color: color, color: color,
position: position, position: position,
paths: paths, paths: paths,
maskBits: maskBits,
); );
} }
@ -128,6 +134,7 @@ class Pathway extends BodyComponent {
required double width, required double width,
double rotation = 0, double rotation = 0,
bool singleWall = false, bool singleWall = false,
int? maskBits,
}) { }) {
final paths = <List<Vector2>>[]; final paths = <List<Vector2>>[];
@ -150,11 +157,13 @@ class Pathway extends BodyComponent {
color: color, color: color,
position: position, position: position,
paths: paths, paths: paths,
maskBits: maskBits,
); );
} }
final Vector2 _position; Vector2 _position;
final List<List<Vector2>> _paths; List<List<Vector2>> _paths;
int _maskBits;
@override @override
Body createBody() { Body createBody() {
@ -170,7 +179,9 @@ class Pathway extends BodyComponent {
); );
final fixtureDef = FixtureDef(chain); final fixtureDef = FixtureDef(chain);
body.createFixture(fixtureDef); body.createFixture(fixtureDef)
..filterData.categoryBits = _maskBits
..filterData.maskBits = _maskBits;
} }
return body; return body;

Loading…
Cancel
Save