Skip to content

Commit eb6dead

Browse files
committed
refactor: 'ground item' -> 'world item'
1 parent bf4b8a3 commit eb6dead

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

src/engine/action/action-pipeline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type ActionType =
3131
| 'item_on_npc'
3232
| 'item_on_player'
3333
| 'item_on_item'
34-
| 'item_on_ground_item'
34+
| 'item_on_world_item'
3535
| 'item_swap'
3636
| 'move_item'
3737
| 'spawned_item_interaction'

src/engine/action/pipe/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export * from './button.action';
22
export * from './equipment-change.action';
33
export * from './item-interaction.action';
44
export * from './item-on-item.action';
5-
export * from './item-on-ground-item.action';
5+
export * from './item-on-world-item.action';
66
export * from './item-on-npc.action';
77
export * from './item-on-object.action';
88
export * from './item-on-player.action';

src/engine/action/pipe/item-on-ground-item.action.ts renamed to src/engine/action/pipe/item-on-world-item.action.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@ import { ActionHook, getActionHooks, questHookFilter, ActionPipe, RunnableHooks
44

55

66
/**
7-
* Defines an item-on-item action hook.
7+
* Defines an item-on-world-item action hook.
88
*
99
* @author jameskmonger
1010
*/
11-
export interface ItemOnGroundItemActionHook extends ActionHook<ItemOnGroundItemAction, itemOnGroundItemActionHandler> {
11+
export interface ItemOnWorldItemActionHook extends ActionHook<ItemOnWorldItemAction, itemOnWorldItemActionHandler> {
1212
/**
1313
* The item pairs being used. Both items are optional so that you can specify a single item, a pair of items, or neither.
1414
*/
15-
items: { item?: number, groundItem?: number }[];
15+
items: { item?: number, worldItem?: number }[];
1616
}
1717

1818

1919
/**
20-
* The item-on-ground-item action hook handler function to be called when the hook's conditions are met.
20+
* The item-on-world-item action hook handler function to be called when the hook's conditions are met.
2121
*/
22-
export type itemOnGroundItemActionHandler = (itemOnGroundItemAction: ItemOnGroundItemAction) => void;
22+
export type itemOnWorldItemActionHandler = (itemOnWorldItemAction: ItemOnWorldItemAction) => void;
2323

2424

2525
/**
26-
* Details about an item-on-ground-item action being performed.
26+
* Details about an item-on-world-item action being performed.
2727
*
2828
* @author jameskmonger
2929
*/
30-
export interface ItemOnGroundItemAction {
30+
export interface ItemOnWorldItemAction {
3131
/**
3232
* The player performing the action.
3333
*/
@@ -60,34 +60,34 @@ export interface ItemOnGroundItemAction {
6060
}
6161

6262
/**
63-
* The pipe that the game engine hands item-on-ground-item actions off to.
63+
* The pipe that the game engine hands item-on-world-item actions off to.
6464
*
65-
* This will call the `item_on_ground_item` action hooks, if any are registered and match the action being performed.
65+
* This will call the `item_on_world_item` action hooks, if any are registered and match the action being performed.
6666
*
67-
* Both `item` and `groundItem` are optional, but if they are provided then they must match the items in use.
67+
* Both `item` and `worldItem` are optional, but if they are provided then they must match the items in use.
6868
*
6969
* @author jameskmonger
7070
*/
71-
const itemOnGroundItemActionPipe = (
71+
const itemOnWorldItemActionPipe = (
7272
player: Player,
7373
usedItem: Item, usedWithItem: WorldItem,
7474
usedWidgetId: number, usedContainerId: number, usedSlot: number
75-
): RunnableHooks<ItemOnGroundItemAction> => {
75+
): RunnableHooks<ItemOnWorldItemAction> => {
7676
if(player.busy) {
7777
return;
7878
}
7979

8080
// Find all item on item action plugins that match this action
81-
let matchingHooks = getActionHooks<ItemOnGroundItemActionHook>('item_on_ground_item', plugin => {
81+
let matchingHooks = getActionHooks<ItemOnWorldItemActionHook>('item_on_world_item', plugin => {
8282
if(questHookFilter(player, plugin)) {
8383
const used = usedItem.itemId;
8484
const usedWith = usedWithItem.itemId;
8585

86-
return (plugin.items.some(({ item, groundItem }) => {
86+
return (plugin.items.some(({ item, worldItem }) => {
8787
const itemMatch = item === undefined || item === used;
88-
const groundItemMatch = groundItem === undefined || groundItem === usedWith;
88+
const worldItemMatch = worldItem === undefined || worldItem === usedWith;
8989

90-
return itemMatch && groundItemMatch;
90+
return itemMatch && worldItemMatch;
9191
}));
9292
}
9393

@@ -102,7 +102,7 @@ const itemOnGroundItemActionPipe = (
102102

103103
if(matchingHooks.length === 0) {
104104
player.outgoingPackets.chatboxMessage(
105-
`Unhandled item on ground item interaction: ${usedItem.itemId} on ${usedWithItem.itemId}`);
105+
`Unhandled item on world item interaction: ${usedItem.itemId} on ${usedWithItem.itemId}`);
106106
return null;
107107
}
108108

@@ -118,6 +118,6 @@ const itemOnGroundItemActionPipe = (
118118

119119

120120
/**
121-
* Item-on-item action pipe definition.
121+
* Item-on-world-item action pipe definition.
122122
*/
123-
export default [ 'item_on_ground_item', itemOnGroundItemActionPipe ] as ActionPipe;
123+
export default [ 'item_on_world_item', itemOnWorldItemActionPipe ] as ActionPipe;

src/engine/net/inbound-packets/item-on-ground-item.packet.ts renamed to src/engine/net/inbound-packets/item-on-world-item.packet.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import { PacketData } from '@engine/net';
55
import { Position } from '@engine/world';
66

77
/**
8-
* Parses the item on ground item packet and calls the `item_on_ground_item` action pipeline.
8+
* Parses the item on world item packet and calls the `item_on_world_item` action pipeline.
99
*
10-
* This will check that the item being used is in the player's inventory, and that the item being used on is on the ground.
10+
* This will check that the item being used is in the player's inventory, and that the world item exists in the correct location.
1111
* The action pipeline will not be called if either of these conditions are not met.
1212
*
1313
* @param player The player that sent the packet.
1414
* @param packet The packet to parse.
1515
*
1616
* @author jameskmonger
1717
*/
18-
const itemOnGroundItemPacket = (player: Player, packet: PacketData) => {
18+
const itemOnWorldItemPacket = (player: Player, packet: PacketData) => {
1919
const { buffer } = packet;
2020

2121
const usedWithX = buffer.get('short', 'u');
@@ -37,24 +37,24 @@ const itemOnGroundItemPacket = (player: Player, packet: PacketData) => {
3737
const usedItem = player.inventory.items[usedSlot];
3838
const usedWithItem = player.instance.getTileModifications(position).mods.worldItems.find(p => p.itemId === usedWithItemId);
3939
if(!usedItem || !usedWithItem) {
40-
logger.warn(`Unhandled item on ground item case (A) for ${usedSlot} (${usedItemId}) on ${usedWithItemId} (${usedWithX}, ${usedWithY}) by ${player.username}`);
40+
logger.warn(`Unhandled item on world item case (A) for ${usedSlot} (${usedItemId}) on ${usedWithItemId} (${usedWithX}, ${usedWithY}) by ${player.username}`);
4141
return;
4242
}
4343

4444
if(usedItem.itemId !== usedItemId || usedWithItem.itemId !== usedWithItemId) {
45-
logger.warn(`Unhandled item on ground item case (B) for ${usedItem.itemId}:${usedItemId} on ${usedWithItem.itemId}:${usedWithItemId} by ${player.username}`);
45+
logger.warn(`Unhandled item on world item case (B) for ${usedItem.itemId}:${usedItemId} on ${usedWithItem.itemId}:${usedWithItemId} by ${player.username}`);
4646
return;
4747
}
4848

49-
player.actionPipeline.call('item_on_ground_item', player, usedItem, usedWithItem, usedWidgetId, usedContainerId, usedSlot);
49+
player.actionPipeline.call('item_on_world_item', player, usedItem, usedWithItem, usedWidgetId, usedContainerId, usedSlot);
5050
} else {
51-
logger.warn(`Unhandled item on ground item case (C) using widgets ${usedWidgetId}:${usedContainerId} by ${player.username}`);
51+
logger.warn(`Unhandled item on world item case (C) using widgets ${usedWidgetId}:${usedContainerId} by ${player.username}`);
5252
}
5353

5454
};
5555

5656
export default {
5757
opcode: 172,
5858
size: 14,
59-
handler: itemOnGroundItemPacket
59+
handler: itemOnWorldItemPacket
6060
};

0 commit comments

Comments
 (0)