Skip to content

Commit

Permalink
Merge pull request #57 from trainlink-org/rework-map
Browse files Browse the repository at this point in the history
Update pathfinding
  • Loading branch information
matt-vdv authored Dec 3, 2023
2 parents 00037d9 + 34c338a commit 962a07f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
22 changes: 19 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,19 @@ export interface MapPoint {
coordinate: Coordinate;
}

export interface Node extends MapPoint {
name: string;
type: string;
state: TurnoutState;
}

export interface Turnout extends MapPoint {
name: string;
state: TurnoutState;
primaryDirection: number;
secondaryDirection: number;
connections: number[];
usedInRoute: boolean;
// connections: number[];
}

export interface TurnoutLink {
Expand All @@ -158,14 +165,16 @@ export interface TurnoutLink {
points: Coordinate[];
startActive: boolean;
endActive: boolean;
usedInRoute: boolean;
}

export interface Destination extends MapPoint {
/** A negative id for the destination (Not exposed to user) */
id: number; // Should always be -ve
// id: number; // Should always be -ve
name: string;
description: string;
connections: number[];
usedInRoute: boolean;
// connections: number[];
}

export interface Coordinate {
Expand All @@ -180,6 +189,13 @@ export interface RouteObject {
end: Destination;
}

export interface RouteObjectNew {
start: Node;
nodes: Node[];
end: Node;
links: TurnoutLink;
}

export interface CurrentTurnoutState {
id: number;
state: TurnoutState;
Expand Down
16 changes: 8 additions & 8 deletions src/websocketEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@ export interface ServerToClientEvents {
'throttle/speedUpdate': (
identifier: LocoIdentifier,
speed: number,
socketId: string,
throttleNum: number
socketID: string,
) => void;
'throttle/directionUpdate': (
identifier: LocoIdentifier,
direction: Direction,
id?: string
socketID: string
) => void;
'throttle/functionUpdate': (
identifier: LocoIdentifier,
functionNum: number,
state: boolean
state: boolean,
socketID: string
) => void;
'throttle/trackPowerUpdate': (
state: boolean,
Expand Down Expand Up @@ -148,11 +148,11 @@ export interface ClientToServerEvents {
'throttle/setSpeed': (
identifier: LocoIdentifier,
speed: number,
throttleID: number
) => void;
'throttle/switchDirection': (
identifier: LocoIdentifier
) => void;
// 'throttle/switchDirection': (
// identifier: LocoIdentifier,
// throttleID: number
// ) => void;
'throttle/setDirection': (
identifier: LocoIdentifier,
direction: Direction
Expand Down

0 comments on commit 962a07f

Please sign in to comment.