Skip to content

Commit

Permalink
adding direction extension methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtome committed Oct 16, 2024
1 parent cce48df commit 32a6e0e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/leap/lib/src/entities/status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ class EntityStatus extends Component {
mixin IgnoredByWorld on EntityStatus {}

/// A status mixin which indicates the parent entity should not
/// be affected by gravity while the status is present.
/// be affected by gravity while the status is present
/// (via [GravityAccelerationBehavior]).
mixin IgnoresGravity on EntityStatus {}

/// A status mixin which indicates the parent entity should not
/// be automatically moved by its velocity.
/// be automatically moved by its velocity (via [ApplyVelocityBehavior])
mixin IgnoresVelocity on EntityStatus {}

/// A status mixin which indicates the parent entity should not
Expand Down
20 changes: 20 additions & 0 deletions packages/leap/lib/src/utils/direction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,27 @@ enum HorizontalDirection {
right,
}

extension HorizontalDirectionExtension on HorizontalDirection {
HorizontalDirection flip() {
if (this == HorizontalDirection.left) {
return HorizontalDirection.right;
} else {
return HorizontalDirection.left;
}
}
}

enum VerticalDirection {
up,
down,
}

extension VerticalDirectionExtension on VerticalDirection {
VerticalDirection flip() {
if (this == VerticalDirection.up) {
return VerticalDirection.down;
} else {
return VerticalDirection.up;
}
}
}

0 comments on commit 32a6e0e

Please sign in to comment.