public void AddKey(KeyInputController input, BlockBehaviour extLogic, MExtKey key)
 {
     foreach (var kk in key.UpdatedKeyCodes)
     {
         input.AddMKey(extLogic, key, (KeyCode)kk.Value);
     }
 }
Beispiel #2
0
        public IKeyInputController CreateKeyboardController(IKeyboardPlugin plugin, ISession session)
        {
            var controller = new KeyInputController(plugin, session);

            controller.Initialize();
            return(controller);
        }
Beispiel #3
0
        private void Register(KeyInputController input)
        {
            MActivateKey.SetKeycodes(input, machineHandler.IsAnyEmulating);
            MEmulateKey.SetKeycodes(input, machineHandler.IsAnyEmulating);

            machineHandler.AddExtKeyEmulator(MEmulateKey);
            machineHandler.AddKey(input, this, MEmulateKey);
        }
Beispiel #4
0
 private void UnregisterCpu()
 {
     InputController = null;
     foreach (var key in PIO.Values)
     {
         key.ResetKeycodes();
     }
 }
 public void Init()
 {
     anim = GetComponentInChildren <Animator>();
     pool = ObjectPool.instance;
     keyInputController = KeyInputController.instance;
     keyInputController.onShootPressed += StartAttack;
     keyInputController.onShootHeld    += Shoot;
     keyInputController.onShootUp      += StopAttack;
 }
Beispiel #6
0
        private void RegisterExtLogicGate(KeyInputController input)
        {
            MAKey.SetKeycodes(input, machineHandler.IsAnyEmulating);
            MBKey.SetKeycodes(input, machineHandler.IsAnyEmulating);
            MEmulateKey.SetKeycodes(input, machineHandler.IsAnyEmulating);

            machineHandler.AddExtKeyEmulator(MEmulateKey);
            machineHandler.AddUpdatedKey(input, this, MEmulateKey);
        }
Beispiel #7
0
 public override void Start(PlayerMachine machine)
 {
     KeyInputController = machine.InternalObject.GetComponent <KeyInputController>();
     foreach (var block in machine.SimulationBlocks)
     {
         NameIndex.Add(block, block.Prefab.Name);
         GuidIndex.Add(block, block.Guid.ToString());
         ClassNameIndex.Add(block, BlockWrapper.GetClassNames(block));
     }
 }
Beispiel #8
0
 public void SetKeycodes(KeyInputController input, Func <MappedKeyItem, float> machineEmu)
 {
     try
     {
         InputController  = input;
         MachineEmulating = machineEmu;
         //foreach (var kp in UpdatedKeyCodes)
         //    AddOrReplaceKey(kp.Key, (KeyCode)kp.Value);
         InvokeKeysChanged();
     }
     finally
     {
     }
 }
 public void Stop()
 {
     KeyInput = null;
     foreach (var block in machine.SimulationBlocks)
     {
         if (CpuBlocks.ContainsKey(block))
         {
             ModContext.Unregisters[typeof(CpuBlock)](block);
         }
         else if (ModContext.Unregisters.ContainsKey(block.GetType()))
         {
             ModContext.Unregisters[block.GetType()](block);
         }
     }
 }
Beispiel #10
0
        public void AddUpdatedKey(KeyInputController input, BlockBehaviour extLogic, MExtKey key)
        {
            //foreach (var kk in key.UpdatedKeyCodes)
            //    input.AddMKey(extLogic, key, (KeyCode)kk.Value);

            // force add BOTH old key AND message
            key.SetUseMessage(false);
            foreach (var kk in key.ResolveKeys().Where(x => x.IsKey))
            {
                input.AddMKey(extLogic, key, kk.Key);
            }
            key.SetUseMessage(true);
            input.AddMKey(extLogic, key, KeyCode.None);
            key.RestoreSavedUseMessage();
        }
Beispiel #11
0
 private void RegisterCpu(KeyInputController input)
 {
     InputController = input;
     foreach (var key in PIO.Values)
     {
         foreach (var kc in key.ResolveKeys().Where(x => x.IsKey).Select(x => x.Key))
         {
             input.AddMKey(BlockBehaviour, key, kc);
             input.Add(kc);
         }
         key.SetInputController(input);
         key.SetKeycodes(input, machineHandler.IsAnyEmulating);
         machineHandler.AddExtKeyEmulator(key);
         machineHandler.AddUpdatedKey(input, BlockBehaviour, key);
     }
 }
