示例#1
0
    /*
    public void Fire(int index)
    {
        if (0 <= index && index < queue.Count)
        {
            Fire(queue[index]);
        }
    }
    */

    protected virtual bool Fire(Automaton owner, Command command)
    {
        if (command != null)
        {
            if (command.IsFirable(owner))
            {
                if (pipe != null)
                {
                    pipe.TryAdd(command);
                    return true;
                }

                if (command is OnDemandCommand && !(command as OnDemandCommand).HasFirableTarget(owner))
                {
                    return true;
                }

                Action action = command.GenerateAction(owner.Stat);
                if (action != null)
                {
                    owner.Fire(action, null);
                    command.StartCooltime();
                }
                return true;
            }
        }
        return false;
    }