Skip to content

Commit 9cc1ef7

Browse files
committed
Moving action pipe files into a new /pipe/ directory for organization
1 parent 9b69c26 commit 9cc1ef7

File tree

142 files changed

+208
-200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+208
-200
lines changed

src/engine/action/action-pipeline.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Subscription } from 'rxjs';
33
import { logger } from '@runejs/core';
44
import { LandscapeObject } from '@runejs/filestore';
55

6-
import { gameEngineDist, getFiles } from '@engine/util';
76
import { Actor, Player } from '@engine/world/actor';
87
import { ActionHook, TaskExecutor } from '@engine/action';
98
import { Position } from '@engine/world';
@@ -224,39 +223,3 @@ export class ActionPipeline {
224223
}
225224

226225
}
227-
228-
229-
/**
230-
* Finds and loads all available action pipe files (`*.action.ts`).
231-
*/
232-
export async function loadActionFiles(): Promise<void> {
233-
const ACTION_DIRECTORY = `${gameEngineDist}/world/action`;
234-
const blacklist = [];
235-
const loadedActions: string[] = [];
236-
237-
for await(const path of getFiles(ACTION_DIRECTORY, blacklist)) {
238-
if(!path.endsWith('.action.ts') && !path.endsWith('.action.js')) {
239-
continue;
240-
}
241-
242-
const location = '.' + path.substring(ACTION_DIRECTORY.length).replace('.js', '');
243-
244-
try {
245-
const importedAction = (require(location)?.default || null) as ActionPipe | null;
246-
if(importedAction && Array.isArray(importedAction) && importedAction[0] && importedAction[1]) {
247-
ActionPipeline.register(importedAction[0], importedAction[1]);
248-
loadedActions.push(importedAction[0]);
249-
}
250-
} catch(error) {
251-
logger.error(`Error loading action file at ${location}:`);
252-
logger.error(error);
253-
}
254-
}
255-
256-
logger.info(`Loaded action pipes: ${loadedActions.join(', ')}.`);
257-
258-
return Promise.resolve();
259-
}
260-
261-
262-
export * from './hooks';

src/engine/action/index.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
11
export * from './action-pipeline';
2-
export * from './button.action';
3-
export * from './equipment-change.action';
4-
export * from './item-interaction.action';
5-
export * from './item-on-item.action';
6-
export * from './item-on-npc.action';
7-
export * from './item-on-object.action';
8-
export * from './item-on-player.action';
9-
export * from './item-swap.action';
10-
export * from './magic-on-npc.action';
11-
export * from './move-item.action';
12-
export * from './npc-init.action';
13-
export * from './npc-interaction.action';
14-
export * from './object-interaction.action';
15-
export * from './player-command.action';
16-
export * from './player-init.action';
17-
export * from './player-interaction.action';
18-
export * from './prayer.action';
19-
export * from './region-change.action';
20-
export * from './spawned-item-interaction.action';
21-
export * from './widget-interaction.action';
2+
export * from './hook';
3+
export * from './pipe';
4+
export * from './loader';

src/engine/action/loader.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { logger } from '@runejs/core';
2+
3+
import { ActionPipe, ActionPipeline } from '@engine/action';
4+
import { getFiles } from '@engine/util';
5+
import { BUILD_DIR } from '@engine/config';
6+
import { join } from 'path';
7+
8+
9+
/**
10+
* Finds and loads all available action pipe files (`*.action.ts`).
11+
*/
12+
export async function loadActionFiles(): Promise<void> {
13+
const ACTION_DIRECTORY = join(BUILD_DIR, 'action');
14+
const PIPE_DIRECTORY = join(ACTION_DIRECTORY, 'pipe');
15+
const blacklist = [];
16+
const loadedActions: string[] = [];
17+
18+
for await(const path of getFiles(PIPE_DIRECTORY, blacklist)) {
19+
if(!path.endsWith('.action.ts') && !path.endsWith('.action.js')) {
20+
continue;
21+
}
22+
23+
const location = '.' + path.substring(ACTION_DIRECTORY.length).replace('.js', '');
24+
25+
try {
26+
const importedAction = (require(location)?.default || null) as ActionPipe | null;
27+
if(importedAction && Array.isArray(importedAction) && importedAction[0] && importedAction[1]) {
28+
ActionPipeline.register(importedAction[0], importedAction[1]);
29+
loadedActions.push(importedAction[0]);
30+
}
31+
} catch(error) {
32+
logger.error(`Error loading action file at ${location}:`);
33+
logger.error(error);
34+
}
35+
}
36+
37+
logger.info(`Loaded action pipes: ${loadedActions.join(', ')}.`);
38+
39+
return Promise.resolve();
40+
}
File renamed without changes.

src/engine/action/pipe/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export * from './button.action';
2+
export * from './equipment-change.action';
3+
export * from './item-interaction.action';
4+
export * from './item-on-item.action';
5+
export * from './item-on-npc.action';
6+
export * from './item-on-object.action';
7+
export * from './item-on-player.action';
8+
export * from './item-swap.action';
9+
export * from './magic-on-npc.action';
10+
export * from './move-item.action';
11+
export * from './npc-init.action';
12+
export * from './npc-interaction.action';
13+
export * from './object-interaction.action';
14+
export * from './player-command.action';
15+
export * from './player-init.action';
16+
export * from './player-interaction.action';
17+
export * from './prayer.action';
18+
export * from './region-change.action';
19+
export * from './spawned-item-interaction.action';
20+
export * from './widget-interaction.action';

0 commit comments

Comments
 (0)