OnPowergridStageChange
OxideCarbonElectronicobject OnPowergridStageChange(PowergridManager powergridManager, int local2)
object OnPowergridStageChange()Works — the game method in this build is the one the hook was written for.
Parameters
- powergridManager
- PowergridManager
- local2
- int
Return value
objectReturn non-null to cancel the game action.
Example
object — you can affect the game: return a value to change or cancel the action.
private object OnPowergridStageChange(PowergridManager powergridManager, int local2)
{
Puts("OnPowergridStageChange");
// change nothing — the game continues as usual
return null;
// to affect the game:
// return false; // non-null cancels the game action
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point 1
Rust.opj (Oxide)
void PowergridManager.ServerTick()
Passes: PowergridManager powergridManager, int local2
WorksReturnBehavior: ExitWhenNonNullArgumentBehavior: UseArgumentString (this, l2)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
}
int num = Server_GetPowerPlantInsertedFuses();
if (num != previousInsertedFusesCount || !hasTickedOnce)
{
previousInsertedFusesCount = num;
int num2 = CalculateCurrentStage();
if (CurrentStage != num2 || !hasTickedOnce)
{
if (Interface.CallHook("OnPowergridStageChange", this, num2) != null)
{
return;
}
Analytics.Azure.OnPowerGridStageChanged(CurrentStage, num2);
CurrentStage = num2;
bool b = num2 > 0;
using (FlagsUpdateScope flagsUpdateScope = StartSetFlags(FlagsUpdateMode.SendNetworkUpdate_Flags))
{
// …Injection point 2
Rust.opj (Oxide)
void PowergridManager.ServerTick()
Passes: —
WorksReturnBehavior: CustomAssembly-CSharp.dll
Where it is called (this branch's game code)
// …
int num = Server_GetPowerPlantInsertedFuses();
if (num != previousInsertedFusesCount || !hasTickedOnce)
{
previousInsertedFusesCount = num;
int num2 = CalculateCurrentStage();
if (CurrentStage != num2 || !hasTickedOnce)
{
Analytics.Azure.OnPowerGridStageChanged(CurrentStage, num2);
object result = Interface.CallHook("OnPowergridStageChange");
// … проверка результата (Modify-хук, см. Rust.opj)
CurrentStage = num2;
bool b = num2 > 0;
using (FlagsUpdateScope flagsUpdateScope = StartSetFlags(FlagsUpdateMode.SendNetworkUpdate_Flags))
{
flagsUpdateScope.Set(Flags.On, b);
}
stageChangeWorkQueue.RestartWorkQueue();
// …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.