34 lines
837 B
Dart
34 lines
837 B
Dart
part of 'sitemode.dart';
|
|
|
|
extension PlayerParts on SiteMode {
|
|
void playerMaintain() {
|
|
playerTookAutomatedAction = false;
|
|
var geo.Offset(:x, :y) = playerPosition;
|
|
|
|
var tile = level.tiles.get(x, y);
|
|
if (tile == LevelTile.closedDoor) {
|
|
level.tiles.set(x, y, LevelTile.openDoor);
|
|
}
|
|
|
|
if (playerIntendedPath.isNotEmpty) {
|
|
var nextPosition = playerIntendedPath.removeAt(0);
|
|
playerPosition = nextPosition;
|
|
playerTookAutomatedAction = true;
|
|
}
|
|
}
|
|
|
|
// support the UI command here
|
|
Future<void> playerMoveTo(int cx, int cy) async {
|
|
var ipath = dijkstraPath(
|
|
geo.Offset(playerPosition.x, playerPosition.y),
|
|
geo.Offset(cx, cy),
|
|
_fovDijkstraNeighbors,
|
|
);
|
|
|
|
if (ipath == null) {
|
|
return; // don't move, I guess
|
|
}
|
|
playerIntendedPath.addAll(ipath);
|
|
}
|
|
}
|