Example #1
0
 /// <summary>
 /// Adds a component to this node's list of components. Internally the component is
 /// stored in this node's <see cref="Scene"/> instance and referenced in the node.
 /// </summary>
 /// <param name="component">The component to store in this node's component list.</param>
 public void AddComponent(FusComponent component)
 {
     if (Scene == null)
     {
         throw new InvalidOperationException($"Cannot add component {component} to node {this} (not yet attached to a scene)");
     }
     Components.Add(Scene.GetComponentIndex(component));
 }
Example #2
0
        internal int GetComponentIndex(FusComponent component)
        {
            if (ComponentList == null)
            {
                ComponentList = new List <FusComponent>();
            }

            int inx = ComponentList.FindIndex(comp => comp == component);

            if (inx < 0)
            {
                inx = ComponentList.Count;
            }

            ComponentList.Add(component);
            return(inx);
        }