template Rin()
{
	int lp;
	int count = 0;
	
	void tick()
	{
		static assert(is(int == typeof(lp)));
		while (true)
		{
			if (rand() % 100 == 0) // たまに瞬き
			{
				blink();
				return;
			}
			
			count++;
			if (300 <= count)
			{
				switch (rand() % 5)
				{
					case 0: // 怒る
						this[2].motion = [2, 1, 2];
						this[2].waitingMotion = [2, 2];
						this[3].motion = [4, 5, 4];
						this[3].waitingMotion = [4, 4];
						this[5].waitingMotion = [3, 3];
						moveMouth(5);
						break;
						
					case 1: // 笑う
						this[2].motion = [0, 1, 0];
						this[2].waitingMotion = [0, 0];
						this[3].motion = [2, 3, 2];
						this[3].waitingMotion = [2, 2];
						this[5].waitingMotion = [1, 1];
						moveMouth(1);
						break;
						
					case 2: // 泣く
						this[2].motion = [3, 1, 3];
						this[2].waitingMotion = [3, 3];
						this[3].motion = [6, 7, 6];
						this[3].waitingMotion = [6, 6];
						this[5].waitingMotion = [2, 2];
						moveMouth(2);
						break;
						
					case 3: // 照れ
						this[2].motion = [2, 1, 2];
						this[2].waitingMotion = [2, 2];
						this[3].motion = [0, 1, 0];
						this[3].waitingMotion = [0, 0];
						this[5].waitingMotion = [0, 0];
						moveMouth(6);
						break;
						
					default: // ふつう
						this[2].motion = [2, 1, 2];
						this[2].waitingMotion = [2, 2];
						this[3].motion = [0, 1, 0];
						this[3].waitingMotion = [0, 0];
						this[5].waitingMotion = [3, 3];
						moveMouth(0);
						break;
				}
				count = 0;
			}
			return;
		}
	}
	
	void blink()
	{
		this[2].motion.t = 0;
		this[3].motion.t = 0;
	}
	
	void moveMouth(size_t subsetY)
	{
		this[4].motion = [this[4].waitingMotion.current, subsetY];
		this[4].waitingMotion = [subsetY, subsetY];
	}
}

