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

public class WindowPartsEffectSepia : WindowPartsEffectBase
{
	public override void Awake()
	{
		base.Awake();
		this.sepia_tone_ = GameMain.Instance.MainCamera.GetComponent<SepiaToneEffect>();
		if (this.sepia_tone_ == null)
		{
			this.sepia_tone_ = GameMain.Instance.MainCamera.gameObject.AddComponent<SepiaToneEffect>();
			if (this.sepia_tone_.shader == null)
			{
				this.sepia_tone_.shader = Shader.Find("Hidden/Sepiatone Effect");
			}
			this.sepia_tone_.enabled = false;
		}
	}

	public override void OnDestroy()
	{
		if (GameMain.Instance == null || GameMain.Instance.MainCamera == null || this.sepia_tone_ == null)
		{
			return;
		}
		UnityEngine.Object.Destroy(this.sepia_tone_);
		this.sepia_tone_ = null;
	}

	public override void Init()
	{
		this.EnabledCheckBox.check = false;
		this.UpdateGui();
	}

	public override void OnSerializeEvent()
	{
		Dictionary<string, Dictionary<string, string>> woldStoreData = this.effect_window_.GetWoldStoreData();
		woldStoreData["Sepia"] = new Dictionary<string, string>();
		Dictionary<string, string> dictionary = woldStoreData["Sepia"];
		dictionary.Add("enabled", base.effect_enabled.ToString());
	}

	public override void OnDeserializeEvent()
	{
		Dictionary<string, Dictionary<string, string>> woldStoreData = this.effect_window_.GetWoldStoreData();
		if (!woldStoreData.ContainsKey("Sepia"))
		{
			WFCheckBox enabledCheckBox = this.EnabledCheckBox;
			bool flag = false;
			base.effect_enabled = flag;
			enabledCheckBox.check = flag;
		}
		else
		{
			Dictionary<string, string> dictionary = woldStoreData["Sepia"];
			base.effect_enabled = bool.Parse(dictionary["enabled"]);
		}
		this.UpdateGui();
	}

	public void UpdateGui()
	{
		this.EnabledCheckBox.check = base.effect_enabled;
	}

	protected override MonoBehaviour effect_object
	{
		get
		{
			return this.sepia_tone_;
		}
	}

	private SepiaToneEffect sepia_tone_;
}
