Exemplo n.º 1
0
    public void OnServerEndProgress(EndProgressInfo info)
    {
        used = true;
        //only interrupt other progress bars if we were completed
        if (info.WasCompleted && progressActionConfig.InterruptsOverlapping)
        {
            //interrupt other progress bars of the same action type on the same location
            var existingBars = UIManager.Instance.ProgressBars
                               .Where(pb => ProgressBar != null && pb != null && pb != ProgressBar)
                               .Where(pb => pb.ServerProgressAction is StandardProgressAction)
                               .Where(pb =>
                                      ((StandardProgressAction)pb.ServerProgressAction).progressActionConfig.StandardProgressActionType == progressActionConfig.StandardProgressActionType)
                               .Where(pb => pb.transform.parent == ProgressBar.transform.parent)
                               .Where(pb => Vector3.Distance(pb.transform.localPosition, startProgressInfo.Target.TargetLocalPosition) < 0.1)
                               .ToList();

            foreach (var existingBar in existingBars)
            {
                Logger.LogTraceFormat("Server interrupting progress bar {0} because progress bar {1} finished " +
                                      "on same tile", Category.ProgressAction, existingBar.ID, ProgressBar.ID);
                existingBar.ServerInterruptProgress();
            }
        }

        //unregister from all hooks
        eventRegistry.UnregisterAll();

        if (info.WasCompleted)
        {
            onCompletion?.Invoke();
        }
    }
Exemplo n.º 2
0
    public void OnServerEndProgress(EndProgressInfo info)
    {
        used = true;
        if (progressActionConfig.InterruptsOverlapping)
        {
            //interrupt other progress bars of the same action type on the same location
            var existingBars = UIManager.Instance.ProgressBars
                               .Where(pb => pb != startProgressInfo.ProgressBar && pb.ServerProgressAction is StandardProgressAction)
                               .Where(pb =>
                                      ((StandardProgressAction)pb.ServerProgressAction).progressActionConfig.StandardProgressActionType == progressActionConfig.StandardProgressActionType)
                               .Where(pb => pb.transform.parent == startProgressInfo.ProgressBar.transform.parent)
                               .Where(pb => Vector3.Distance(pb.transform.localPosition, startProgressInfo.Target.TargetLocalPosition) < 0.1)
                               .ToList();

            foreach (var existingBar in existingBars)
            {
                existingBar.ServerInterruptProgress();
            }
        }

        UnregisterHooks();
        if (info.WasCompleted)
        {
            onCompletion?.Invoke();
        }
    }