private void SetTroopSlotForPendingShipment(TroopSlot[] troopSlots, ulong shipmentDBID)
 {
     TroopSlot[] troopSlotArray = troopSlots;
     for (int i = 0; i < (int)troopSlotArray.Length; i++)
     {
         if (troopSlotArray[i].GetDBID() == shipmentDBID)
         {
             return;
         }
     }
     TroopSlot[] troopSlotArray1 = troopSlots;
     for (int j = 0; j < (int)troopSlotArray1.Length; j++)
     {
         TroopSlot troopSlot = troopSlotArray1[j];
         if (troopSlot.IsPendingCreate())
         {
             troopSlot.SetCharShipment(this.m_charShipmentRec.ID, shipmentDBID, 0, true, 0);
             return;
         }
     }
     TroopSlot[] troopSlotArray2 = troopSlots;
     for (int k = 0; k < (int)troopSlotArray2.Length; k++)
     {
         TroopSlot troopSlot1 = troopSlotArray2[k];
         if (troopSlot1.IsEmpty())
         {
             troopSlot1.SetCharShipment(this.m_charShipmentRec.ID, shipmentDBID, 0, true, 0);
             return;
         }
     }
 }
 private void SetTroopSlotForExistingFollower(TroopSlot[] troopSlots, WrapperGarrisonFollower follower)
 {
     if (follower.Durability <= 0)
     {
         return;
     }
     TroopSlot[] troopSlotArray = troopSlots;
     for (int i = 0; i < (int)troopSlotArray.Length; i++)
     {
         int ownedFollowerID = troopSlotArray[i].GetOwnedFollowerID();
         if (ownedFollowerID != 0 && ownedFollowerID == follower.GarrFollowerID)
         {
             return;
         }
     }
     TroopSlot[] troopSlotArray1 = troopSlots;
     for (int j = 0; j < (int)troopSlotArray1.Length; j++)
     {
         TroopSlot troopSlot = troopSlotArray1[j];
         if (troopSlot.IsCollected())
         {
             GarrFollowerRec record = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID);
             int             num    = (GarrisonStatus.Faction() != PVP_FACTION.HORDE ? record.AllianceIconFileDataID : record.HordeIconFileDataID);
             troopSlot.SetCharShipment(this.m_charShipmentRec.ID, (ulong)0, follower.GarrFollowerID, false, num);
             return;
         }
     }
     TroopSlot[] troopSlotArray2 = troopSlots;
     for (int k = 0; k < (int)troopSlotArray2.Length; k++)
     {
         TroopSlot troopSlot1 = troopSlotArray2[k];
         if (troopSlot1.IsPendingCreate())
         {
             GarrFollowerRec garrFollowerRec = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID);
             int             num1            = (GarrisonStatus.Faction() != PVP_FACTION.HORDE ? garrFollowerRec.AllianceIconFileDataID : garrFollowerRec.HordeIconFileDataID);
             troopSlot1.SetCharShipment(this.m_charShipmentRec.ID, (ulong)0, follower.GarrFollowerID, false, num1);
             return;
         }
     }
     TroopSlot[] troopSlotArray3 = troopSlots;
     for (int l = 0; l < (int)troopSlotArray3.Length; l++)
     {
         TroopSlot troopSlot2 = troopSlotArray3[l];
         if (troopSlot2.IsEmpty())
         {
             GarrFollowerRec record1 = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID);
             int             num2    = (GarrisonStatus.Faction() != PVP_FACTION.HORDE ? record1.AllianceIconFileDataID : record1.HordeIconFileDataID);
             troopSlot2.SetCharShipment(this.m_charShipmentRec.ID, (ulong)0, follower.GarrFollowerID, false, num2);
             return;
         }
     }
 }
 private void HandleShipmentAdded(int charShipmentID, ulong shipmentDBID)
 {
     if (charShipmentID == this.m_charShipmentRec.ID)
     {
         TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
         TroopSlot[] troopSlotArray       = componentsInChildren;
         for (int i = 0; i < (int)troopSlotArray.Length; i++)
         {
             if (troopSlotArray[i].GetDBID() == shipmentDBID)
             {
                 return;
             }
         }
         TroopSlot[] troopSlotArray1 = componentsInChildren;
         for (int j = 0; j < (int)troopSlotArray1.Length; j++)
         {
             TroopSlot troopSlot = troopSlotArray1[j];
             if (troopSlot.IsPendingCreate())
             {
                 troopSlot.SetCharShipment(charShipmentID, shipmentDBID, 0, true, 0);
                 this.UpdateRecruitButtonState();
                 return;
             }
         }
         TroopSlot[] troopSlotArray2 = componentsInChildren;
         for (int k = 0; k < (int)troopSlotArray2.Length; k++)
         {
             TroopSlot troopSlot1 = troopSlotArray2[k];
             if (troopSlot1.IsEmpty())
             {
                 troopSlot1.SetCharShipment(charShipmentID, shipmentDBID, 0, true, 0);
                 this.UpdateRecruitButtonState();
                 return;
             }
         }
     }
 }
