public Drawable(Vector2 position, IDs id = IDs.DEFAULT) // : base(sprite.spriteRect.Width, sprite.spriteRect.Height)
 {
     if (id == IDs.DEFAULT)
     {
         id = EntityConstants.TypeToID(GetType());
     }
     this.id = id;
     SetStats(id);
 }
        private ShipItem CreateShipItem(Part part, int linkPosition, Vector2 v, RectangularHull hull)
        {
            IDs id = IDs.EMPTYPART;

            if (part != null)
            {
                id = EntityConstants.TypeToID(part.GetType());
            }
            return(new ShipItem(new Vector2(v.X, v.Y), linkPosition, hull, part, id));
        }
 public PartController(Vector2 position, bool isEvil, IDs id = IDs.DEFAULT)
 {
     IsEvil = isEvil;
     if (id == IDs.DEFAULT)
     {
         id = EntityConstants.TypeToID(GetType());
     }
     Hull         = new RectangularHull(id);
     Hull.Carrier = this;
     Position     = position;
     this.id      = id;
     SetStats(id);
 }
        //refactor buying out of this method
        private void AddPart(Part newPart)
        {
            if (newPart != null)
            {
                IsModified = true;
            }

            bool notEnoughMoney = false;  // only used to see if

            if (shipItems[activeSelection].id == IDs.RECTHULLPART)
            {
            }
            else if (activeSelection != 0)
            {
                ShipItem        pressedItem = shipItems[activeSelection];
                RectangularHull hull        = null;
                hull = pressedItem.Hull;
                // now redundant - graveyard functionality
                //if (pressedItem.id == IDs.RECTHULLPART)
                //{
                //    RemoveHull(pressedItem);
                //    FixLinkPosition(pressedItem); //!!!!!
                //}

                if (newPart == null)
                {
                    PlaceEmptyBox(pressedItem, hull);
                    UpgradeBar.SpentResource -= EntityConstants.PRICE[(int)pressedItem.id];
                }
                else
                {
                    float newPartPrice = EntityConstants.GetStatsFromID(EntityConstants.PRICE, EntityConstants.TypeToID(newPart.GetType()));
                    if (UpgradeBar.Resource >= newPartPrice)
                    {
                        PlacePart(pressedItem, hull, newPart);
                        UpgradeBar.SpentResource += newPartPrice;
                        UpgradeBar.SpentResource -= EntityConstants.PRICE[(int)pressedItem.id];
                    }
                    else
                    {
                        notEnoughMoney = true;
                    }
                }
                if (!notEnoughMoney)
                {
                    Vector2  v = pressedItem.Position;
                    ShipItem s = CreateShipItem(newPart, pressedItem.LinkPosition, v, (RectangularHull)hull);
                    shipItems[activeSelection] = s;
                    RenewEmptyBoxes();
                }
            }
        }