Refactor coordinate system

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-14 00:49:31 +01:00
parent 5c9dafbbdf
commit 46712370a4
8 changed files with 83 additions and 29 deletions

View File

@@ -1,6 +1,6 @@
import 'dart:math' as math;
import 'package:wolf_dart/classes/linear_coordinates.dart';
import 'package:wolf_dart/classes/coordinate_2d.dart';
import 'package:wolf_dart/features/entities/entity.dart';
abstract class Enemy extends Entity {
@@ -58,11 +58,11 @@ abstract class Enemy extends Entity {
// The enemy can now check its own line of sight!
bool hasLineOfSight(
LinearCoordinates player,
Coordinate2D playerPosition,
bool Function(int x, int y) isWalkable,
) {
double dx = player.x - x;
double dy = player.y - y;
double dx = playerPosition.x - x;
double dy = playerPosition.y - y;
double distance = math.sqrt(dx * dx + dy * dy);
// 1. FOV Check
@@ -94,7 +94,7 @@ abstract class Enemy extends Entity {
// The weapon asks the enemy if it is unobstructed from the shooter
bool hasLineOfSightFrom(
LinearCoordinates source,
Coordinate2D source,
double sourceAngle,
double distance,
bool Function(int x, int y) isWalkable,
@@ -112,7 +112,7 @@ abstract class Enemy extends Entity {
void update({
required int elapsedMs,
required LinearCoordinates player,
required Coordinate2D playerPosition,
required bool Function(int x, int y) isWalkable,
required void Function(int damage) onDamagePlayer,
});