Esempio n. 1
0
        public override void CopyTo(MObject m1)
        {
            base.CopyTo(m1);

            MSceneObject mo = (MSceneObject)m1;

            mo.transform.Scale          = transform.Scale;
            mo.transform.RotationOffset = transform.RotationOffset;

            //we don't want to use the template position, since these will be set by the world map
            //mo.transform.Position = transform.Position;
            //mo.transform.Rotation = transform.Rotation;
            mo.SetMaterial(material);
            mo.TemplateID     = TemplateID;
            mo.IsAvatar       = IsAvatar;
            mo.CastsShadow    = CastsShadow;
            mo.BoundingBox    = BoundingBox;
            mo.IndicesLength  = IndicesLength;
            mo.VerticesLength = VerticesLength;
            mo.IsTransparent  = IsTransparent;

            foreach (MObject m in Modules)
            {
                if (m.Type == EType.PhysicsObject)
                {
                    MPhysicsObject p1 = (MPhysicsObject)m;
                    MPhysicsObject p2 = new MPhysicsObject(mo, mo.Name, (float)p1.Mass, p1.Shape, false, p1.CreateScale);
                    p2.Name = p1.Name;
                    p2.SetDamping(p1._rigidBody.LinearDamping, p1._rigidBody.AngularDamping);
                    p2._rigidBody.AngularFactor = p1._rigidBody.AngularFactor;
                    p2._rigidBody.LinearFactor  = p1._rigidBody.LinearFactor;
                    p2._rigidBody.Restitution   = p1._rigidBody.Restitution;
                    p2.SetPosRot(mo.transform.Position, mo.transform.Rotation);
                    //p2.SetPosition(mo.transform.Position);
                    //p2.SetRotation(mo.transform.Rotation);
                    p2.StopAllMotion();
                }

                if (m.Type == EType.PointLight)
                {
                    MPointLight p = new MPointLight(m.Name);
                    MScene.LightRoot.Add(p);
                    m.CopyTo(p);
                    mo.Add(p);
                }

                if (m.Type == EType.Sound)
                {
                    MSound os = (MSound)m;
                    MSound s  = new MSound();
                    os.CopyTo(s);
                    s.Error = os.Error;
                    s.Load(os.Filename, mo);
                    mo.Add(s);
                }

                //network objects can only be owned by the user. When the user is offline the network object is dormant
                //if (mo.OwnerID.Equals(Globals.UserAccount.UserID))
                if (m.Type == EType.NetworkObject)
                {
                    MNetworkObject mn = (MNetworkObject)m.FindModuleByType(MObject.EType.NetworkObject);
                    if (mn != null)
                    {
                        mo.Add(mn);
                    }
                }

                if (m.Type == EType.NPCPlayer)
                {
                    MNPC p = new MNPC(mo, m.Name);
                    m.CopyTo(p);
                    mo.Add(p);
                }

                if (m.Type == EType.Door)
                {
                    MDoor d2 = new MDoor(mo);
                    m.CopyTo(d2);
                    mo.Add(d2);
                }
            }
        }
Esempio n. 2
0
 public void CopyTo(MNPC t)
 {
     t.Name         = Name;
     t.CurrentState = CurrentState;
 }