using System;
using MaidStatus;
using TextureBank;
using UnityEngine;

namespace Schedule
{
	public class SlotBase
	{
		public Maid maid
		{
			get
			{
				if (GameMain.Instance.CharacterMgr.status.GetScheduleSlot(this.slotId) != this._maid)
				{
					this.Update();
				}
				return this._maid;
			}
			set
			{
				if (this._maid != value)
				{
					if (value == null)
					{
						GameMain.Instance.CharacterMgr.status.scheduleSlot[this.slotId].maid_guid = string.Empty;
					}
					else
					{
						GameMain.Instance.CharacterMgr.status.scheduleSlot[this.slotId].maid_guid = value.status.guid;
					}
					this._maid = value;
					this.Update();
				}
			}
		}

		public int slotId
		{
			get
			{
				return this._slotId;
			}
		}

		public int noonWorkId
		{
			get
			{
				return this.maid.status.noonWorkId;
			}
			set
			{
				this.maid.status.noonWorkId = value;
			}
		}

		public int nightWorkId
		{
			get
			{
				return this.maid.status.nightWorkId;
			}
			set
			{
				this.maid.status.nightWorkId = value;
			}
		}

		public bool noonCommuFlag
		{
			get
			{
				return this.maid.status.noonCommu;
			}
			set
			{
				this.maid.status.noonCommu = value;
			}
		}

		public int popular_rank
		{
			get
			{
				return this.maid.status.popularRank;
			}
		}

		public bool nightCommuFlag
		{
			get
			{
				return this.maid.status.nightCommu;
			}
			set
			{
				this.maid.status.nightCommu = value;
			}
		}

		public Texture2D popular_rank_icon
		{
			get
			{
				return this._popular_rank_icon;
			}
		}

		public Texture2D icon
		{
			get
			{
				return this.maid.GetThumIcon();
			}
		}

		public bool leader
		{
			get
			{
				return this.maid.status.leader;
			}
		}

		public string last_name
		{
			get
			{
				return this.maid.status.lastName;
			}
		}

		public string first_name
		{
			get
			{
				return this.maid.status.firstName;
			}
		}

		public Contract contract_type
		{
			get
			{
				return this.maid.status.contract;
			}
		}

		public string contract_type_name
		{
			get
			{
				string result = string.Empty;
				if (this.maid.status.heroineType == HeroineType.Sub)
				{
					result = this.maid.status.subCharaStatus.contractText;
				}
				else
				{
					result = EnumConvert.GetString(this.maid.status.contract);
				}
				return result;
			}
		}

		public Texture2D noon_icon
		{
			get
			{
				if (this.noon_icon_name == null)
				{
					return null;
				}
				return this.textureBank.GetTexture(this.noon_icon_name);
			}
		}

		public string noon_icon_name
		{
			get
			{
				if (!ScheduleCSVData.AllData.ContainsKey(this.maid.status.noonWorkId))
				{
					return null;
				}
				return ScheduleCSVData.AllData[this.maid.status.noonWorkId].icon;
			}
		}

		public Texture2D night_icon
		{
			get
			{
				if (this.night_icon_name == null)
				{
					return null;
				}
				return this.textureBank.GetTexture(this.night_icon_name);
			}
		}

		public string night_icon_name
		{
			get
			{
				if (!ScheduleCSVData.AllData.ContainsKey(this.maid.status.nightWorkId))
				{
					return null;
				}
				return ScheduleCSVData.AllData[this.maid.status.nightWorkId].icon;
			}
		}

		public Maid Maid
		{
			get
			{
				return this.maid;
			}
		}

		public virtual void Update()
		{
			this._maid = GameMain.Instance.CharacterMgr.status.GetScheduleSlot(this.slotId);
			this.UpdateRankIcon();
		}

		protected void UpdateRankIcon()
		{
			this._popular_rank_icon = null;
			if (this._maid != null && this.textureBank != null)
			{
				int popular_rank = this.popular_rank;
				if (popular_rank != 1)
				{
					if (popular_rank != 2)
					{
						if (popular_rank == 3)
						{
							this._popular_rank_icon = this.textureBank.GetTexture("cm3d2_management_crown_bronze");
						}
					}
					else
					{
						this._popular_rank_icon = this.textureBank.GetTexture("cm3d2_management_crown_silver");
					}
				}
				else
				{
					this._popular_rank_icon = this.textureBank.GetTexture("cm3d2_management_crown_gold");
				}
			}
		}

		protected Maid _maid;

		protected int _slotId;

		protected Texture2D _popular_rank_icon;

		public TextureBank textureBank;

		private const string POPULAR_RANK_ICON_1 = "cm3d2_management_crown_gold";

		private const string POPULAR_RANK_ICON_2 = "cm3d2_management_crown_silver";

		private const string POPULAR_RANK_ICON_3 = "cm3d2_management_crown_bronze";
	}
}