Beispiel #4
0
        private void UpdateTroopSlots()
        {
            if (this.m_followerRec == null || this.m_charShipmentRec == null)
            {
                return;
            }
            int maxTroops = this.GetMaxTroops((int)((GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? this.m_followerRec.AllianceGarrClassSpecID : this.m_followerRec.HordeGarrClassSpecID));

            TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
            if (componentsInChildren.Length < maxTroops)
            {
                for (int i = componentsInChildren.Length; i < maxTroops; i++)
                {
                    GameObject gameObject = Object.Instantiate <GameObject>(this.m_troopSlotPrefab);
                    gameObject.transform.SetParent(this.m_troopSlotsRootObject.transform, false);
                    TroopSlot component = gameObject.GetComponent <TroopSlot>();
                    component.SetCharShipment(this.m_charShipmentRec.ID, 0UL, 0, false, 0);
                }
            }
            if (componentsInChildren.Length > maxTroops)
            {
                for (int j = maxTroops; j < componentsInChildren.Length; j++)
                {
                    Object.Destroy(componentsInChildren[j].gameObject);
                }
            }
            componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
            foreach (TroopSlot troopSlot in componentsInChildren)
            {
                int ownedFollowerID = troopSlot.GetOwnedFollowerID();
                if (ownedFollowerID != 0 && (!PersistentFollowerData.followerDictionary.ContainsKey(ownedFollowerID) || PersistentFollowerData.followerDictionary[ownedFollowerID].Durability == 0))
                {
                    troopSlot.SetCharShipment(this.m_charShipmentRec.ID, 0UL, 0, false, 0);
                }
            }
            uint num = (uint)((GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? this.m_followerRec.AllianceGarrClassSpecID : this.m_followerRec.HordeGarrClassSpecID);

            foreach (WrapperGarrisonFollower follower in PersistentFollowerData.followerDictionary.Values)
            {
                GarrFollowerRec record = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID);
                uint            num2   = (uint)((GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? record.AllianceGarrClassSpecID : record.HordeGarrClassSpecID);
                if (num2 == num && follower.Durability > 0)
                {
                    this.SetTroopSlotForExistingFollower(componentsInChildren, follower);
                }
            }
            CharShipmentRec record2 = StaticDB.charShipmentDB.GetRecord(this.m_charShipmentRec.ID);

            foreach (WrapperCharacterShipment wrapperCharacterShipment in PersistentShipmentData.shipmentDictionary.Values)
            {
                if (wrapperCharacterShipment.ShipmentRecID == this.m_charShipmentRec.ID)
                {
                    this.SetTroopSlotForPendingShipment(componentsInChildren, wrapperCharacterShipment.ShipmentID);
                }
                else
                {
                    CharShipmentRec record3 = StaticDB.charShipmentDB.GetRecord(wrapperCharacterShipment.ShipmentRecID);
                    if (record3.ContainerID == record2.ContainerID)
                    {
                        this.SetTroopSlotForPendingShipment(componentsInChildren, wrapperCharacterShipment.ShipmentID);
                    }
                }
            }
        }
Beispiel #5
0
        private void UpdateItemSlots()
        {
            if (this.m_isArtifactResearch && this.m_akResearchDisabled)
            {
                TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
                for (int i = 0; i < componentsInChildren.Length; i++)
                {
                    Object.Destroy(componentsInChildren[i].gameObject);
                }
                return;
            }
            bool flag = true;

            if (this.m_charShipmentRec != null && !PersistentShipmentData.CanPickupShipmentType(this.m_charShipmentRec.ID))
            {
                flag = false;
            }
            int num = 0;

            foreach (WrapperCharacterShipment wrapperCharacterShipment in PersistentShipmentData.shipmentDictionary.Values)
            {
                if (wrapperCharacterShipment.ShipmentRecID == this.m_charShipmentRec.ID)
                {
                    num++;
                    break;
                }
            }
            if (num > 0 && !flag)
            {
                this.m_troopSlotsCanvasGroup.alpha          = 0f;
                this.m_troopSlotsCanvasGroup.interactable   = false;
                this.m_troopSlotsCanvasGroup.blocksRaycasts = false;
            }
            else
            {
                this.m_troopSlotsCanvasGroup.alpha          = 1f;
                this.m_troopSlotsCanvasGroup.interactable   = true;
                this.m_troopSlotsCanvasGroup.blocksRaycasts = true;
            }
            int maxShipments = (int)this.m_charShipmentRec.MaxShipments;

            TroopSlot[] componentsInChildren2 = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
            if (componentsInChildren2.Length < maxShipments)
            {
                for (int j = componentsInChildren2.Length; j < maxShipments; j++)
                {
                    GameObject gameObject = Object.Instantiate <GameObject>(this.m_troopSlotPrefab);
                    gameObject.transform.SetParent(this.m_troopSlotsRootObject.transform, false);
                    TroopSlot component = gameObject.GetComponent <TroopSlot>();
                    component.SetCharShipment(this.m_charShipmentRec.ID, 0UL, 0, false, 0);
                }
            }
            if (componentsInChildren2.Length > maxShipments)
            {
                for (int k = maxShipments; k < componentsInChildren2.Length; k++)
                {
                    Object.Destroy(componentsInChildren2[k].gameObject);
                }
            }
            componentsInChildren2 = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
            foreach (TroopSlot troopSlot in componentsInChildren2)
            {
                if (troopSlot.GetDBID() != 0UL && !PersistentShipmentData.shipmentDictionary.ContainsKey(troopSlot.GetDBID()))
                {
                    troopSlot.SetCharShipment(this.m_charShipmentRec.ID, 0UL, 0, false, 0);
                }
            }
            foreach (WrapperCharacterShipment wrapperCharacterShipment2 in PersistentShipmentData.shipmentDictionary.Values)
            {
                if (wrapperCharacterShipment2.ShipmentRecID == this.m_charShipmentRec.ID)
                {
                    this.SetTroopSlotForPendingShipment(componentsInChildren2, wrapperCharacterShipment2.ShipmentID);
                }
            }
        }
        private void UpdateTroopSlots()
        {
            if (this.m_followerRec == null || this.m_charShipmentRec == null)
            {
                return;
            }
            int maxTroops = this.GetMaxTroops((GarrisonStatus.Faction() != PVP_FACTION.HORDE ? (int)this.m_followerRec.AllianceGarrClassSpecID : (int)this.m_followerRec.HordeGarrClassSpecID));

            TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
            if ((int)componentsInChildren.Length < maxTroops)
            {
                for (int i = (int)componentsInChildren.Length; i < maxTroops; i++)
                {
                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_troopSlotPrefab);
                    gameObject.transform.SetParent(this.m_troopSlotsRootObject.transform, false);
                    TroopSlot component = gameObject.GetComponent <TroopSlot>();
                    component.SetCharShipment(this.m_charShipmentRec.ID, (ulong)0, 0, false, 0);
                }
            }
            if ((int)componentsInChildren.Length > maxTroops)
            {
                for (int j = maxTroops; j < (int)componentsInChildren.Length; j++)
                {
                    UnityEngine.Object.Destroy(componentsInChildren[j].gameObject);
                }
            }
            componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
            TroopSlot[] troopSlotArray = componentsInChildren;
            for (int k = 0; k < (int)troopSlotArray.Length; k++)
            {
                TroopSlot troopSlot       = troopSlotArray[k];
                int       ownedFollowerID = troopSlot.GetOwnedFollowerID();
                if (ownedFollowerID != 0 && (!PersistentFollowerData.followerDictionary.ContainsKey(ownedFollowerID) || PersistentFollowerData.followerDictionary[ownedFollowerID].Durability == 0))
                {
                    troopSlot.SetCharShipment(this.m_charShipmentRec.ID, (ulong)0, 0, false, 0);
                }
            }
            uint num = (GarrisonStatus.Faction() != PVP_FACTION.HORDE ? this.m_followerRec.AllianceGarrClassSpecID : this.m_followerRec.HordeGarrClassSpecID);

            foreach (WrapperGarrisonFollower value in PersistentFollowerData.followerDictionary.Values)
            {
                GarrFollowerRec record = StaticDB.garrFollowerDB.GetRecord(value.GarrFollowerID);
                if ((GarrisonStatus.Faction() != PVP_FACTION.HORDE ? record.AllianceGarrClassSpecID : record.HordeGarrClassSpecID) != num || value.Durability <= 0)
                {
                    continue;
                }
                this.SetTroopSlotForExistingFollower(componentsInChildren, value);
            }
            CharShipmentRec charShipmentRec = StaticDB.charShipmentDB.GetRecord(this.m_charShipmentRec.ID);

            foreach (WrapperCharacterShipment wrapperCharacterShipment in PersistentShipmentData.shipmentDictionary.Values)
            {
                if (wrapperCharacterShipment.ShipmentRecID != this.m_charShipmentRec.ID)
                {
                    if (StaticDB.charShipmentDB.GetRecord(wrapperCharacterShipment.ShipmentRecID).ContainerID != charShipmentRec.ContainerID)
                    {
                        continue;
                    }
                    this.SetTroopSlotForPendingShipment(componentsInChildren, wrapperCharacterShipment.ShipmentID);
                }
                else
                {
                    this.SetTroopSlotForPendingShipment(componentsInChildren, wrapperCharacterShipment.ShipmentID);
                }
            }
        }
        private void UpdateItemSlots()
        {
            if (this.m_isArtifactResearch && this.m_akResearchDisabled)
            {
                TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
                for (int i = 0; i < (int)componentsInChildren.Length; i++)
                {
                    UnityEngine.Object.Destroy(componentsInChildren[i].gameObject);
                }
                return;
            }
            bool flag = true;

            if (this.m_charShipmentRec != null && !PersistentShipmentData.CanPickupShipmentType(this.m_charShipmentRec.ID))
            {
                flag = false;
            }
            int num = 0;

            foreach (WrapperCharacterShipment value in PersistentShipmentData.shipmentDictionary.Values)
            {
                if (value.ShipmentRecID != this.m_charShipmentRec.ID)
                {
                    continue;
                }
                num++;
                break;
            }
            if (num <= 0 || flag)
            {
                this.m_troopSlotsCanvasGroup.alpha          = 1f;
                this.m_troopSlotsCanvasGroup.interactable   = true;
                this.m_troopSlotsCanvasGroup.blocksRaycasts = true;
            }
            else
            {
                this.m_troopSlotsCanvasGroup.alpha          = 0f;
                this.m_troopSlotsCanvasGroup.interactable   = false;
                this.m_troopSlotsCanvasGroup.blocksRaycasts = false;
            }
            int maxShipments = (int)this.m_charShipmentRec.MaxShipments;

            TroopSlot[] troopSlotArray = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
            if ((int)troopSlotArray.Length < maxShipments)
            {
                for (int j = (int)troopSlotArray.Length; j < maxShipments; j++)
                {
                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_troopSlotPrefab);
                    gameObject.transform.SetParent(this.m_troopSlotsRootObject.transform, false);
                    TroopSlot component = gameObject.GetComponent <TroopSlot>();
                    component.SetCharShipment(this.m_charShipmentRec.ID, (ulong)0, 0, false, 0);
                }
            }
            if ((int)troopSlotArray.Length > maxShipments)
            {
                for (int k = maxShipments; k < (int)troopSlotArray.Length; k++)
                {
                    UnityEngine.Object.Destroy(troopSlotArray[k].gameObject);
                }
            }
            troopSlotArray = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
            TroopSlot[] troopSlotArray1 = troopSlotArray;
            for (int l = 0; l < (int)troopSlotArray1.Length; l++)
            {
                TroopSlot troopSlot = troopSlotArray1[l];
                if (troopSlot.GetDBID() != (long)0 && !PersistentShipmentData.shipmentDictionary.ContainsKey(troopSlot.GetDBID()))
                {
                    troopSlot.SetCharShipment(this.m_charShipmentRec.ID, (ulong)0, 0, false, 0);
                }
            }
            foreach (WrapperCharacterShipment wrapperCharacterShipment in PersistentShipmentData.shipmentDictionary.Values)
            {
                if (wrapperCharacterShipment.ShipmentRecID != this.m_charShipmentRec.ID)
                {
                    continue;
                }
                this.SetTroopSlotForPendingShipment(troopSlotArray, wrapperCharacterShipment.ShipmentID);
            }
        }