RustTip

OnItemStacked

OxideItem
void OnItemStacked(Item item, Item item, ItemContainer newcontainer, int int32)
void OnItemStacked(Item item, Item item, ItemContainer newcontainer)
Работает — метод игры в этой сборке тот же, под который написан хук.

Параметры

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

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

// …
		{
			droppedItem.DroppedBy = sourcePlayer?.userID ?? ((EncryptedValue<ulong>)0uL);
		}
	}
	return true;
}
if (!newcontainer.CanAccept(this))
{
	Interface.CallHook("OnItemStacked", item2, this, newcontainer);
	return false;
}
BaseEntity entityOwner3 = GetEntityOwner();
RemoveFromContainer(sourcePlayer);
RemoveFromWorld();
RemoveConflictingSlots(newcontainer, entityOwner3, sourcePlayer);
position = iTargetPos;
SetParent(newcontainer, sourcePlayer);
// …

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