OnEngineStart
OxideCarbonVehicleCalled when an engine starts.
object OnEngineStart(SmallEngine smallEngine, BasePlayer player)
object OnEngineStart(object arg0)
object OnEngineStart(TOwner owner, BasePlayer player)Works — the game method in this build is the one the hook was written for.
Parameters
- smallEngine
- SmallEngine
- player
- BasePlayer
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 OnEngineStart(SmallEngine smallEngine, BasePlayer player)
{
Puts("OnEngineStart");
// 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 SmallEngine.TurnOn(BaseEntity.RPCMessage)
Passes: SmallEngine smallEngine, BasePlayer player
WorksReturnBehavior: ExitWhenValidTypeArgumentBehavior: UseArgumentString (this, a0.player)Assembly-CSharp.dll
Where it is called (this branch's game code)
[RPC_Server]
[RPC_Server.IsVisible(3f)]
[RPC_Server.CallsPerSecond(5uL)]
public void TurnOn(RPCMessage msg)
{
if (Interface.CallHook("OnEngineStart", this, msg.player) != null)
{
return;
}
if (fuelSystem.HasFuel() && PlayerBoat.IsPlayerAuthedOnChildEntity(this, msg.player, authedIfNoPrivOrLock: true))
{
TurnOn();
}
}Injection point 2
Rust.opj (Oxide)
void MotorRowboat.EngineToggle(bool)
Passes: object arg0
WorksReturnBehavior: CustomAssembly-CSharp.dll
Where it is called (this branch's game code)
public void EngineToggle(bool wantsOn)
{
if (fuelSystem.HasFuel(forceCheck: true))
{
object result = Interface.CallHook("OnEngineStart", this.GetDriver());
// … проверка результата (Modify-хук, см. Rust.opj)
using (FlagsUpdateScope flagsUpdateScope = StartSetFlags(FlagsUpdateMode.SendNetworkUpdate))
{
flagsUpdateScope.Set(Flags.On, wantsOn);
}
if (wantsOn)
{
rigidBody.WakeUp();
// …Injection point 3
Rust.opj (Oxide)
void VehicleEngineController`1.TryStartEngine(BasePlayer)
Passes: TOwner owner, BasePlayer player
WorksReturnBehavior: CustomAssembly-CSharp.dll
Where it is called (this branch's game code)
// …
{
return;
}
if (!CanRunEngine())
{
owner.OnEngineStartFailed();
return;
}
object result = Interface.CallHook("OnEngineStart", this.owner, player);
// … проверка результата (Modify-хук, см. Rust.opj)
using (BaseEntity.FlagsUpdateScope flagsUpdateScope = owner.StartSetFlags(BaseEntity.FlagsUpdateMode.SendNetworkUpdate))
{
flagsUpdateScope.Set(engineStartingFlag, b: true);
flagsUpdateScope.Set(BaseEntity.Flags.On, b: false);
}
owner.Invoke(FinishStartingEngine, engineStartupTime);
}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.