Duality.Components.Physics.RigidBody.OnCopyTo C# (CSharp) Method

OnCopyTo() protected method

protected OnCopyTo ( Component target, Duality provider ) : void
target Component
provider Duality
return void
        protected override void OnCopyTo(Component target, Duality.Cloning.CloneProvider provider)
        {
            base.OnCopyTo(target, provider);
            RigidBody c = target as RigidBody;

            bool wasInitialized = c.bodyInitState == InitState.Initialized;
            if (wasInitialized) c.Shutdown();

            c.bodyType = this.bodyType;
            c.linearDamp = this.linearDamp;
            c.angularDamp = this.angularDamp;
            c.fixedAngle = this.fixedAngle;
            c.ignoreGravity = this.ignoreGravity;
            c.continous = this.continous;
            c.colCat = this.colCat;
            c.colWith = this.colWith;
            c.explicitMass = this.explicitMass;
            c.isSensor = this.isSensor;

            c.linearVel = this.linearVel;
            c.angularVel = this.angularVel;
            c.revolutions = this.revolutions;

            // Detach and copy Shapes
            c.shapes = new List<ShapeInfo>();
            if (this.shapes != null) c.SetShapes(this.shapes.Select(s => provider.RequestObjectClone(s)));

            // Detach and copy Joints
            c.joints = null;
            if (this.joints != null) c.SetJoints(this.joints.Select(j =>
            {
                // If there is a clone registered, just return the clone. Don't process a joint twice.
                if (provider.IsOriginalObject(j)) return provider.GetRegisteredObjectClone(j);

                JointInfo j2 = j.Clone();
                j2.BodyA = provider.GetRegisteredObjectClone(j.BodyA);
                j2.BodyB = provider.GetRegisteredObjectClone(j.BodyB);
                provider.RegisterObjectClone(j, j2);

                return j2;
            }));

            if (wasInitialized) c.Initialize();
        }