private void HandleShipmentAdded(int charShipmentID, ulong shipmentDBID)
 {
     if (charShipmentID == this.m_shipmentType.CharShipmentID)
     {
         TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>();
         TroopSlot[] array = componentsInChildren;
         for (int i = 0; i < array.Length; i++)
         {
             TroopSlot troopSlot = array[i];
             if (troopSlot.GetDBID() == shipmentDBID)
             {
                 return;
             }
         }
         TroopSlot[] array2 = componentsInChildren;
         for (int j = 0; j < array2.Length; j++)
         {
             TroopSlot troopSlot2 = array2[j];
             if (troopSlot2.IsEmpty())
             {
                 troopSlot2.SetCharShipment(charShipmentID, shipmentDBID, 0, true, 0);
                 break;
             }
         }
         this.UpdateRecruitButtonState();
     }
 }
    private void UpdateItemSlots()
    {
        int maxShipments = (int)this.m_charShipmentRec.MaxShipments;

        TroopSlot[] componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
        if (componentsInChildren.Length < maxShipments)
        {
            for (int i = componentsInChildren.Length; i < maxShipments; i++)
            {
                GameObject gameObject = Object.Instantiate <GameObject>(this.m_troopSlotPrefab);
                gameObject.get_transform().SetParent(this.m_troopSlotsRootObject.get_transform(), false);
                TroopSlot component = gameObject.GetComponent <TroopSlot>();
                component.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, 0, false, 0);
            }
        }
        if (componentsInChildren.Length > maxShipments)
        {
            for (int j = maxShipments; j < componentsInChildren.Length; j++)
            {
                Object.DestroyImmediate(componentsInChildren[j].get_gameObject());
            }
        }
        componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
        TroopSlot[] array = componentsInChildren;
        for (int k = 0; k < array.Length; k++)
        {
            TroopSlot troopSlot = array[k];
            if (troopSlot.GetDBID() != 0uL && !PersistentShipmentData.shipmentDictionary.ContainsKey(troopSlot.GetDBID()))
            {
                troopSlot.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, 0, false, 0);
            }
        }
        IEnumerator enumerator = PersistentShipmentData.shipmentDictionary.get_Values().GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                JamCharacterShipment jamCharacterShipment = (JamCharacterShipment)enumerator.get_Current();
                if (jamCharacterShipment.ShipmentRecID == this.m_shipmentType.CharShipmentID)
                {
                    this.SetTroopSlotForPendingShipment(componentsInChildren, jamCharacterShipment.ShipmentID);
                }
            }
        }
        finally
        {
            IDisposable disposable = enumerator as IDisposable;
            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
    }
 private void SetTroopSlotForPendingShipment(TroopSlot[] troopSlots, ulong shipmentDBID)
 {
     for (int i = 0; i < troopSlots.Length; i++)
     {
         TroopSlot troopSlot = troopSlots[i];
         if (troopSlot.GetDBID() == shipmentDBID)
         {
             return;
         }
     }
     for (int j = 0; j < troopSlots.Length; j++)
     {
         TroopSlot troopSlot2 = troopSlots[j];
         if (troopSlot2.IsEmpty())
         {
             troopSlot2.SetCharShipment(this.m_shipmentType.CharShipmentID, shipmentDBID, 0, true, 0);
             return;
         }
     }
 }
 private void SetTroopSlotForExistingFollower(TroopSlot[] troopSlots, JamGarrisonFollower follower)
 {
     if (follower.Durability <= 0)
     {
         return;
     }
     for (int i = 0; i < troopSlots.Length; i++)
     {
         TroopSlot troopSlot       = troopSlots[i];
         int       ownedFollowerID = troopSlot.GetOwnedFollowerID();
         if (ownedFollowerID != 0 && ownedFollowerID == follower.GarrFollowerID)
         {
             return;
         }
     }
     for (int j = 0; j < troopSlots.Length; j++)
     {
         TroopSlot troopSlot2 = troopSlots[j];
         if (troopSlot2.IsCollected())
         {
             GarrFollowerRec record         = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID);
             int             iconFileDataID = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? record.AllianceIconFileDataID : record.HordeIconFileDataID;
             troopSlot2.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, follower.GarrFollowerID, false, iconFileDataID);
             return;
         }
     }
     for (int k = 0; k < troopSlots.Length; k++)
     {
         TroopSlot troopSlot3 = troopSlots[k];
         if (troopSlot3.IsEmpty())
         {
             GarrFollowerRec record2         = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID);
             int             iconFileDataID2 = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? record2.AllianceIconFileDataID : record2.HordeIconFileDataID;
             troopSlot3.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, follower.GarrFollowerID, false, iconFileDataID2);
             return;
         }
     }
 }
    private void UpdateTroopSlots()
    {
        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.get_transform().SetParent(this.m_troopSlotsRootObject.get_transform(), false);
                TroopSlot component = gameObject.GetComponent <TroopSlot>();
                component.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, 0, false, 0);
            }
        }
        if (componentsInChildren.Length > maxTroops)
        {
            for (int j = maxTroops; j < componentsInChildren.Length; j++)
            {
                Object.DestroyImmediate(componentsInChildren[j].get_gameObject());
            }
        }
        componentsInChildren = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
        TroopSlot[] array = componentsInChildren;
        for (int k = 0; k < array.Length; k++)
        {
            TroopSlot troopSlot       = array[k];
            int       ownedFollowerID = troopSlot.GetOwnedFollowerID();
            if (ownedFollowerID != 0 && (!PersistentFollowerData.followerDictionary.ContainsKey(ownedFollowerID) || PersistentFollowerData.followerDictionary.get_Item(ownedFollowerID).Durability == 0))
            {
                troopSlot.SetCharShipment(this.m_shipmentType.CharShipmentID, 0uL, 0, false, 0);
            }
        }
        uint num = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? this.m_followerRec.AllianceGarrClassSpecID : this.m_followerRec.HordeGarrClassSpecID;

        using (Dictionary <int, JamGarrisonFollower> .ValueCollection.Enumerator enumerator = PersistentFollowerData.followerDictionary.get_Values().GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                JamGarrisonFollower current = enumerator.get_Current();
                GarrFollowerRec     record  = StaticDB.garrFollowerDB.GetRecord(current.GarrFollowerID);
                uint num2 = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? record.AllianceGarrClassSpecID : record.HordeGarrClassSpecID;
                if (num2 == num && current.Durability > 0)
                {
                    this.SetTroopSlotForExistingFollower(componentsInChildren, current);
                }
            }
        }
        CharShipmentRec record2     = StaticDB.charShipmentDB.GetRecord(this.m_shipmentType.CharShipmentID);
        IEnumerator     enumerator2 = PersistentShipmentData.shipmentDictionary.get_Values().GetEnumerator();

        try
        {
            while (enumerator2.MoveNext())
            {
                JamCharacterShipment jamCharacterShipment = (JamCharacterShipment)enumerator2.get_Current();
                if (jamCharacterShipment.ShipmentRecID == this.m_shipmentType.CharShipmentID)
                {
                    this.SetTroopSlotForPendingShipment(componentsInChildren, jamCharacterShipment.ShipmentID);
                }
                else
                {
                    CharShipmentRec record3 = StaticDB.charShipmentDB.GetRecord(jamCharacterShipment.ShipmentRecID);
                    if (record3.ContainerID == record2.ContainerID)
                    {
                        this.SetTroopSlotForPendingShipment(componentsInChildren, jamCharacterShipment.ShipmentID);
                    }
                }
            }
        }
        finally
        {
            IDisposable disposable = enumerator2 as IDisposable;
            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
    }
