OnCowMilk
OxideCarbonAnimalobject OnCowMilk()
object OnCowMilk(Rust.Ai.Gen2.Cow cow, BasePlayer player, object l1)
object OnCowMilk(object arg0)Method changed — check — the game method differs from the one the hook is recorded for in Oxide. The hook is still called, but its place may have shifted — worth checking after an update.
Parameters
No parameters.
Return value
objectThe returned value replaces the game result; null lets the game decide.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnCowMilk()
{
Puts("OnCowMilk");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return false; // your value instead of the game result
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point 1
Rust.opj (Oxide)
bool Rust.Ai.Gen2.Cow.TryMilk(BasePlayer)
Passes: —
Method changed — checkReturnBehavior: CustomAssembly-CSharp.dll
Where it is called (this branch's game code)
// …
if (player.IsConnected)
{
player.ShowToast(GameTip.Styles.Error, MilkBullPhrase, false);
}
return false;
}
if (!CanBeMilked(player))
{
object result = Interface.CallHook("OnCowMilk");
// … проверка результата (Modify-хук, см. Rust.opj)
return false;
}
MilkCharges = Mathf.Max(0, MilkCharges - 1);
RefreshProduction();
if (MilkDef != null)
{
int num = MilkedAmount();
// …Injection point 2
Rust.opj (Oxide)
bool Rust.Ai.Gen2.Cow.TryMilk(BasePlayer)
Passes: Rust.Ai.Gen2.Cow cow, BasePlayer player, object l1
Method changed — checkReturnBehavior: ExitWhenNonNullArgumentBehavior: UseArgumentString (this, a0, l1)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
player.ShowToast(GameTip.Styles.Error, MilkBullPhrase, false);
}
return false;
}
if (!CanBeMilked(player))
{
return false;
}
object returnvar = Interface.CallHook("OnCowMilk", this, player, local1);
if (returnvar != null)
{
return returnvar is bool && (bool)returnvar;
}
MilkCharges = Mathf.Max(0, MilkCharges - 1);
RefreshProduction();
if (MilkDef != null)
{
// …Injection point 3
Rust.opj (Oxide)
bool Rust.Ai.Gen2.Cow.TryMilk(BasePlayer)
Passes: object arg0
Method changed — checkReturnBehavior: ContinueAssembly-CSharp.dll
Where it is called (this branch's game code)
// …
}
return false;
}
if (!CanBeMilked(player))
{
return false;
}
MilkCharges = Mathf.Max(0, MilkCharges - 1);
Interface.CallHook("OnCowMilk", local1.Remove(0f));
RefreshProduction();
if (MilkDef != null)
{
int num = MilkedAmount();
player.GiveItem(ItemManager.Create(MilkDef, num, 0uL, isServerSide: true, 0uL));
if (MilkEffect != null && MilkEffect.isValid)
{
Effect.server.Run(MilkEffect.resourcePath, this, 0u, Vector3.zero, Vector3.zero);
// …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.