﻿// Decompiled with JetBrains decompiler
// Type: Wb.Lpw.Shared.Client.UnityEngine.MultiPlatformComponent`1
// Assembly: Wb.Lpw.Shared.Client.Unity.Engine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 2005C154-053D-446F-B064-848BB3D10703
// Assembly location: C:\Users\CGA Computer\Desktop\LEGO Universe Stuff\LOCO Server\Unity Web Player Extractor\Saved Files\LOCO Server.unity3d_unpacked\Wb.Lpw.Shared.Client.Unity.Engine.dll

using UnityEngine;

namespace Wb.Lpw.Shared.Client.UnityEngine
{
  public abstract class MultiPlatformComponent<TConfig> : MultiPlatformComponentBase where TConfig : MultiPlatformConfig
  {
    [HideInInspector]
    [SerializeField]
    public TConfig[] PerPlatformConfigs = new TConfig[2];
    [HideInInspector]
    [SerializeField]
    protected TConfig _defaultConfig;

    public TConfig DefaultConfig
    {
      get
      {
        if (Object.op_Equality((Object) (object) this._defaultConfig, (Object) null))
        {
          this._defaultConfig = (TConfig) ((Component) this).get_gameObject().AddComponent<TConfig>();
          this._defaultConfig.set_hideFlags((HideFlags) 2);
        }
        return this._defaultConfig;
      }
      set
      {
        this._defaultConfig = value;
      }
    }

    public virtual TConfig PlatformConfig
    {
      get
      {
        TConfig config = this.PerPlatformConfigs[(int) MultiPlatformComponentBase.GetCurrentPlatform()];
        if (Object.op_Inequality((Object) (object) config, (Object) null))
          return config;
        return this.DefaultConfig;
      }
    }

    public override MultiPlatformConfig GetDefaultConfig()
    {
      return (MultiPlatformConfig) this.DefaultConfig;
    }

    public override void SetDefaultConfig(MultiPlatformConfig config)
    {
      this._defaultConfig = (TConfig) config;
    }

    public override MultiPlatformConfig[] GetPlatformConfigs()
    {
      return (MultiPlatformConfig[]) this.PerPlatformConfigs;
    }

    public override void SetPlatformConfigs(MultiPlatformConfig[] configs)
    {
      this.PerPlatformConfigs = (TConfig[]) configs;
    }

    public void AddPlatformConfig(Platform aPlatform)
    {
      if (!Object.op_Equality((Object) (object) this.PerPlatformConfigs[(int) aPlatform], (Object) null))
        return;
      this.PerPlatformConfigs[(int) aPlatform] = (TConfig) ((Component) this).get_gameObject().AddComponent<TConfig>();
      this.PerPlatformConfigs[(int) aPlatform].set_hideFlags((HideFlags) 2);
    }

    public override void DeleteAllConfigurationsExceptCurrent()
    {
      this.DeleteAllConfigurationsExcept(MultiPlatformComponentBase.GetCurrentPlatform());
    }

    public override void DeleteAllConfigurationsExcept(Platform platformToKeep)
    {
      if (Object.op_Inequality((Object) (object) this.PerPlatformConfigs[(int) platformToKeep], (Object) null))
        this.DefaultConfig = this.PerPlatformConfigs[(int) platformToKeep];
      foreach (MultiPlatformConfig multiPlatformConfig in (MultiPlatformConfig[]) ((Component) this).get_gameObject().GetComponents<MultiPlatformConfig>())
      {
        if (Object.op_Inequality((Object) multiPlatformConfig, (Object) (object) this.DefaultConfig))
          Object.DestroyImmediate((Object) multiPlatformConfig);
      }
      this.PerPlatformConfigs = new TConfig[2];
    }
  }
}
