Example #1
0
        /// <summary>
        /// Inserts a reference to the specified child into the Owner
        /// in the List specified by the ChildInfo property</summary>
        /// <param name="child">Child to be inserted</param>
        public bool AddChild(object child)
        {
            DomNode childNode = child.As <DomNode>();
            bool    isGobRef  = child.Is <IGameObject>() && childNode.GetRoot().Is <IGame>() && m_childInfo.Type == Schema.gameObjectReferenceType.Type;
            bool    isResRef  = ResourceReference.CanReference(m_childInfo.Type, child.As <IResource>());

            DomNode refNode = null;

            if (isGobRef)
            {
                GameObjectReference gobRef = GameObjectReference.Create(childNode);
                refNode = gobRef.Cast <DomNode>();
            }
            else if (isResRef)
            {
                IReference <IResource> resReference =
                    ResourceReference.Create(m_childInfo.Type, child.As <IResource>());
                refNode = resReference.As <DomNode>();
            }

            if (m_childInfo.IsList)
            {
                m_owner.GetChildList(m_childInfo).Add(refNode);
            }
            else
            {
                m_owner.SetChild(m_childInfo, refNode);
            }
            return(true);
        }
Example #2
0
        IGameObject IResourceConverter.Convert(IResource resource)
        {
            if (resource == null)
            {
                return(null);
            }

            IGameObject gob = null;

            if (resource.Type == ResourceTypes.Model)
            {
                Locator locator = Locator.Create();
                IReference <IResource> resRef = ResourceReference.Create(resource);
                locator.Reference = resRef;
                locator.DomNode.InitializeExtensions();
                gob = locator;
            }
            return(gob);
        }