示例#1
0
    // 执行命令
    public new void pushCommand(Command cmd, CommandReceiver cmdReceiver)
    {
        if (cmd == null)
        {
            logError("cmd is null! receiver : " + (cmdReceiver != null ? cmdReceiver.getName() : ""));
            return;
        }
        if (cmdReceiver == null)
        {
            logError("receiver is null! cmd : " + (cmd != null ? cmd.getType().ToString() : ""));
            return;
        }
        if (!cmd.isValid())
        {
            logError("cmd is invalid! make sure create cmd use CommandSystem.newCmd! pushCommand cmd type : "
                     + cmd.GetType().ToString() + "cmd id : " + cmd.mAssignID);
            return;
        }
        if (cmd.isDelayCommand())
        {
            logError("cmd is a delay cmd! can not use pushCommand!" + cmd.mAssignID + ", " + cmd.showDebugInfo());
            return;
        }
        cmd.setReceiver(cmdReceiver);
        if (cmd.getShowDebugInfo())
        {
            logConsole("CommandSystem : " + cmd.mAssignID + ", " + cmd.showDebugInfo() + ", receiver : " + cmdReceiver.getName());
        }
        cmdReceiver.receiveCommand(cmd);

        // 销毁回收命令
        mCommandPool.destroyCmd(cmd);
    }
示例#2
0
    // delayExecute是命令延时执行的时间,默认为0,只有new出来的命令才能延时执行
    // 子线程中发出的命令必须是延时执行的命令!
    public new void pushDelayCommand(Command cmd, CommandReceiver cmdReceiver, float delayExecute, IDelayCmdWatcher watcher)
    {
        // 如果命令系统已经销毁了,则不能再发送命令
        if (mDestroy)
        {
            return;
        }
        if (cmd == null)
        {
            logError("cmd is null! receiver : " + (cmdReceiver != null ? cmdReceiver.getName() : EMPTY));
            return;
        }
        if (cmdReceiver == null)
        {
            logError("receiver is null! cmd : " + (cmd != null ? cmd.GetType().ToString() : EMPTY));
            return;
        }
        if (cmd.isDestroy())
        {
            logError("cmd is invalid! make sure create cmd use CommandSystem.newCmd! pushDelayCommand cmd type : "
                     + Typeof(cmd) + "cmd id : " + cmd.getAssignID());
            return;
        }
        if (!cmd.isDelayCommand())
        {
            logError("cmd is not a delay command, Command : " + cmd.getAssignID() + ", " + cmd.showDebugInfo());
            return;
        }
        clampMin(ref delayExecute);
        if (cmd.isShowDebugInfo())
        {
#if UNITY_EDITOR || DEVELOPMENT_BUILD
            log("CMD : delay cmd : " + cmd.getAssignID() + ", " + delayExecute + ", info : " + cmd.showDebugInfo() + ", receiver : " + cmdReceiver.getName(), LOG_LEVEL.NORMAL);
#endif
        }
        cmd.setDelayTime(delayExecute);
        cmd.setReceiver(cmdReceiver);
        mBufferLock.waitForUnlock();
        mCommandBufferInput.Add(cmd);
        mBufferLock.unlock();
        watcher?.addDelayCmd(cmd);
    }
示例#3
0
    // delayExecute是命令延时执行的时间,默认为0,只有new出来的命令才能延时执行
    // 子线程中发出的命令必须是延时执行的命令!
    public new void pushDelayCommand(Command cmd, CommandReceiver cmdReceiver, float delayExecute = 0.001f)
    {
        // 如果命令系统已经销毁了,则不能再发送命令
        if (mSystemDestroy)
        {
            return;
        }
        if (cmd == null)
        {
            logError("cmd is null! receiver : " + (cmdReceiver != null ? cmdReceiver.getName() : ""));
            return;
        }
        if (cmdReceiver == null)
        {
            logError("receiver is null! cmd : " + (cmd != null ? cmd.getType().ToString() : ""));
            return;
        }
        if (!cmd.isValid())
        {
            logError("cmd is invalid! make sure create cmd use CommandSystem.newCmd! pushDelayCommand cmd type : "
                     + cmd.GetType().ToString() + "cmd id : " + cmd.mAssignID);
            return;
        }
        if (!cmd.isDelayCommand())
        {
            logError("cmd is not a delay command, Command : " + cmd.mAssignID + ", " + cmd.showDebugInfo());
            return;
        }
        if (delayExecute < 0.0f)
        {
            delayExecute = 0.0f;
        }
        if (cmd.getShowDebugInfo())
        {
            logInfo("CommandSystem : delay cmd : " + cmd.mAssignID + ", " + delayExecute + ", info : " + cmd.showDebugInfo() + ", receiver : " + cmdReceiver.getName(), LOG_LEVEL.LL_NORMAL);
        }
        DelayCommand delayCommand = new DelayCommand(delayExecute, cmd, cmdReceiver);

        mBufferLock.waitForUnlock();
        mCommandBufferInput.Add(delayCommand);
        mBufferLock.unlock();
    }
