OnEntityControl
OxideElectronicobject OnEntityControl(AutoTurret autoTurret, ulong playerID)
object OnEntityControl(PoweredRemoteControlEntity poweredRemoteControlEntity, ulong playerID)
object OnEntityControl(RemoteControlEntity remoteControlEntity, ulong playerID)Works — the game method in this build is the one the hook was written for.
Parameters
- autoTurret
- AutoTurret
- playerID
- ulong
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 OnEntityControl(AutoTurret autoTurret, ulong playerID)
{
Puts("OnEntityControl");
// 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)
bool AutoTurret.CanControl(ulong)
Passes: AutoTurret autoTurret, ulong playerID
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: AllAssembly-CSharp.dll
Where it is called (this branch's game code)
public virtual bool CanControl(ulong playerID)
{
object returnvar = Interface.CallHook("OnEntityControl", this, playerID);
if (returnvar is bool)
{
return (bool)returnvar;
}
if (booting)
{
return false;
}
// …Injection point 2
Rust.opj (Oxide)
bool PoweredRemoteControlEntity.CanControl(ulong)
Passes: PoweredRemoteControlEntity poweredRemoteControlEntity, ulong playerID
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: AllAssembly-CSharp.dll
Where it is called (this branch's game code)
public virtual bool CanControl(ulong playerID)
{
object returnvar = Interface.CallHook("OnEntityControl", this, playerID);
if (returnvar is bool)
{
return (bool)returnvar;
}
if (!IsPowered())
{
return IsStatic();
}
// …Injection point 3
Rust.opj (Oxide)
bool RemoteControlEntity.CanControl(ulong)
Passes: RemoteControlEntity remoteControlEntity, ulong playerID
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: AllAssembly-CSharp.dll
Where it is called (this branch's game code)
public virtual bool CanControl(ulong playerID)
{
object returnvar = Interface.CallHook("OnEntityControl", this, playerID);
if (returnvar is bool)
{
return (bool)returnvar;
}
return true;
}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.