OnCuttingTake
OxideCarbonPlayerobject OnCuttingTake(GrowableEntity growableEntity, BasePlayer player, Item local1)
object OnCuttingTake(object arg0)Работает — метод игры в этой сборке тот же, под который написан хук.
Параметры
- growableEntity
- GrowableEntity
- player
- BasePlayer
- local1
- Item
Возвращаемое значение
objectВерните не null, чтобы отменить действие игры.
Пример
object — можно повлиять на игру: вернуть значение, чтобы изменить или отменить действие.
private object OnCuttingTake(GrowableEntity growableEntity, BasePlayer player, Item local1)
{
Puts("OnCuttingTake");
// ничего не меняем — игра продолжит как обычно
return null;
// повлиять на игру:
// return false; // не null — действие игры отменяется
}Работает и в Oxide, и в Carbon: Carbon загружает плагины Oxide без изменений.
Место встраивания 1
Rust.opj (Oxide)
void GrowableEntity.TakeClones(BasePlayer)
Передаёт: GrowableEntity growableEntity, BasePlayer player, Item local1
РаботаетReturnBehavior: ExitWhenNonNullArgumentBehavior: UseArgumentString (this, a0, l1)Assembly-CSharp.dll
Где вызывается (код игры этой ветки)
// …
return;
}
int num = Properties.BaseCloneCount + Genes.GetGeneTypeCount(GrowableGenetics.GeneType.Yield) / 2;
if (num > 0)
{
Item item = ItemManager.Create(Properties.CloneItem, num, 0uL, isServerSide: true, 0uL);
item.SetItemOwnership(player, ItemOwnershipPhrases.Cloned);
GrowableGeneEncoding.EncodeGenesToItem(this, item);
if (Interface.CallHook("OnCuttingTake", this, player, item) != null)
{
return;
}
Analytics.Azure.OnGatherItem(item.info.shortname, item.amount, this, player);
player.GiveItem(item, GiveItemReason.ResourceHarvested, GiveItemOptions.BackpackOverflow);
if (Properties.pickEffect.isValid)
{
Effect.server.Run(Properties.pickEffect.resourcePath, transform.position, Vector3.up);
// …Место встраивания 2
Rust.opj (Oxide)
void GrowableEntity.TakeClones(BasePlayer)
Передаёт: object arg0
РаботаетReturnBehavior: ContinueAssembly-CSharp.dll
Где вызывается (код игры этой ветки)
// …
int num = Properties.BaseCloneCount + Genes.GetGeneTypeCount(GrowableGenetics.GeneType.Yield) / 2;
if (num > 0)
{
Item item = ItemManager.Create(Properties.CloneItem, num, 0uL, isServerSide: true, 0uL);
item.SetItemOwnership(player, ItemOwnershipPhrases.Cloned);
GrowableGeneEncoding.EncodeGenesToItem(this, item);
Analytics.Azure.OnGatherItem(item.info.shortname, item.amount, this, player);
player.GiveItem(item, GiveItemReason.ResourceHarvested, GiveItemOptions.BackpackOverflow);
Interface.CallHook("OnCuttingTake", item.Remove(0f));
if (Properties.pickEffect.isValid)
{
Effect.server.Run(Properties.pickEffect.resourcePath, transform.position, Vector3.up);
}
TellPlanter();
Die();
}
}Источники: Rust.opj из OxideMod/Oxide.Rust (MIT) и метаданные хуков документации Carbon (MIT). Код методов — декомпиляция сервера этой ветки.