rendom
This commit is contained in:
@@ -29,6 +29,16 @@ class InteractionSystem {
|
||||
|
||||
const candidates = this.scene.spatialGrid ? this.scene.spatialGrid.query(playerPos.x, playerPos.y) : this.scene.npcs;
|
||||
|
||||
if (this.scene.vehicles) {
|
||||
for (const v of this.scene.vehicles) {
|
||||
const d = Phaser.Math.Distance.Between(playerPos.x, playerPos.y, v.gridX, v.gridY);
|
||||
if (d < minDist) {
|
||||
minDist = d;
|
||||
nearest = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const npc of candidates) {
|
||||
const d = Phaser.Math.Distance.Between(playerPos.x, playerPos.y, npc.gridX, npc.gridY);
|
||||
if (d < minDist) {
|
||||
@@ -39,7 +49,10 @@ class InteractionSystem {
|
||||
|
||||
if (nearest) {
|
||||
console.log('E Interacted with:', nearest.type);
|
||||
if (nearest.type === 'zombie') {
|
||||
if (nearest.type === 'scooter') {
|
||||
nearest.interact(this.scene.player);
|
||||
}
|
||||
else if (nearest.type === 'zombie') {
|
||||
// Always Tame on E key (Combat is Space/Click)
|
||||
nearest.tame();
|
||||
} else {
|
||||
@@ -82,6 +95,20 @@ class InteractionSystem {
|
||||
return;
|
||||
}
|
||||
|
||||
// 3.4 Check for Vehicles (Scooter)
|
||||
if (!isAttack && this.scene.vehicles) {
|
||||
for (const vehicle of this.scene.vehicles) {
|
||||
// If mounted, dismount (interact with self/vehicle at same pos)
|
||||
// If unmounted, check proximity
|
||||
if (Math.abs(vehicle.gridX - gridX) < 1.5 && Math.abs(vehicle.gridY - gridY) < 1.5) {
|
||||
if (vehicle.interact) {
|
||||
vehicle.interact(this.scene.player);
|
||||
return; // Stop other interactions
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3.5 Check for NPC Interaction
|
||||
const candidates = this.scene.spatialGrid ? this.scene.spatialGrid.query(gridX, gridY) : this.scene.npcs;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user