예제 #1
0
        /* Custom method to add keys to a ControlGroup. We 'hijack' the control group lookup function
         * that will also save the name of they key in the list for us
         */
        private static void AddKey(string assignmentName,
                                   KeyCode keyCode,
                                   ControlsGroup controlsGroup,
                                   bool hidden = false
                                   )
        {
            // This is just because of the accessibility to change the assigned name, we use
            // the control group for that.
            controlsGroup.Name = assignmentName;
            KeyManager.AddGroupLookup(controlsGroup);

            // Now Create the key, add its looup string name, and save it in the allkeys list, to ensure
            // is being saved/load by the game config initialisation function.
            KeyItem keyItem = new KeyItem(assignmentName, keyCode, hidden);

            KeyManager.KeyItemLookup.Add(assignmentName, keyItem);
            KeyManager.AllKeys.Add(keyItem);
        }
예제 #2
0
        static void Postfix()
        {
            // We need to add a custom control group for the keys to be attached to, and create
            // the Lookout reference.
            UnityEngine.Debug.Log("Adding custom Shortcuts group");
            ControlsGroup controlsGroup1 = new ControlsGroup("ShortCuts");

            KeyManager.AddGroupLookup(controlsGroup1);

            // We will add the custom keys with default values to the KeyItem list using our new
            // created control group, however this method -due to accesibility of the class method-
            // will change the current ControlGroup name.
            ShortcutInjectBindingGroup.AddKey("Backpack 2", KeyCode.Keypad7, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Backpack 3", KeyCode.Keypad8, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Backpack 4", KeyCode.Keypad9, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Backpack 5", KeyCode.Keypad4, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Uniform 1", KeyCode.None, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Uniform 2", KeyCode.None, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Toolbelt 1", KeyCode.Keypad5, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Toolbelt 2", KeyCode.Keypad6, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Toolbelt 3", KeyCode.None, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Toolbelt 4", KeyCode.None, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Grinder", KeyCode.None, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Welder", KeyCode.None, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Hand Drill", KeyCode.None, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Wrench", KeyCode.None, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Cable Cutters", KeyCode.None, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Screwdriver", KeyCode.None, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Crowbar", KeyCode.None, controlsGroup1, false);
            ShortcutInjectBindingGroup.AddKey("Authoring tool", KeyCode.None, controlsGroup1, false);

            // TODO ADD other tools
            //ShortcutInjectBindingGroup.AddKey("Weapon", KeyCode.None, controlsGroup1, false);
            //ShortcutInjectBindingGroup.AddKey("Water", KeyCode.None, controlsGroup1, false);


            // We need to restore the name of the control group back to its correct string
            controlsGroup1.Name = "ShortCuts";
        }