Beispiel #1
0
 public PSItem GetMissileItemByMissileDesignId(int missileDesignId)
 {
     for (int index = 0; index < this.ItemsBelongingToShip.Count; ++index)
     {
         PSItem psItem = this.ItemsBelongingToShip[index];
         if (psItem.ItemDesign.MissileDesignId == missileDesignId)
         {
             return(psItem);
         }
     }
     return((PSItem)null);
 }
Beispiel #2
0
 public PSItem GetCraftItemByCraftDesignId(int craftDesignId)
 {
     for (int index = 0; index < this.ItemsBelongingToShip.Count; ++index)
     {
         PSItem psItem = this.ItemsBelongingToShip[index];
         if (psItem.ItemDesign.CraftDesignId == craftDesignId)
         {
             return(psItem);
         }
     }
     return((PSItem)null);
 }
Beispiel #3
0
 public virtual void DeleteParentItem(PSItem item)
 {
     for (int index = 0; index < this.Items.Length; ++index)
     {
         PSItem psItem = this.Items[index];
         if (psItem != null && psItem.ShipId == item.ShipId && item.ItemDesign.ParentItemDesignId == psItem.ItemDesignId)
         {
             this.Items[index] = (PSItem)null;
             break;
         }
     }
 }
Beispiel #4
0
        public PSItem GetItemByKey(string itemDesignKey)
        {
            List <PSItem> itemsBelongingToShip = this.ItemsBelongingToShip;

            for (int index = 0; index < itemsBelongingToShip.Count; ++index)
            {
                PSItem psItem = itemsBelongingToShip[index];
                if (psItem.ItemDesign.ItemDesignKey == itemDesignKey)
                {
                    return(psItem);
                }
            }
            return((PSItem)null);
        }
Beispiel #5
0
        public virtual PSItem GetItemByItemDesignId(int itemDesignId)
        {
            List <PSItem> itemsBelongingToShip = this.ItemsBelongingToShip;

            for (int index = 0; index < itemsBelongingToShip.Count; ++index)
            {
                PSItem psItem = itemsBelongingToShip[index];
                if (psItem.ItemDesign.ItemDesignId == itemDesignId)
                {
                    return(psItem);
                }
            }
            return((PSItem)null);
        }
Beispiel #6
0
        public int GetTotalNumberOfItemsOfTypeEquippedOnCharacters(PSItem psItem)
        {
            int num = 0;

            for (int index = 0; index < this.Characters.Length; ++index)
            {
                PSCharacter character = this.Characters[index];
                if (character.EquippedItems != null && character.EquippedItems.Count > 0)
                {
                    num += character.EquippedItems.Count <PSItem>((Func <PSItem, bool>)(equip => equip.ItemId == psItem.ItemId));
                }
            }
            return(num);
        }
Beispiel #7
0
        public List <PSItem> GetAllItemsBySubType(ItemSubType subType)
        {
            List <PSItem> psItemList = new List <PSItem>();

            for (int index = 0; index < this.ItemsBelongingToShip.Count; ++index)
            {
                PSItem psItem = this.ItemsBelongingToShip[index];
                if (psItem.ItemDesign.ItemSubType == subType)
                {
                    psItemList.Add(psItem);
                }
            }
            return(psItemList);
        }
Beispiel #8
0
        public List <PSItem> GetAvailableItemsByTypeAndRank(ItemType type, int rank)
        {
            List <PSItem> psItemList = new List <PSItem>();

            for (int index = 0; index < this.ItemsBelongingToShip.Count; ++index)
            {
                PSItem psItem = this.ItemsBelongingToShip[index];
                if (psItem.ItemDesign.ItemType == type && psItem.Quantity > 0 && psItem.ItemDesign.Rank == rank)
                {
                    psItemList.Add(psItem);
                }
            }
            return(psItemList);
        }
Beispiel #9
0
        public int GetTotalItemsByItemType(ItemType itemType)
        {
            int           num = 0;
            List <PSItem> itemsBelongingToShip = this.ItemsBelongingToShip;

            for (int index = 0; index < itemsBelongingToShip.Count; ++index)
            {
                PSItem psItem = itemsBelongingToShip[index];
                if (psItem.ItemDesign.ItemType == itemType && (psItem.ItemDesign.RequiredResearchDesignId == 0 || psItem.ItemDesign.RequiredPsResearch != null && psItem.ItemDesign.RequiredPsResearch.ResearchState == ResearchState.Completed))
                {
                    num += psItem.Quantity;
                }
            }
            return(num);
        }