示例#4
0
    // 执行命令
    public new void pushCommand(Command cmd, CommandReceiver cmdReceiver)
    {
        // 如果命令系统已经销毁了,则不能再发送命令
        if (mDestroy)
        {
            return;
        }
        if (cmd == null)
        {
            logError("cmd is null! receiver : " + (cmdReceiver != null ? cmdReceiver.getName() : EMPTY));
            return;
        }
        if (cmdReceiver == null)
        {
            logError("receiver is null! cmd : " + (cmd != null ? cmd.GetType().ToString() : EMPTY));
            return;
        }
        if (cmd.isDestroy())
        {
            logError("cmd is invalid! make sure create cmd use CommandSystem.newCmd! pushCommand cmd type : "
                     + Typeof(cmd) + "cmd id : " + cmd.getAssignID());
            return;
        }
        if (cmd.isDelayCommand())
        {
            logError("cmd is a delay cmd! can not use pushCommand!" + cmd.getAssignID() + ", " + cmd.showDebugInfo());
            return;
        }
        cmd.setReceiver(cmdReceiver);
        if (cmd.isShowDebugInfo())
        {
#if UNITY_EDITOR || DEVELOPMENT_BUILD
            log("CMD : " + cmd.getAssignID() + ", " + cmd.showDebugInfo() + ", receiver : " + cmdReceiver.getName(), LOG_LEVEL.NORMAL);
#endif
        }
        cmdReceiver.receiveCommand(cmd);
        // 销毁回收命令
        mClassPoolThread?.destroyClass(cmd);
    }
示例#5
0
 // 执行命令
 public new void pushCommand(Command cmd, CommandReceiver cmdReceiver)
 {
     // 如果命令系统已经销毁了,则不能再发送命令
     if (mDestroy)
     {
         return;
     }
     if (cmd == null)
     {
         logError("cmd is null! receiver : " + (cmdReceiver != null ? cmdReceiver.getName() : EMPTY_STRING));
         return;
     }
     if (cmdReceiver == null)
     {
         logError("receiver is null! cmd : " + (cmd != null ? cmd.getType().ToString() : EMPTY_STRING));
         return;
     }
     if (!cmd.isValid())
     {
         logError("cmd is invalid! make sure create cmd use CommandSystem.newCmd! pushCommand cmd type : "
                  + cmd.GetType().ToString() + "cmd id : " + cmd.mAssignID);
         return;
     }
     if (cmd.isDelayCommand())
     {
         logError("cmd is a delay cmd! can not use pushCommand!" + cmd.mAssignID + ", " + cmd.showDebugInfo());
         return;
     }
     cmd.setReceiver(cmdReceiver);
     if (cmd.isShowDebugInfo())
     {
         logInfo("CommandSystem : " + cmd.mAssignID + ", " + cmd.showDebugInfo() + ", receiver : " + cmdReceiver.getName(), LOG_LEVEL.LL_NORMAL);
     }
     cmdReceiver.receiveCommand(cmd);
     // 销毁回收命令
     mCommandPool?.destroyCmd(cmd);
 }
