RustTip

OnItemStacked

OxideItem
void OnItemStacked(Item item, Item item, ItemContainer newcontainer, int int32)
void OnItemStacked(Item item, Item item, ItemContainer newcontainer)
Метод изменился — проверить — код метода игры отличается от того, под который записан хук в Oxide. Хук всё равно вызывается, но место вызова могло сместиться — стоит проверить после обновления.

Параметры

item
Item
item
Item
newcontainer
ItemContainer
int32
int

Возвращаемое значение

voidВозвращаемое значение игнорируется — хук только уведомляет.

Пример

private void OnItemStacked(Item item, Item item, ItemContainer newcontainer, int int32)
{
    Puts("OnItemStacked");
}

Работает и в Oxide, и в Carbon: Carbon загружает плагины Oxide без изменений.

Место встраивания 1

Rust.opj (Oxide)
bool Item.MoveToContainer(ItemContainer, int, bool, bool, BasePlayer, bool)

Передаёт: Item item, Item item, ItemContainer newcontainer, int int32

Метод изменился — проверитьReturnBehavior: ContinueArgumentBehavior: UseArgumentString (l13, this, a0, l15)Assembly-CSharp.dll

Где вызывается (код игры этой ветки)

// …
if (slot2.instanceData != null && instanceData != null && (bool)info.GetComponent<ItemModFoodSpoiling>())
{
	slot2.instanceData.dataFloat = Mathf.Min(slot2.instanceData.dataFloat, instanceData.dataFloat);
	slot2.instanceData.refrigeratedSeconds = Mathf.Min(slot2.instanceData.refrigeratedSeconds, instanceData.refrigeratedSeconds);
}
newcontainer.onItemAddedToStack?.Invoke(slot2, num2, sourcePlayer);
amount -= num2;
slot2.MarkDirty();
Interface.CallHook("OnItemStacked", slot2, this, newcontainer, num2);
MarkDirty();
MigrateItemOwnership(slot2, num2);
if (amount <= 0)
{
	RemoveFromWorld();
	RemoveFromContainer(sourcePlayer);
	Remove();
	return true;
// …

Место встраивания 2

Rust.opj (Oxide)
bool Item.MoveToContainer(ItemContainer, int, bool, bool, BasePlayer, bool)

Передаёт: Item item, Item item, ItemContainer newcontainer

Метод изменился — проверитьReturnBehavior: ContinueArgumentBehavior: UseArgumentString (l23, this, a0)Assembly-CSharp.dll

Где вызывается (код игры этой ветки)

// …
	}
	return false;
}
if (newcontainer.maxStackSize > 0 && newcontainer.maxStackSize < amount)
{
	Item item2 = SplitItem(newcontainer.maxStackSize);
	if (item2 != null && !item2.MoveToContainer(newcontainer, iTargetPos, allowStack: false, ignoreStackLimit: false, sourcePlayer) && (itemContainer == null || !item2.MoveToContainer(itemContainer, -1, allowStack: true, ignoreStackLimit: false, sourcePlayer)))
	{
		Interface.CallHook("OnItemStacked", item2, this, newcontainer);
		DroppedItem droppedItem = item2.Drop(newcontainer.dropPosition, newcontainer.dropVelocity) as DroppedItem;
		if (droppedItem != null)
		{
			droppedItem.DroppedBy = sourcePlayer?.userID ?? ((EncryptedValue<ulong>)0uL);
		}
	}
	return true;
}
// …

Источники: Rust.opj из OxideMod/Oxide.Rust (MIT) и метаданные хуков документации Carbon (MIT). Код методов — декомпиляция сервера этой ветки.