public ElementModel AddLightNode(ElementModel target, Point p, int?order = null, int?size = null) { if (target == null || target.IsRootNode) { target = FindOrCreateTargetGroupForLight(); } else if (target.Lights.Any()) { throw new ArgumentException("Cannot add light node to leaf element with lights."); } if (order == null) { order = GetNextOrder(); } ElementModel em = new ElementModel(Uniquify($"{target.Name}", 1), order.Value, target); target.AddChild(em); _models.Add(em.Id, em); if (size == null) { size = em.LightSize; } else { em.LightSize = size.Value; } var light = CreateLight(p, size.Value, em.Id); em.AddLight(light); return(em); }
private void AddLightToTarget(Point p, ElementModel em) { var light = CreateLight(p, em.LightSize, em.Id); em.AddLight(light); }