using System;
using RVector4 = UnityEngine.Vector4;

namespace Cryville.Crtr {
	public abstract class PropStore {
		protected PropSrc m_source;
		public PropSrc Source { get { return m_source; } }
		protected PropOp m_target;
		public PropOp Target { get { return m_target; } }
	}
	public abstract class PropStore<T> : PropStore where T : IEquatable<T> {
		T m_value;
		public T Value {
			get {
				return m_value;
			}
			set {
				if (m_value.Equals(value)) return;
				m_value = value;
				m_source.Invalidate();
			}
		}
		public new PropSrc.Fixed<T> Source { get { return (PropSrc.Fixed<T>)m_source; } }
		public new PropOp.Fixed<T> Target { get { return (PropOp.Fixed<T>)m_target; } }
	}
	public static class PropStores {
		public class Float : PropStore<float> {
			public Float() {
				m_source = new PropSrc.Float(() => Value);
				m_target = new PropOp.Float(v => Value = v);
			}
		}
		public class Identifier : PropStore<int> {
			public Identifier() {
				m_source = new PropSrc.Identifier(() => Value);
				m_target = new PropOp.Identifier(v => Value = v);
			}
		}
		public class Vector4 : PropStore<RVector4> {
			public Vector4() {
				m_source = new PropSrc.Vector4(() => Value);
				m_target = new PropOp.Vector4(v => Value = v);
			}
		}
	}
}
