RustTip

CanCastFishingRod

OxideCarbonFishing

Called to determine whether to cast fishing rod.

Return true to allow the action and false to block it.

object CanCastFishingRod(BasePlayer basePlayer, BaseFishingRod baseFishingRod, Item item, Vector3 vector3)
Works — the game method in this build is the one the hook was written for.

Parameters

basePlayer
BasePlayer
baseFishingRod
BaseFishingRod
item
Item
vector3
Vector3

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 CanCastFishingRod(BasePlayer basePlayer, BaseFishingRod baseFishingRod, Item item, Vector3 vector3)
{
    Puts("CanCastFishingRod");

    // 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.Server_RequestCast(BaseEntity.RPCMessage)

Passes: BasePlayer basePlayer, BaseFishingRod baseFishingRod, Item item, Vector3 vector3

WorksReturnBehavior: CustomAssembly-CSharp.dll

Where it is called (this branch's game code)

// …
	FailedCast(FailReason.NoLure);
	return;
}
if (!EvaluateFishingPosition(ref pos, ownerPlayer, out var reason, out surfaceBody))
{
	FailedCast(reason);
	return;
}
object result = Interface.CallHook("CanCastFishingRod", ownerPlayer, this, currentLure, pos);
// … проверка результата (Modify-хук, см. Rust.opj)
FishingBobber component = gameManager.CreateEntity(FishingBobberRef.resourcePath, transform.position + Vector3.up * 2.8f + ownerPlayer.eyes.BodyForward() * 1.8f, GetOwnerPlayer().ServerRotation).GetComponent<FishingBobber>();
component.transform.forward = GetOwnerPlayer().eyes.BodyForward();
component.Spawn();
component.InitialiseBobber(ownerPlayer, surfaceBody, pos, 150f);
int usedLureAmount = 0;
bool isOverfished = false;
if (FishLookup.Instance != null)
// …

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.