Beispiel #10
0
        public int GetTotalItemStorageUsedByRoomDesign(RoomDesign roomDesign)
        {
            int           num = 0;
            List <PSItem> itemsBelongingToShip = this.ItemsBelongingToShip;

            for (int index = 0; index < itemsBelongingToShip.Count; ++index)
            {
                PSItem psItem = itemsBelongingToShip[index];
                if (psItem.ItemDesign.ItemType == roomDesign.ManufactureType && psItem.ItemDesign.MinRoomLevel <= roomDesign.Level && psItem.ItemDesign.Rank == roomDesign.ItemRank && (psItem.ItemDesign.RequiredResearchDesignId == 0 || psItem.ItemDesign.RequiredPsResearch != null && psItem.ItemDesign.RequiredPsResearch.ResearchState == ResearchState.Completed))
                {
                    num += psItem.ItemDesign.ItemSpace * psItem.Quantity;
                }
            }
            return(num);
        }
Beispiel #11
0
        public List <PSItem> GetAllExistingItemsBySubType(ItemSubType subType)
        {
            List <PSItem> psItemList           = new List <PSItem>();
            List <PSItem> itemsBelongingToShip = this.ItemsBelongingToShip;

            for (int index = 0; index < itemsBelongingToShip.Count; ++index)
            {
                PSItem psItem = itemsBelongingToShip[index];
                if (psItem.ItemDesign.ItemSubType == subType && psItem.Quantity > 0)
                {
                    psItemList.Add(psItem);
                }
            }
            return(psItemList);
        }
Beispiel #12
0
        public int GetTotalNumberOfItemsOfTypeEquippedOnRooms(PSItem psItem)
        {
            int num1 = 0;

            for (int index = 0; index < this.Rooms.Length; ++index)
            {
                PSRoom room = this.Rooms[index];
                if (room.ModuleItems != null && room.ModuleItems.Count > 0)
                {
                    int num2 = room.ModuleItems.Count <PSItem>((Func <PSItem, bool>)(mod => mod.ItemId == psItem.ItemId));
                    num1 += num2;
                }
            }
            return(num1);
        }
Beispiel #13
0
 public virtual PSItem GetItemByItemId(int itemId)
 {
     if (this.Items != null)
     {
         for (int index = 0; index < this.Items.Length; ++index)
         {
             PSItem psItem = this.Items[index];
             if (psItem.ItemId == itemId)
             {
                 return(psItem);
             }
         }
     }
     return((PSItem)null);
 }
Beispiel #14
0
        public List <PSItem> GetAllAvailableItemsBySubType(ItemSubType subType)
        {
            List <PSItem> psItemList           = new List <PSItem>();
            List <PSItem> itemsBelongingToShip = this.ItemsBelongingToShip;

            for (int index = 0; index < itemsBelongingToShip.Count; ++index)
            {
                PSItem psItem = itemsBelongingToShip[index];
                ItemManagementInterface managementInterface = psItem as ItemManagementInterface;
                if (psItem.ItemDesign.ItemSubType == subType && managementInterface.QuantityAvailable > 0)
                {
                    psItemList.Add(psItem);
                }
            }
            return(psItemList);
        }
Beispiel #15
0
 public override void DeleteParentItem(PSItem item)
 {
     try
     {
         this.PSMainItems.Remove(this.PSMainItems.First <PSMainItem>((Func <PSMainItem, bool>)(x =>
         {
             if (x.ShipId == item.ShipId)
             {
                 return(item.ItemDesign.ParentItemDesignId == x.ItemDesignId);
             }
             return(false);
         })));
     }
     catch
     {
     }
 }
Beispiel #16
0
        public virtual PSItem AddItemToShip(PSItem item)
        {
            PSItem psItem = Array.Find <PSItem>(this.Items, (Predicate <PSItem>)(x => x.ItemId == item.ItemId));

            if (psItem != null)
            {
                psItem.ItemDesignId = item.ItemDesignId;
                psItem.Quantity     = item.Quantity;
                psItem.ShipId       = item.ShipId;
            }
            else
            {
                this.ReplaceParentItem(item);
                Debug.LogError((object)"Trying to get base Ship class to add an item! Not supported!", (Object)null);
            }
            return(psItem);
        }
Beispiel #17
0
        public override PSItem AddItemToShip(PSItem item)
        {
            PSItem psItem = (PSItem)null;

            try
            {
                psItem = (PSItem)this.PSMainItems.First <PSMainItem>((Func <PSMainItem, bool>)(x => x.ItemId == item.ItemId));
            }
            catch
            {
            }
            if (psItem != null)
            {
                psItem.ItemDesignId = item.ItemDesignId;
                psItem.Quantity     = item.Quantity;
                psItem.ShipId       = item.ShipId;
            }
            else
            {
                this.DeleteParentItem(item);
                this.PSMainItems.Add(item as PSMainItem);
            }
            return(psItem);
        }