OnCupboardProtectionCalculated
OxideCarbonStructureCalled when a cupboard protection is calculated.
void OnCupboardProtectionCalculated(BuildingPrivlidge buildingPrivlidge, float cachedProtectedMinutes)Works — the game method in this build is the one the hook was written for.
Parameters
- buildingPrivlidge
- BuildingPrivlidge
- cachedProtectedMinutes
- float
Return value
voidThe return value is ignored — the hook only notifies.
Example
private void OnCupboardProtectionCalculated(BuildingPrivlidge buildingPrivlidge, float cachedProtectedMinutes)
{
Puts("OnCupboardProtectionCalculated");
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point
Rust.opj (Oxide)
float BuildingPrivlidge.GetProtectedMinutes(bool)
Passes: BuildingPrivlidge buildingPrivlidge, float cachedProtectedMinutes
WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (this, this.cachedProtectedMinutes)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
if (isServer)
{
if (!force && Time.realtimeSinceStartup < nextProtectedCalcTime)
{
return cachedProtectedMinutes;
}
nextProtectedCalcTime = Time.realtimeSinceStartup + 60f;
cachedProtectedMinutes = CalculateProtectedMinutes();
Interface.CallHook("OnCupboardProtectionCalculated", this, this.cachedProtectedMinutes);
return cachedProtectedMinutes;
}
return 0f;
}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.