protected override void Initialize() { Controller = GetComponentInParent <IAgentController>(); Dynamics = GetComponentInParent <IVehicleDynamics>(); Actions = GetComponentInParent <VehicleActions>(); Debug.Assert(Dynamics != null); Debug.Assert(SimulatorManager.Instance != null); Controls = new WheelControlSensorInput(); Controls.VehicleWheel.Accel.performed += AccelPerformed; Controls.VehicleWheel.Accel.canceled += AccelCanceled; Controls.VehicleWheel.Brake.performed += BrakePerformed; Controls.VehicleWheel.Brake.canceled += BrakeCanceled; Controls.VehicleWheel.Steer.performed += SteerPerformed; Controls.VehicleWheel.ButtonA.performed += ButtonA; Controls.VehicleWheel.ButtonB.performed += ButtonB; Controls.VehicleWheel.ButtonX.performed += ButtonX; Controls.VehicleWheel.ButtonY.performed += ButtonY; Controls.VehicleWheel.ButtonRB.performed += ButtonRB; Controls.VehicleWheel.ButtonLB.performed += ButtonLB; Controls.VehicleWheel.ButtonSelect.performed += ButtonSelect; Controls.VehicleWheel.ButtonStart.performed += ButtonStart; Controls.VehicleWheel.ButtonRSB.performed += ButtonRSB; Controls.VehicleWheel.ButtonLSB.performed += ButtonLSB; Controls.VehicleWheel.ButtonCenter.performed += ButtonCenter; Controls.VehicleWheel.DPad.performed += DPad; Controls.Enable(); }
protected override void Deinitialize() { if (Controls != null) { Controls.Disable(); Controls.Dispose(); Controls = null; } }