Ejemplo n.º 1
0
        private void ResolveTradedItems()
        {
            List <Thing> itemList    = CaravanInventoryUtility.AllInventoryItems(this.landedShip);
            List <Thing> tmpToRemove = new List <Thing>();

            if (itemList != null)
            {
                for (int i = 0; i < landedShip.ships.Count; i++)
                {
                    ThingContainer container = landedShip.ships[i].GetInnerContainer();
                    tmpToRemove.Clear();
                    for (int k = 0; k < container.Count; k++)
                    {
                        if (!itemList.Contains(container[k]))
                        {
                            Pawn pawn = container[k] as Pawn;
                            if (pawn != null)
                            {
                                if (!pawn.IsColonist)
                                {
                                    tmpToRemove.Add(container[k]);
                                }
                            }
                            else
                            {
                                tmpToRemove.Add(container[k]);
                            }
                        }
                    }
                    container.RemoveAll(x => tmpToRemove.Contains(x));
                }
            }
            this.landedShip.ReloadStockIntoShip();
        }
Ejemplo n.º 2
0
        public void ReloadStockIntoShip()
        {
            List <Thing> allCargo = this.allLandedShipCargo.ToList <Thing>();

            allCargo.AddRange(this.PawnsListForReading.Cast <Thing>().ToList());
            List <Thing> remainingCargo = new List <Thing>();

            for (int i = 0; i < this.PawnsListForReading.Count; i++)
            {
                this.tmpThingsToRemove.Clear();
                ThingContainer carrier = this.PawnsListForReading[i].inventory.GetInnerContainer();
                for (int k = 0; k < carrier.Count; k++)
                {
                    if (allCargo.Contains(carrier[k]))
                    {
                        this.tmpThingsToRemove.Add(carrier[k]);
                    }
                    else
                    {
                        remainingCargo.Add(carrier[k]);
                    }
                }
                carrier.RemoveAll(x => this.tmpThingsToRemove.Contains(x));
            }

            List <Thing> stockInShips = new List <Thing>();

            foreach (ShipBase ship in this.ships)
            {
                stockInShips.AddRange(ship.GetInnerContainer());
            }

            for (int i = 0; i < allCargo.Count; i++)
            {
                if (!stockInShips.Contains(allCargo[i]))
                {
                    remainingCargo.Add(allCargo[i]);
                }
            }

            DropShipUtility.LoadNewCargoIntoRandomShips(remainingCargo, this.ships);
        }