Override/extend entity behaviour?
Hi,

How could I override or extend the default behaviour of an entity ?
Let's take a BaseOven as an example:

// BaseOven
// Token: 0x0600082D RID: 2093 RVA: 0x0002BC74 File Offset: 0x00029E74
public void Cook()
{
	global::Item item = this.FindBurnable();
	if (item == null)
	{
		this.StopCooking();
		return;
	}
	base.inventory.OnCycle(0.5f);
	global::BaseEntity slot = base.GetSlot(global::BaseEntity.Slot.FireMod);
	if (slot)
	{
		slot.SendMessage("Cook", 0.5f, SendMessageOptions.DontRequireReceiver);
	}
	global::ItemModBurnable component = item.info.GetComponent<global::ItemModBurnable>();
	item.fuel -= 0.5f * (this.cookingTemperature / 200f);
	if (!item.HasFlag(global::Item.Flag.OnFire))
	{
		item.SetFlag(global::Item.Flag.OnFire, true);
		item.MarkDirty();
	}
	if (item.fuel <= 0f)
	{
		this.ConsumeFuel(item, component);
	}
}​

I would like to write a custom cook() method so I can add additional functionality to it.
How can this be accomplished ?
I mean I guess if there was prehook then you could cancel the default behaviour and do your own behaviour but it doesn't look like any exist in that method.
Not sure if Harmony is recommended to be used, but you could possibly patch this method, not sure if you can do this with a plugin, but with an extension sure. 
It wouldn't be hard to add a hook to this method, if it's something you're interested in I can add one.
I saw other doing a custom component and then attaching it to a BaseOven entity and wait for the OnOvenToggle event canceling it's default behaviour (return false) and trigerring instead their custom component.

But I was wondering if there was a better way to accomplish this.
This "workaround" is only possible when you have a behaviour which can be "side intercepted" by an existing hook.. but if there is no hook ?
I'll look into adding a new hook that might help you. It will probably take a while for the pull request to be merged, maybe until next oxide update.
The new hook must be defined at Rust.opj..
Indeed I need your help, 0x89A, in order to understand the patching schema ! :-)

Merged post

May I suggest the following hooks for the BaseOven class:
- OnOvenCook
- OnOvenConsumeFuel