public virtual Component Map() { Type t = typeof(T); T component; if (!AllowMultipleComponents) { component = ComponentHandler.GetComponent(t) as T; if (component == null) { component = Activator.CreateInstance(t) as T; ComponentHandler.SetComponent(component); } } else { component = ComponentHandler.GetComponent(t, ComponentId) as T; if (component == null) { component = Activator.CreateInstance(t) as T; component = ComponentHandler.AddComponent(component) as T; } } Map(component); return(component); }