Exemplo n.º 1
0
        private void gameEvents_UpdateTick(object sender, EventArgs e)
        {
            //if last command is not finished, update it
            if (m_curCmd != null && !m_curCmd.isFinish)
            {
                m_curCmd.update();
                return;
            }

            //try to see if we can invoke new command by last pressed but not released button
            if (StardewWrap.isPlayerBusy() || m_lastActionButtion == SButton.None)
            {
                return;
            }
            CmdCfg cfg = findCmdCfg(m_lastActionButtion);

            if (cfg == null)
            {
                return;
            }
            m_lastActionButtion = SButton.None;
            m_cmdcfg            = cfg;
            m_curCmd            = Command.create(m_cmdcfg.cmd);
            if (m_curCmd == null)
            {
                return;
            }
            m_curCmd.exec(m_cmdcfg.par);
        }
Exemplo n.º 2
0
        /*********
        ** Private methods
        *********/
        /// <summary>The method invoked when the player presses a controller, keyboard, or mouse button.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void inputEvents_ButtonPressed(object sender, EventArgsInput e)
        {
#if DEBUG
            this.Monitor.Log($"Pressed {e.Button}.");
#endif
            //only when player is ready shall we start process button event
            if (!StardewWrap.isPlayerReady())
            {
                return;
            }

            //if current key is modify key, mark the key
            if (isModifyKey(e.Button))
            {
                m_modify = e.Button;
                e.SuppressButton();
                return;
            }
            //not modify key. Now check if the key combination is in the config
            CmdCfg cfg = findCmdCfg(e.Button);
            if (cfg == null)
            {
                return;
            }
            //old command must finished before new command could be created, but record the key to see if we can invoke it later
            if ((m_curCmd != null && !m_curCmd.isFinish) || StardewWrap.isPlayerBusy())
            {
                m_lastActionButtion = e.Button;
                return;
            }
            //now create the command
            m_cmdcfg = cfg;
            m_curCmd = Command.create(m_cmdcfg.cmd);
            if (m_curCmd == null)
            {
                m_cmdcfg = null;
                return;
            }
            //command is there so just overide and execute it
            m_curCmd.exec(m_cmdcfg.par);
            e.SuppressButton();
        }
Exemplo n.º 3
0
 /// <summary>Check if new command is good to go.</summary>
 public bool canTriggerNew()
 {
     return(!((m_curCmd != null && !m_curCmd.isFinish) || StardewWrap.isPlayerBusy()));
 }