Beispiel #1
0
        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);
        }
Beispiel #2
0
        public UserInterface([Resolvable, ResolveTargets(ResolveTargets.Parent)] IGlyphComponent parent = null)
        {
            Interactive = new SubscribableInterface(this);

            if (parent?.Name != null)
            {
                Interactive.Name = parent.Name + " interface";
            }
        }
Beispiel #3
0
        public ILayerRoot <TLayer> GetLayerRoot(IGlyphComponent component)
        {
            foreach (ILayerRoot <TLayer> layerRoot in _layers.Keys)
            {
                if (layerRoot.Parent.AllChildren().Contains(component))
                {
                    return(layerRoot);
                }
            }

            return(null);
        }
Beispiel #4
0
        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);
        }
Beispiel #7
0
        // 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();
            }
        }
Beispiel #8
0
 bool IContainer <IGlyphComponent> .TryUnlink(IGlyphComponent child) => ContainerImplementation.TryUnlink(child);
Beispiel #9
0
 void IContainer <IGlyphComponent> .Unlink(IGlyphComponent child) => ContainerImplementation.Unlink(child);
Beispiel #10
0
 ILayerRoot ILayerManager.GetLayerRoot(IGlyphComponent component)
 {
     return(GetLayerRoot(component));
 }
Beispiel #11
0
 public void RemoveAndDispose(IGlyphComponent item)
 {
     Remove(item);
     item.Dispose();
 }
Beispiel #12
0
 static public SceneNode GetSceneNode(this IGlyphComponent component)
 {
     return(component?.Components.FirstOfTypeOrDefault <SceneNode>()
            ?? component?.AllParents().SelectMany(x => x.Components).FirstOfTypeOrDefault <SceneNode>());
 }