void GlobalEvents_onComponentRemovedByPlayer(Components.Component sender)
 {
     if (sender is Components.Joint) return;
     for (int i = 0; i < components.Count; i++)
     {
         if (components[i].objType == sender.GetType() && components[i].Avalable > -1)
         {
             components[i].Avalable++;
         }
     }
 }
        public void RegisterComponent(Components.Component comp)
        {
            CSComponent c = new CSComponent();

            IO.Log.Write("            Adding " + comp.Graphics.GetCSToolTip() + " to ComponentSelector");
            c.Texture = ResourceManager.Load<Texture2D>(comp.Graphics.GetIconName());
            c.objType = comp.GetType();
            c.instance = comp;
            c.componentGraphics = comp.Graphics;
            c.jointCoords0cw = comp.GetJointCoords(Components.Component.Rotation.cw0);
            c.jointCoords90cw = comp.GetJointCoords(Components.Component.Rotation.cw90);
            c.jointCoords180cw = comp.GetJointCoords(Components.Component.Rotation.cw180);
            c.jointCoords270cw = comp.GetJointCoords(Components.Component.Rotation.cw270);
            c.Name = comp.Graphics.GetCSToolTip();
            c.IsDragDropPlacement = (comp is Components.Properties.IDragDropPlacable);

            /*
            if (c.jointCoords0cw.Length % 2 == 1)
                c.jointCoords0cw = new int[0];
            else
                for (int i = 0; i < c.jointCoords0cw.Length; i++)
                    c.jointCoords0cw[i] = c.jointCoords0cw[i] - Math.Abs(c.jointCoords0cw[i] % 8);

            if (c.jointCoords90cw.Length % 2 == 1)
                c.jointCoords90cw = new int[0];
            else
                for (int i = 0; i < c.jointCoords90cw.Length; i++)
                    c.jointCoords90cw[i] = c.jointCoords90cw[i] - Math.Abs(c.jointCoords90cw[i] % 8);

            if (c.jointCoords180cw.Length % 2 == 1)
                c.jointCoords180cw = new int[0];
            else
                for (int i = 0; i < c.jointCoords180cw.Length; i++)
                    c.jointCoords180cw[i] = c.jointCoords180cw[i] - Math.Abs(c.jointCoords180cw[i] % 8);

            if (c.jointCoords270cw.Length % 2 == 1)
                c.jointCoords270cw = new int[0];
            else
                for (int i = 0; i < c.jointCoords270cw.Length; i++)
                    c.jointCoords270cw[i] = c.jointCoords270cw[i] - Math.Abs(c.jointCoords270cw[i] % 8);//*/

            //comp.typeID = (short)components.Count;
            Components.ComponentsManager.TypeIDs.Add(comp.GetType(), (short)Components.ComponentsManager.TypeIDs.Count);
            components.Add(c);
        }