Beispiel #12
0
 public void SetKeycodes(KeyInputController input, Func <uint, float> machineEmu)
 {
     registeringKeys = true;
     try
     {
         InputController  = input;
         MachineEmulating = machineEmu;
         foreach (var kp in UpdatedKeyCodes)
         {
             AddOrReplaceKey(kp.Key, (KeyCode)kp.Value);
         }
         InvokeKeysChanged();
     }
     finally
     {
         registeringKeys = false;
     }
 }
        public void Start()
        {
            AllGates = new Dictionary <uint, HashSet <MExtKey> >();
            AllKeys  = GetKeys(machine.SimulationBlocks).SelectMany(x => GetMKeys(x.key).Select(y => new { x.key, code = y }))
                       .GroupBy(x => x.code, x => x.key).ToDictionary(x => x.Key, x => new HashSet <MKey>(x));
            KeyInput = machine.GetComponent <KeyInputController>();
            foreach (var block in machine.SimulationBlocks)
            {
                ModContext.PlaceAdditionScripts(block);

                // On simulation start Besiege collects key codes from all keys and really maps them to KeyCode as dict's key
                // This crashes block loading, because extended IDs cannot be serialized to KeyCode
                // But AFAIK this is the only place in game where KeyCode really needs to be a KeyCode, not just Int
                // So we set Int values after simulation start and clear them on end
                if (CpuBlocks.ContainsKey(block))
                {
                    ModContext.Registers[typeof(CpuBlock)](block, KeyInput); // CpuBlock is a special case, because it is not BlockBehavior
                }
                else if (ModContext.Registers.ContainsKey(block.GetType()))
                {
                    ModContext.Registers[block.GetType()](block, KeyInput);
                }
            }
        }
Beispiel #14
0
    public void Init(Inventory inventory, float moveSpeed)
    {
        speed            = moveSpeed;
        areaController   = AreaController.instance;
        areaWidth        = areaController.active_area.Width - 1;
        areaHeight       = areaController.active_area.Height - 1;
        mouse_controller = MouseInputController.instance;
        mouse_controller.onRightClick += TryInteract;
        key_controller = KeyInputController.instance;
        key_controller.onKeyPressed          += OnMove;
        key_controller.onKeyHeld             += Move;
        key_controller.onKeyUp               += OnMoveStop;
        key_controller.onInteractBttnPressed += TryInteract;

        SetAnimParams(0, 0);
        Camera_Controller.instance.SetTargetAndLock(this.transform, 0, areaWidth, 0, areaHeight);
        OnChangeArea();
        heroInventory     = inventory;
        radiation_tracker = new RadiationTracker(heroInventory);
        InventoryUI.instance.Init(heroInventory, radiation_tracker);
        move_x = transform.position.x;
        move_y = transform.position.y;
        GetComponent <HeroAttackController>().Init();
    }
Beispiel #15
0
 void Awake()
 {
     instance = this;
 }
Beispiel #16
0
        public static void StartChat(int roomNumber)
        {
            isChatOn = true;

            int    chatTimer = 0;
            string message   = String.Empty;

            //KeyInputController keyInputControl = new KeyInputController(input);
            KeyInputController.command = new StringBuilder("");
            KeyInputController.StartReading();
            ReceiveMessageController rcvMessageControl = new ReceiveMessageController();



            while (isChatOn)
            {
                //Set timer for redraw screen
                if (chatTimer <= 0)
                {
                    chatTimer = 1000;            //Get update every 1 sec
                }
                else
                {
                    chatTimer -= 200;
                }

                rcvMessageControl.StartRcvThread();
                //receiveListen
                //Logic for redraw:
                //If input was made OR chat timer cycled => redraw screen
                if (KeyInputController.wasCharWritten == true || chatTimer == 1000)
                {
                    message = KeyInputController.inputString;

                    if (KeyInputController.wasStringSended)
                    {
                        message = KeyInputController.inputString;
                        SendMessage();
                        //rcvMessageControl.KeepMessage(ReceiveMessage(s));
                        KeyInputController.wasStringSended = false;
                    }

                    //Need to lock?
                    KeyInputController.wasCharWritten = false;

                    //Otherwise Redraw
                    Console.Clear();
                    //UI Top
                    Console.WriteLine("==========================================================");
                    Console.WriteLine("================Welcome to the POCKETCHAT!!===============");
                    Console.WriteLine("================" + "Room #" + roomNumber + "===============");
                    Console.WriteLine("==========================================================");

                    rcvMessageControl.PrintMessages();

                    Console.WriteLine("==========================================================");
                    Console.WriteLine("Enter 'LEAVE' to leave room.");
                    Console.WriteLine();
                    Console.Write("> " + KeyInputController.command.ToString());
                }

                Thread.Sleep(100);

                if (KeyInputController.wasStopChatted)
                {
                    isChatOn = false;
                }

                //Time to check for new input
            }
        }