CanCatchFish
OxideCarbonFishingCalled to determine whether to catch fish.
Return true to allow the action and false to block it.
object CanCatchFish(BasePlayer basePlayer, BaseFishingRod baseFishingRod, Item item)Works — the game method in this build is the one the hook was written for.
Parameters
- basePlayer
- BasePlayer
- baseFishingRod
- BaseFishingRod
- item
- Item
Return value
objectThe result is checked in a special way — see the call code below.
Example
object — you can affect the game: return a value to change or cancel the action.
private object CanCatchFish(BasePlayer basePlayer, BaseFishingRod baseFishingRod, Item item)
{
Puts("CanCatchFish");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return null; // null — the game continues as usual
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Rust.opj (Oxide)
void BaseFishingRod.CatchProcessBudgeted()
Passes: BasePlayer basePlayer, BaseFishingRod baseFishingRod, Item item
WorksReturnBehavior: CustomAssembly-CSharp.dll
Where it is called (this branch's game code)
// …
{
return;
}
CurrentState = CatchState.Caught;
if (currentFishTarget != null)
{
Item item = ItemManager.Create(currentFishTarget, 1, 0uL, isServerSide: true, 0uL);
item.SetItemOwnership(ownerPlayer, ItemOwnershipPhrases.Fishing);
object result = Interface.CallHook("CanCatchFish", ownerPlayer, this, item);
// … проверка результата (Modify-хук, см. Rust.opj)
ownerPlayer.GiveItem(item, GiveItemReason.Crafted);
if (currentFishTarget.shortname == "skull.human")
{
item.name = RandomUsernames.Get(Random.Range(0, 1000));
}
if (GameInfo.HasAchievements && !string.IsNullOrEmpty(fishableModifier.SteamStatName))
{
// …Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.