Example #1
0
        public override void CopyInto(IBaseComponent newObject)
        {
            var physicsComponent = newObject as PhysicsComponent;

            Debug.Assert(physicsComponent != null, "physicsComponent != null");

            physicsComponent.MaxVelocity = MaxVelocity;
            physicsComponent.Solid       = Solid;

            foreach (KeyValuePair <string, Body> bodyEntry in Bodies)
            {
                var body = bodyEntry.Value.DeepClone();
                ((FarseerUserData)body.UserData).Owner = physicsComponent;
                physicsComponent.AddBody(bodyEntry.Value.DeepClone(), bodyEntry.Key);
                physicsManager.RegisterBody(body);
            }

            foreach (KeyValuePair <string, Joint> joint in Joints)
            {
                physicsComponent.copyJoints.Add(joint.Key, joint.Value);
            }

            base.CopyInto(newObject);
        }