Beispiel #6
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.DestroyImmediate(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 = (GarrisonStatus.Faction() != PVP_FACTION.HORDE) ? this.m_followerRec.AllianceGarrClassSpecID : this.m_followerRec.HordeGarrClassSpecID;

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

        try
        {
            while (enumerator2.MoveNext())
            {
                object obj = enumerator2.Current;
                JamCharacterShipment jamCharacterShipment = (JamCharacterShipment)obj;
                if (jamCharacterShipment.ShipmentRecID == this.m_charShipmentRec.ID)
                {
                    this.SetTroopSlotForPendingShipment(componentsInChildren, jamCharacterShipment.ShipmentID);
                }
                else
                {
                    CharShipmentRec record3 = StaticDB.charShipmentDB.GetRecord(jamCharacterShipment.ShipmentRecID);
                    if (record3.ContainerID == record2.ContainerID)
                    {
                        this.SetTroopSlotForPendingShipment(componentsInChildren, jamCharacterShipment.ShipmentID);
                    }
                }
            }
        }
        finally
        {
            IDisposable disposable;
            if ((disposable = (enumerator2 as IDisposable)) != null)
            {
                disposable.Dispose();
            }
        }
    }
Beispiel #7
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.DestroyImmediate(componentsInChildren[i].gameObject);
            }
            return;
        }
        bool flag = true;

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

        try
        {
            while (enumerator.MoveNext())
            {
                object obj = enumerator.Current;
                JamCharacterShipment jamCharacterShipment = (JamCharacterShipment)obj;
                if (jamCharacterShipment.ShipmentRecID == this.m_charShipmentRec.ID)
                {
                    num++;
                    break;
                }
            }
        }
        finally
        {
            IDisposable disposable;
            if ((disposable = (enumerator as IDisposable)) != null)
            {
                disposable.Dispose();
            }
        }
        if ((num > 0 && !flag) || (this.m_isArtifactResearch && ArtifactKnowledgeData.s_artifactKnowledgeInfo != null && ArtifactKnowledgeData.s_artifactKnowledgeInfo.CurrentLevel >= ArtifactKnowledgeData.s_artifactKnowledgeInfo.MaxLevel))
        {
            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 num2 = (int)this.m_charShipmentRec.MaxShipments;

        if (this.m_isArtifactResearch && ArtifactKnowledgeData.s_artifactKnowledgeInfo != null)
        {
            int num3 = ArtifactKnowledgeData.s_artifactKnowledgeInfo.MaxLevel - ArtifactKnowledgeData.s_artifactKnowledgeInfo.CurrentLevel;
            if (num3 > 0 && num3 < num2)
            {
                num2 = num3;
            }
        }
        TroopSlot[] componentsInChildren2 = this.m_troopSlotsRootObject.GetComponentsInChildren <TroopSlot>(true);
        if (componentsInChildren2.Length < num2)
        {
            for (int j = componentsInChildren2.Length; j < num2; 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 > num2)
        {
            for (int k = num2; k < componentsInChildren2.Length; k++)
            {
                Object.DestroyImmediate(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);
            }
        }
        IEnumerator enumerator2 = PersistentShipmentData.shipmentDictionary.Values.GetEnumerator();

        try
        {
            while (enumerator2.MoveNext())
            {
                object obj2 = enumerator2.Current;
                JamCharacterShipment jamCharacterShipment2 = (JamCharacterShipment)obj2;
                if (jamCharacterShipment2.ShipmentRecID == this.m_charShipmentRec.ID)
                {
                    this.SetTroopSlotForPendingShipment(componentsInChildren2, jamCharacterShipment2.ShipmentID);
                }
            }
        }
        finally
        {
            IDisposable disposable2;
            if ((disposable2 = (enumerator2 as IDisposable)) != null)
            {
                disposable2.Dispose();
            }
        }
    }