public bool SetKeyedComponent(object key, IGlyphComponent component) { IGlyphComponent currentComponent = GetKeyedComponent <IGlyphComponent>(key); if (component == currentComponent) { return(false); } if (currentComponent != null) { RemoveAndDispose(currentComponent); _keyedComponents.Remove(key); } if (component != null) { if (!Contains(component)) { Add(component); } _keyedComponents[key] = component; } return(true); }
public UserInterface([Resolvable, ResolveTargets(ResolveTargets.Parent)] IGlyphComponent parent = null) { Interactive = new SubscribableInterface(this); if (parent?.Name != null) { Interactive.Name = parent.Name + " interface"; } }
public ILayerRoot <TLayer> GetLayerRoot(IGlyphComponent component) { foreach (ILayerRoot <TLayer> layerRoot in _layers.Keys) { if (layerRoot.Parent.AllChildren().Contains(component)) { return(layerRoot); } } return(null); }
public override sealed bool Remove(IGlyphComponent item) { if (!Contains(item) || !base.Remove(item)) { return(false); } _keyedComponents.Remove(x => x.Value == item); Schedulers.UnplanComponent(item); return(true); }
public void UnplanComponent(IGlyphComponent component) { Initialize.Unplan(component); if (component is ILoadContent loadContent) { LoadContent.Unplan(loadContent); } if (component is IUpdate update) { Update.Unplan(update); } if (component is IDraw draw) { Draw.Unplan(draw); } }
static public IGlyphData GetData(this IGlyphData root, IGlyphComponent component) { if (root == null || component == null) { return(null); } foreach (IGlyphComponent parent in component.AndAllParents()) { if (Tree.BreadthFirst(root, x => x.Children).Any(x => x.BindedObject == parent, out IGlyphData data)) { return(data); } } return(null); }
// TODO : Handle injection on changing children & parents public override sealed void Add(IGlyphComponent item) { if (Contains(item)) { throw new ArgumentException("Component provided is already contained by this entity !"); } Type type = item.GetType(); if (Components.AnyOfType(type) && type.GetCustomAttributes(typeof(SinglePerParentAttribute)).Any()) { throw new SingleComponentException(type); } var glyphObject = item as GlyphObject; if (glyphObject != null) { glyphObject.Resolver.Parent = null; } base.Add(item); if (glyphObject != null) { glyphObject.Resolver.Parent = this; } Schedulers.PlanComponent(item); if (_initialized) { item.Initialize(); } if (_contentLoaded && item is ILoadContent loadingItem) { Task.Run(async() => await loadingItem.LoadContent(Resolver.Resolve <IContentLibrary>())).Wait(); } }
bool IContainer <IGlyphComponent> .TryUnlink(IGlyphComponent child) => ContainerImplementation.TryUnlink(child);
void IContainer <IGlyphComponent> .Unlink(IGlyphComponent child) => ContainerImplementation.Unlink(child);
ILayerRoot ILayerManager.GetLayerRoot(IGlyphComponent component) { return(GetLayerRoot(component)); }
public void RemoveAndDispose(IGlyphComponent item) { Remove(item); item.Dispose(); }
static public SceneNode GetSceneNode(this IGlyphComponent component) { return(component?.Components.FirstOfTypeOrDefault <SceneNode>() ?? component?.AllParents().SelectMany(x => x.Components).FirstOfTypeOrDefault <SceneNode>()); }