﻿// Decompiled with JetBrains decompiler
// Type: DismissAllPanelsJob
// Assembly: Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 19851F1B-4780-4223-BA01-2C20F2CD781E
// Assembly location: C:\Users\CGA Computer\Desktop\LEGO Universe Stuff\LOCO Server\Unity Web Player Extractor\Saved Files\LOCO Server.unity3d_unpacked\Assembly-CSharp.dll

using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

public class DismissAllPanelsJob : Job
{
  private Action<DismissAllPanelsJob> _doneWithSuccessCallback = (Action<DismissAllPanelsJob>) (j => {});
  private Action<DismissAllPanelsJob> _doneWithFailureCallback = (Action<DismissAllPanelsJob>) (j => {});
  private string[] _exceptThesePanels;

  public DismissAllPanelsJob(string[] except, Action<DismissAllPanelsJob> doneWithSuccessCallback, Action<DismissAllPanelsJob> doneWithFailureCallback)
  {
    this._exceptThesePanels = except;
    if (doneWithSuccessCallback != null)
      this._doneWithSuccessCallback = doneWithSuccessCallback;
    if (doneWithFailureCallback == null)
      return;
    this._doneWithFailureCallback = doneWithFailureCallback;
  }

  public override void Start()
  {
    foreach (string menuName in Enumerable.Where<string>(Enumerable.Select<WBPanelBase, string>(FordPanelManager.Instance.GetActivePanels(), (Func<WBPanelBase, string>) (panel => ((Object) panel).get_name())), (Func<string, bool>) (name =>
    {
      if (this._exceptThesePanels != null)
        return !Enumerable.Contains<string>((IEnumerable<string>) this._exceptThesePanels, name);
      return true;
    })))
      JobMgr.Instance.Execute((Job) new DismissMenuJob(menuName, (Action<DismissMenuJob>) null, (Action<DismissMenuJob>) null));
    this.Done(false);
  }

  public override void Dispose()
  {
    this._doneWithSuccessCallback = (Action<DismissAllPanelsJob>) null;
    this._doneWithFailureCallback = (Action<DismissAllPanelsJob>) null;
  }

  public static DismissAllPanelsJob Create(string[] except, Action<DismissAllPanelsJob> doneWithSuccessCallback, Action<DismissAllPanelsJob> doneWithFailureCallback)
  {
    return new DismissAllPanelsJob(except, doneWithSuccessCallback, doneWithFailureCallback);
  }

  protected override void Done(bool withError = false)
  {
    if (withError)
    {
      if (this._doneWithFailureCallback != null)
        this._doneWithFailureCallback(this);
    }
    else if (this._doneWithSuccessCallback != null)
      this._doneWithSuccessCallback(this);
    JobMgr.Instance.CurrentJobDone();
  }

  public override string ToString()
  {
    return string.Format("{0})", (object) base.ToString());
  }

  public override string GetJobTarget()
  {
    return "ALL";
  }
}
