﻿// Decompiled with JetBrains decompiler
// Type: GfsPrepareRelogin
// 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 UnityEngine;
using Wb.Lpw.AssetPipeline.Client;
using Wb.Lpw.Game.Common.Descriptions;
using Wb.Lpw.Shared.Client.UnityEngine;
using Wb.Lpw.Shared.Common.HFSM;

public class GfsPrepareRelogin : HFSState
{
  private bool _allDone;

  public GfsPrepareRelogin()
  {
    GfsPrepareRelogin gfsPrepareRelogin1 = this;
    Action action1 = (Action) Delegate.Combine((Delegate) gfsPrepareRelogin1.OnEntry, (Delegate) new Action(this.Entry));
    gfsPrepareRelogin1.OnEntry = (Action) action1;
    GfsPrepareRelogin gfsPrepareRelogin2 = this;
    Action action2 = (Action) Delegate.Combine((Delegate) gfsPrepareRelogin2.OnUpdate, (Delegate) new Action(this.Update));
    gfsPrepareRelogin2.OnUpdate = (Action) action2;
    GfsPrepareRelogin gfsPrepareRelogin3 = this;
    Func<HFSTransition> func = (Func<HFSTransition>) Delegate.Combine((Delegate) gfsPrepareRelogin3.OnTransitionCheck, (Delegate) new Func<HFSTransition>(this.GetTransition));
    gfsPrepareRelogin3.OnTransitionCheck = (Func<HFSTransition>) func;
  }

  public HFSTransition GetTransition()
  {
    if (this._allDone)
      return new HFSTransition(TransitionType.Sibling, (HFSState) new GfsLogin(true, true));
    return HFSTransition.None;
  }

  public void Entry()
  {
    this._allDone = false;
    if (GameflowManager.Instance.IsLoadingScreenUp())
      return;
    FordPanelManager instance = FordPanelManager.Instance;
    string[] strArray1 = new string[2];
    int index1 = 0;
    string str1 = "UILoadingScreen";
    strArray1[index1] = str1;
    int index2 = 1;
    string str2 = "UIPanelLoading";
    strArray1[index2] = str2;
    string[] strArray2 = strArray1;
    int num = 17;
    // ISSUE: variable of the null type
    __Null local1 = null;
    // ISSUE: variable of the null type
    __Null local2 = null;
    // ISSUE: variable of the null type
    __Null local3 = null;
    string[] forceDismissAllPanelsExcept = strArray2;
    instance.SwitchLayout((FordPanelBase.FordHUDGroup) num, (Action<string, UIPanelBase>) local1, (object) local2, (Action<string>) local3, forceDismissAllPanelsExcept);
    LoadingDestination loadingDestination = ((List<LoadingDestination>) GameFramework.Roger.LoadingScreens.Value.Destinations)[0];
    UILoadingScreen.LoadingOptions options = new UILoadingScreen.LoadingOptions()
    {
      Destination = loadingDestination
    };
    GameflowManager.Instance.ShowLoadingScreen(options);
  }

  public void Update()
  {
    if (this._allDone || !GameflowManager.Instance.IsLoadingScreenUp())
      return;
    this.FinishCleanupAndExitState();
  }

  private void FinishCleanupAndExitState()
  {
    if (GameServerState.Instance != null)
      GameServerState.Instance.DisposeStatic();
    if (Object.op_Inequality((Object) ResourceMgr.Instance, (Object) null))
      ResourceMgr.Instance.PurgeCache();
    Application.LoadLevel("EmptyScene");
    if (Object.op_Inequality((Object) ResourceMgr.Instance, (Object) null))
    {
      ResourceMgr.Instance.PurgeDeadReferrers();
      ResourceMgr.Instance.PurgeDeadResources();
      ResourceMgr.Instance.PurgePools();
    }
    if (Object.op_Inequality((Object) FordPanelManager.Instance, (Object) null))
      FordPanelManager.Instance.DestroyPanelCache();
    if (Object.op_Inequality((Object) MeshCombineMgr.Instance, (Object) null))
    {
      MeshCombineMgr.Instance.ClearCache();
      MeshCombineMgr.Instance.Photographer.ClearCache();
    }
    StreamedResourceContainer.IncrementErrorGeneration();
    StreamedResourcesContainer.IncrementErrorGeneration();
    this._allDone = true;
  }
}
