using System;

public class MotionKagManager : BaseKagManager
{
	public MotionKagManager(TJSScript tjs, ScriptManager script_mgr) : base(tjs, script_mgr)
	{
		for (int i = 0; i < this.last_maid_motion_set_log_.Length; i++)
		{
			this.last_maid_motion_set_log_[i] = string.Empty;
		}
		for (int j = 0; j < this.last_man_motion_set_log_.Length; j++)
		{
			this.last_man_motion_set_log_[j] = string.Empty;
		}
	}

	public override void Initialize()
	{
		base.Initialize();
		this.kag_.RemoveTagCallBack("motionscript");
		this.kag_.RemoveTagCallBack("allprocpropseqstart");
		this.kag_.AddTagCallBack("allprocpropseqstart", new KagScript.KagTagCallBack(this.TagMotAllProcPropSeqStart));
		this.kag_.RemoveTagCallBack("setmaidoffsetmultipos");
		this.kag_.AddTagCallBack("setmaidoffsetmultipos", new KagScript.KagTagCallBack(this.TagSetMaidOffsetMultiPos2));
		this.kag_.RemoveTagCallBack("face");
		this.kag_.AddTagCallBack("face", new KagScript.KagTagCallBack(this.TagMotFace));
		this.kag_.RemoveTagCallBack("faceblend");
		this.kag_.AddTagCallBack("faceblend", new KagScript.KagTagCallBack(this.TagMotFaceBlend));
	}

	public Maid SetMainMaid(Maid maid)
	{
		this.main_maid_ = maid;
		return this.main_maid_;
	}

	public Maid SetMainMaid(string maid_guid)
	{
		if (string.IsNullOrEmpty(maid_guid))
		{
			this.main_maid_ = null;
			return null;
		}
		for (int i = 0; i < GameMain.Instance.CharacterMgr.GetMaidCount(); i++)
		{
			Maid maid = GameMain.Instance.CharacterMgr.GetMaid(i);
			if (maid != null && maid.status.guid == maid_guid)
			{
				this.main_maid_ = maid;
				break;
			}
		}
		return this.main_maid_;
	}

	public Maid SetMainMan(Maid man)
	{
		this.main_man_ = man;
		return this.main_man_;
	}

	public Maid SetMainMan(string man_guid)
	{
		if (string.IsNullOrEmpty(man_guid))
		{
			this.main_man_ = null;
			return null;
		}
		for (int i = 0; i < GameMain.Instance.CharacterMgr.GetManCount(); i++)
		{
			Maid man = GameMain.Instance.CharacterMgr.GetMan(i);
			if (man != null && man.status.guid == man_guid)
			{
				this.main_man_ = man;
				break;
			}
		}
		return this.main_man_;
	}

	private bool TagSetMaidOffsetMultiPos2(KagTagSupport tag_data)
	{
		if (this.valid_pos)
		{
			base.TagSetMaidOffsetMultiPos(tag_data);
		}
		return false;
	}

	private bool TagMotAllProcPropSeqStart(KagTagSupport tag_data)
	{
		Maid maidAndMan = base.GetMaidAndMan(tag_data);
		if (maidAndMan == null)
		{
			return false;
		}
		if (tag_data.IsValid("fix"))
		{
			maidAndMan.AllProcProp();
		}
		else
		{
			NDebug.Assert(!this.script_mgr_.is_motion_all_prop_seq, "MotionKagManager AllProcPropSeqStart error.");
			this.script_mgr_.is_motion_all_prop_seq = true;
			this.script_mgr_.motion_all_prop_seq_maid = maidAndMan;
		}
		return false;
	}

	private bool TagMotFace(KagTagSupport tag_data)
	{
		return !this.face_fix_ && base.TagFace(tag_data);
	}

	private bool TagMotFaceBlend(KagTagSupport tag_data)
	{
		return !this.face_fix_ && base.TagFaceBlend(tag_data);
	}

	public void SetNextMotion(bool is_next)
	{
		this.next_flag_ = is_next;
	}

	public void SetFaceFix(bool is_fix)
	{
		this.face_fix_ = is_fix;
	}

	protected override void PlayMaidMotion(Maid maid, string fn, bool additive = false, bool loop = false, bool boAddQue = false, float val = 0.5f)
	{
		if (this.next_flag_)
		{
			boAddQue = true;
			this.next_flag_ = false;
		}
		base.PlayMaidMotion(maid, fn, additive, loop, boAddQue, val);
		if (!maid.boMAN && !boAddQue && 0 <= maid.ActiveSlotNo && maid.ActiveSlotNo < this.last_maid_motion_set_log_.Length)
		{
			this.last_maid_motion_set_log_[maid.ActiveSlotNo] = fn.ToLower();
		}
		else if (maid.boMAN && !boAddQue && 0 <= maid.ActiveSlotNo && maid.ActiveSlotNo < this.last_man_motion_set_log_.Length)
		{
			this.last_man_motion_set_log_[maid.ActiveSlotNo] = fn.ToLower();
		}
	}

	public void ClearMotion()
	{
		this.exec_wait_data_.Clear();
		this.wait_event_list_.Clear();
	}

	public void SetSloatNo(int no)
	{
		this.sloat_no_ = no;
	}

	public override string GetKagClassName()
	{
		return "モーションkag : " + this.sloat_no_.ToString();
	}

	public override Maid GetMaid(int no)
	{
		if (no == 0 && this.main_maid_ != null)
		{
			return this.main_maid_;
		}
		return base.GetMaid(no);
	}

	public override Maid GetMan(int man_no)
	{
		if (man_no == 0 && this.main_man_ != null)
		{
			return this.main_man_;
		}
		return base.GetMan(man_no);
	}

	public bool valid_pos
	{
		get
		{
			return this.valid_pos_;
		}
		set
		{
			this.valid_pos_ = value;
		}
	}

	public Maid main_maid
	{
		get
		{
			return this.main_maid_;
		}
	}

	public Maid main_man
	{
		get
		{
			return this.main_man_;
		}
	}

	public string[] last_maid_motion_set_log
	{
		get
		{
			return this.last_maid_motion_set_log_;
		}
	}

	public string[] last_man_motion_set_log
	{
		get
		{
			return this.last_man_motion_set_log_;
		}
	}

	private int sloat_no_;

	private bool next_flag_;

	private bool face_fix_;

	private Maid main_maid_;

	private Maid main_man_;

	private bool valid_pos_ = true;

	protected string[] last_maid_motion_set_log_ = new string[6];

	protected string[] last_man_motion_set_log_ = new string[6];
}
