Added rail tracks, cart and camera movement with arrow keys, removed enemies... 4 now
This commit is contained in:
@@ -108,6 +108,23 @@ function handleMove(w: World, actor: Actor, action: { dx: number; dy: number },
|
||||
handleExpCollection(actor, events, accessor);
|
||||
}
|
||||
return events;
|
||||
} else {
|
||||
// If blocked, check if we can interact with an entity at the target position
|
||||
if (actor.category === "combatant" && actor.isPlayer && accessor?.context) {
|
||||
const ecsWorld = accessor.context;
|
||||
const interactables = ecsWorld.getEntitiesWith("position", "trigger").filter(id => {
|
||||
const p = ecsWorld.getComponent(id, "position");
|
||||
const t = ecsWorld.getComponent(id, "trigger");
|
||||
return p?.x === nx && p?.y === ny && t?.onInteract;
|
||||
});
|
||||
|
||||
if (interactables.length > 0) {
|
||||
// Trigger interaction by marking it as triggered
|
||||
// The TriggerSystem will pick this up on the next update
|
||||
ecsWorld.getComponent(interactables[0], "trigger")!.triggered = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return [{ type: "move-blocked", actorId: actor.id, x: nx, y: ny }];
|
||||
@@ -115,6 +132,7 @@ function handleMove(w: World, actor: Actor, action: { dx: number; dy: number },
|
||||
|
||||
|
||||
|
||||
|
||||
function handleAttack(_w: World, actor: Actor, action: { targetId: EntityId }, accessor: EntityAccessor): SimEvent[] {
|
||||
const target = accessor.getActor(action.targetId);
|
||||
if (target && target.category === "combatant" && actor.category === "combatant") {
|
||||
|
||||
Reference in New Issue
Block a user