示例#6
0
    // delayExecute是命令延时执行的时间,默认为0,只有new出来的命令才能延时执行
    // 子线程中发出的命令必须是延时执行的命令!
    public void pushDelayCommand(Command cmd, CommandReceiver cmdReceiver, float delayExecute = 0.001f)
    {
        if (cmd == null || cmdReceiver == null)
        {
            UnityUtility.logError("cmd or receiver is null!");
            return;
        }
        if (!cmd.isValid())
        {
            UnityUtility.logError("cmd is invalid! make sure create cmd use CommandSystem.newCmd! pushDelayCommand cmd type : "
                                  + cmd.GetType().ToString() + "cmd id : " + cmd.mAssignID);
            return;
        }
        if (!cmd.isDelayCommand())
        {
            UnityUtility.logError("cmd is not a delay command, Command : " + cmd.mAssignID + ", " + cmd.showDebugInfo());
            return;
        }
        if (delayExecute < 0.0f)
        {
            delayExecute = 0.0f;
        }
        if (cmd.getShowDebugInfo())
        {
            UnityUtility.logInfo("CommandSystem : delay cmd : " + cmd.mAssignID + ", " + delayExecute + ", info : " + cmd.showDebugInfo() + ", receiver : " + cmdReceiver.getName(), LOG_LEVEL.LL_NORMAL);
        }
        DelayCommand delayCommand = new DelayCommand(delayExecute, cmd, cmdReceiver);

        mBufferLock.waitForUnlock(LOCK_TYPE.LT_READ);
        mCommandBufferInput.Add(delayCommand);
        mBufferLock.unlock(LOCK_TYPE.LT_READ);
    }
示例#7
0
    // 执行命令
    public void pushCommand(Command cmd, CommandReceiver cmdReceiver)
    {
        if (cmd == null || cmdReceiver == null)
        {
            UnityUtility.logError("cmd or receiver is null!");
            return;
        }
        if (!cmd.isValid())
        {
            UnityUtility.logError("cmd is invalid! make sure create cmd use CommandSystem.newCmd! pushCommand cmd type : "
                                  + cmd.GetType().ToString() + "cmd id : " + cmd.mAssignID);
            return;
        }
        if (cmd.isDelayCommand())
        {
            UnityUtility.logError("cmd is a delay cmd! can not use pushCommand!" + cmd.mAssignID + ", " + cmd.showDebugInfo());
            return;
        }
        cmd.setReceiver(cmdReceiver);
        if (cmd.getShowDebugInfo())
        {
            UnityUtility.logInfo("CommandSystem : " + cmd.mAssignID + ", " + cmd.showDebugInfo() + ", receiver : " + cmdReceiver.getName(), LOG_LEVEL.LL_NORMAL);
        }
        cmdReceiver.receiveCommand(cmd);

        // 销毁回收命令
        mCommandPool.destroyCmd(cmd);
    }
示例#8
0
    // delayExecute是命令延时执行的时间,默认为0,只有new出来的命令才能延时执行
    // 子线程中发出的命令必须是延时执行的命令!
    public void pushDelayCommand(Command cmd, CommandReceiver cmdReceiver, float delayExecute = 0.001f)
    {
        if (cmd == null || cmdReceiver == null)
        {
            UnityUtility.logError("cmd or receiver is null!");
            return;
        }
        if (!cmd.isValid())
        {
            UnityUtility.logError("cmd is invalid! make sure create cmd use CommandSystem.newCmd!");
            return;
        }
        if (!cmd.isDelayCommand())
        {
            UnityUtility.logError("cmd is not a delay command, Command : " + cmd.showDebugInfo());
            return;
        }
        if (delayExecute < 0.0f)
        {
            delayExecute = 0.0f;
        }
        if (mShowDebugInfo && cmd.getShowDebugInfo())
        {
            UnityUtility.logInfo("CommandSystem : delay cmd : " + delayExecute + ", info : " + cmd.showDebugInfo() + ", receiver : " + cmdReceiver.getName());
        }
        DelayCommand delayCommand = new DelayCommand(delayExecute, cmd, cmdReceiver);

        // 等待解锁缓冲区并锁定缓冲区
        waitAndLockBuffer();
        mCommandBufferInput.Add(delayCommand);
        // 解锁缓冲区
        unlockBuffer();
    }
示例#9
0
    //执行命令
    public void pushCommand(Command cmd, CommandReceiver cmdReceiver)
    {
        if (cmd == null || cmdReceiver == null)
        {
            UnityUtility.logError("cmd or receiver is null!");
            return;
        }
        if (!cmd.isValid())
        {
            UnityUtility.logError("cmd is invalid! make sure create cmd use CommandSystem.newCmd!");
            return;
        }
        if (cmd.isDelayCommand())
        {
            UnityUtility.logError("cmd is a delay cmd! can not use pushCommand!");
            return;
        }
        cmd.setReceiver(cmdReceiver);
        if (mShowDebugInfo && cmd.getShowDebugInfo())
        {
            UnityUtility.logInfo("CommandSystem : " + cmd.showDebugInfo() + ", receiver : " + cmdReceiver.getName());
        }
        cmdReceiver.receiveCommand(cmd);

        // 销毁回收命令
        mCommandPool.destroyCmd(cmd);
    }