Ejemplo n.º 1
0
        // --------------------------------------------------------------------

        public override SceneObject Clone()
        {
            EntityProxy newObj = new EntityProxy(this.Id, this.Scene);

            newObj.EntityRef = mEntity;
            newObj.Copy(this);

            return(newObj);
        }
Ejemplo n.º 2
0
        public virtual void ReadXml(XmlReader reader)
        {
            Id         = reader.GetAttribute("id");
            InstanceId = Convert.ToInt32(reader.GetAttribute("instanceId"));

            if (reader.IsEmptyElement)
            {
                return;
            }

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if (reader.Name.Equals("SceneObject"))
                    {
                        SceneObject obj = new SceneObject("", Scene);
                        obj.ReadXml(reader);
                        obj.SetParent(this, false);
                    }

                    if (reader.Name.Equals("EntityProxy"))
                    {
                        EntityProxy tmp = new EntityProxy("", Scene);
                        tmp.ReadXml(reader);
                        tmp.Parent = this;
                    }

                    if (reader.Name.Equals("Transform"))
                    {
                        Transform.ReadXml(reader);
                    }

                    if (reader.Name.Equals("Component"))
                    {
                        Component c = Component.GetComponent(reader);
                        Components.Add(c);
                        c.Attach(this);
                    }
                    //ComponentLoader.Load(obj, reader);
                    break;

                case XmlNodeType.EndElement:
                    if (reader.Name.Equals("SceneObject"))
                    {
                        return;
                    }
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        // --------------------------------------------------------------------

        public void GetEntitiesInChildren(List <Entity> entities)
        {
            EntityProxy thisEntity = this as EntityProxy;

            if (thisEntity != null && thisEntity.EntityRef != null)
            {
                entities.Add(thisEntity.EntityRef);
            }

            for (int i = 0; i < mChildren.Count; ++i)
            {
                if (!mChildren[i].Active)
                {
                    continue;
                }

                mChildren[i].GetEntitiesInChildren(entities);
            }
        }
Ejemplo n.º 4
0
        // --------------------------------------------------------------------

        public List <Entity> GetEntitiesInChildren()
        {
            List <Entity> entities   = new List <Entity>();
            EntityProxy   thisEntity = this as EntityProxy;

            if (thisEntity != null && thisEntity.EntityRef != null)
            {
                entities.Add(thisEntity.EntityRef);
            }

            for (int i = 0; i < mChildren.Count; ++i)
            {
                if (!mChildren[i].Active)
                {
                    continue;
                }

                mChildren[i].GetEntitiesInChildren(entities);
            }

            return(entities);
        }
Ejemplo n.º 5
0
        // --------------------------------------------------------------------

        public static bool RaycastEntity(Ray ray, out RaycastHit hit, EntityProxy obj)
        {
            obj.CalculateBounds();
            return(RaycastObject(ray, out hit, obj.EntityRef.Root));
        }