public override void DeregisterPart(PartConsole console)
 {
     if (ActionDictionary.ContainsKey(console))
     {
         ActionDictionary.Remove(console);
     }
 }
    private void OnEnable()
    {
        _partConsole    = (PartConsole)target;
        _lastPartTarget = _partTarget;

        UpdatePropertyList();
    }
    //public FloatEvent ActivateFloat = new FloatEvent();

    public void RegisterAction(PartConsole console, Action <float> action)
    {
        //TODO: Add hard assert once in Hyperfusion
        if (ActionDictionary.ContainsKey(console) && ActionDictionary[console].Contains(action))
        {
            print("Adding duplicate action to " + name + " from " + console.name + ".");
            return;
        }

        //If we don't have a list setup for that console, add one.
        if (!ActionDictionary.ContainsKey(console))
        {
            ActionDictionary.Add(console, new List <Action <float> >());
        }

        ActionDictionary[console].Add(action);
    }
 public abstract void DeregisterPart(PartConsole console);
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (_partTarget != _lastPartTarget)
        {
            _partConsole.ClearControlActionsByPart();
            UpdatePropertyList();
        }

        bool updateruntimebindings = false; //If true, will call BindToReflectedProperties() at the end of the method

        //Display properties
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Display Properties", EditorStyles.boldLabel);
        for (int i = 0; i < _partConsole.DisplayBindings.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(_partConsole.DisplayBindings[i].PropertyName);

            DisplayPropBinding tempbinding = new DisplayPropBinding
            {
                PropertyName       = _partConsole.DisplayBindings[i].PropertyName,
                Display            = EditorGUILayout.ObjectField(_partConsole.DisplayBindings[i].Display, PartConsole.GetDisplayType(_partConsole.DisplayBindings[i].PropertyTypeString), true) as ConsoleDisplay,
                PropertyTypeString = _partConsole.DisplayBindings[i].PropertyTypeString
            };
            EditorGUILayout.EndHorizontal();

            if (tempbinding.Display != _partConsole.DisplayBindings[i].Display)
            {
                _partConsole.DisplayBindings[i] = tempbinding;
                if (Application.isPlaying)
                {
                    //_partConsole.BindToReflectedProperties();
                    updateruntimebindings = true;
                }
            }
        }
        ;

        //Control properties
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Control Properties", EditorStyles.boldLabel);
        for (int i = 0; i < _partConsole.ControlBindings.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(_partConsole.ControlBindings[i].PropertyName);

            ControlPropBinding tempbinding = new ControlPropBinding
            {
                PropertyName       = _partConsole.ControlBindings[i].PropertyName,
                Control            = EditorGUILayout.ObjectField(_partConsole.ControlBindings[i].Control, PartConsole.GetControlType(_partConsole.ControlBindings[i].PropertyTypeString), true) as ConsoleControl,
                PropertyTypeString = _partConsole.ControlBindings[i].PropertyTypeString
            };

            EditorGUILayout.EndHorizontal();

            if (tempbinding.Control != _partConsole.ControlBindings[i].Control)
            {
                if (_partConsole.ControlBindings[i].Control != null)
                {
                    _partConsole.ControlBindings[i].Control.DeregisterPart(_partConsole);
                }
                _partConsole.ControlBindings[i] = tempbinding;
                if (Application.isPlaying)
                {
                    updateruntimebindings = true;
                }
            }
        }


        serializedObject.ApplyModifiedProperties();
        if (updateruntimebindings)
        {
            _partConsole.ClearControlActionsByPart();
            _partConsole.BindToReflectedProperties();
        }
    }