Implemented OnOvenToggle hook (Rust)

Discussion in 'Feature Suggestions' started by Jake Rich, Oct 30, 2016.

  1. Jake Rich

    Jake Rich Plugin Developer

    Code (Text):

    {
              "Type": "Simple",
              "Hook": {
                "InjectionIndex": 4,
                "ReturnBehavior": 1,
                "ArgumentBehavior": 4,
                "ArgumentString": "this, l0, a0.player",
                "HookTypeName": "Simple",
                "Name": "OnFurnaceSwitch",
                "HookName": "OnFurnaceSwitch",
                "AssemblyName": "Assembly-CSharp.dll",
                "TypeName": "BaseOven",
                "Flagged": false,
                "Signature": {
                  "Exposure": 0,
                  "Name": "SVSwitch",
                  "ReturnType": "System.Void",
                  "Parameters": [
                    "BaseEntity/RPCMessage"
                  ]
                },
                "MSILHash": "7ZDvGZMcDhVbIFBKOVdE8Sq1ar5NdUwgFz8+K/BbpZU=",
                "BaseHookName": null,
                "HookCategory": "Item"
              }
    }
    I'm not sure why, but a lot of the Hashes in the Rust.obj file change when I try and make a pull request. Here's the c# code. (BaseOven.SVSwitch)

    Code (Text):

    [BaseEntity.RPC_Server, BaseEntity.RPC_Server.MaxDistance(4f)]
    private void SVSwitch(BaseEntity.RPCMessage msg)
    {
        bool flag = msg.read.Bit();
        if (Interface.CallHook("OnFurnaceSwitch", new object[]
        {
            this,
            flag,
            msg.player
        }) != null)
        {
            return;
        }
        if (flag == base.IsOn())
        {
            return;
        }
        if (flag)
        {
            this.StartCooking();
        }
        else
        {
            this.StopCooking();
        }
    }

     
     
    Jakkee likes this.
  2. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    I don't see the need for the l0 argument, you can get it from BaseOven/this. Likely going with OnOvenToggle though, as it covers campfires too.
     
    Norn likes this.
  3. Jake Rich

    Jake Rich Plugin Developer

    Right, because it will always toggle to the opposite state it currently is, so the target state will be !BaseOven.IsOn().
     
  4. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    That's one way to check, sure. I was thinking of just BaseOven and BasePlayer as the arguments too, as the 2nd arg you had you can get from BaseOven I believe.