OnWaterCollect
OxideEntityobject OnWaterCollect(WaterCatcher waterCatcher)
object OnWaterCollect(WaterPump waterPump, ItemDefinition itemDefinition)Works — the game method in this build is the one the hook was written for.
Parameters
- waterCatcher
- WaterCatcher
Return value
objectReturn a value of the method's result type and the game returns it immediately; null continues as usual.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnWaterCollect(WaterCatcher waterCatcher)
{
Puts("OnWaterCollect");
// 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 1
Rust.opj (Oxide)
void WaterCatcher.CollectWater()
Passes: WaterCatcher waterCatcher
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: JustThisAssembly-CSharp.dll
Where it is called (this branch's game code)
// …
return;
}
float num = ((overrideCollectInterval > 0f) ? overrideCollectInterval : 60f);
nextCollect = num + Random.Range(0f, num * 0.1f);
if (inventory == null || IsFull())
{
return;
}
if (Interface.CallHook("OnWaterCollect", this) != null)
{
return;
}
float num2 = collectionRates.baseRate;
if (requireOutside)
{
Vector3 position = transform.position;
num2 += Climate.GetFog(position) * collectionRates.fogRate;
// …Injection point 2
Rust.opj (Oxide)
void WaterPump.CreateWater()
Passes: WaterPump waterPump, ItemDefinition itemDefinition
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (this, l0)Assembly-CSharp.dll
Where it is called (this branch's game code)
private void CreateWater()
{
if (!IsFull())
{
ItemDefinition itemDefinition = WaterResource.SV_GetAtPoint(WaterResourceLocation.position);
if (itemDefinition != null)
{
if (Interface.CallHook("OnWaterCollect", this, itemDefinition) != null)
{
return;
}
inventory.AddItem(itemDefinition, AmountPerPump, 0uL);
UpdateOnFlag();
}
}
}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.