using System;
using UnityEngine;

namespace Cryville.EEW.Unity.Map.Element {
	class OngoingGroupElement : GroupElement {
		float _blinkingTime;
		float m_blinkingPeriod;
		public float BlinkingPeriod {
			get => m_blinkingPeriod;
			set {
				m_blinkingPeriod = value;
				_blinkingTime = Math.Max(value - 0.5f, value / 2);
			}
		}
		Transform _container;
		protected override Transform Container => _container;
		void Awake() {
			_container = new GameObject("_container").transform;
			_container.SetParent(transform, false);
		}
		void Update() {
			_container.gameObject.SetActive((DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds % m_blinkingPeriod < _blinkingTime);
		}
	}
}
