Exemple #1
0
        static void Postfix(PartyVM __instance)
        {
            if (!PartyManagerSettings.Settings.DisableUpdatedTroopLabel)
            {
                try
                {
                    GenericHelpers.LogDebug("PartyVM RefreshPartyInformation Patch", "Post called");
                    var logic = __instance.GetPartyScreenLogic();

                    if (logic == null)
                    {
                        GenericHelpers.LogDebug("RefreshPartyInformation.Postfix", "Logic null, skipping party label update");
                        return;
                    }

                    if (__instance.MainPartyTroops != null && logic?.RightOwnerParty?.PartySizeLimit != null)
                    {
                        __instance.MainPartyTroopsLbl = GetPMPartyListLabel(__instance.MainPartyTroopsLbl, __instance.MainPartyTroops, logic.RightOwnerParty.PartySizeLimit);
                    }

                    if (__instance.OtherPartyTroops != null && logic?.LeftOwnerParty?.PartySizeLimit != null)
                    {
                        __instance.OtherPartyTroopsLbl = GetPMPartyListLabel(__instance.OtherPartyTroopsLbl, __instance.OtherPartyTroops, logic.LeftOwnerParty.PartySizeLimit);
                    }
                }
                catch (Exception e)
                {
                    GenericHelpers.LogException("updateTroopLabelsPatch", e);
                }
            }
        }
Exemple #2
0
        public void TransferPrisoners(bool fromLeft)
        {
            try
            {
                List <PartyCharacterVM> prisoners;

                if (fromLeft)
                {
                    prisoners = _partyVM.OtherPartyPrisoners.ToList();
                }
                else
                {
                    prisoners = _partyVM.MainPartyPrisoners.ToList();
                }

                if (_partyLogic.PrisonerTransferState == PartyScreenLogic.TransferState.TransferableWithTrade && PartyManagerSettings.Settings.RansomPrisonersUseWhitelist)
                {
                    prisoners = prisoners.Where(x => PartyManagerSettings.Settings.RansomPrisonerBlackWhiteList
                                                .Contains(x.Character.Name.ToString())).ToList();
                }
                else if (_partyLogic.PrisonerTransferState == PartyScreenLogic.TransferState.TransferableWithTrade)
                {
                    prisoners = prisoners.Where(x => !PartyManagerSettings.Settings.RansomPrisonerBlackWhiteList
                                                .Contains(x.Character.Name.ToString())).ToList();
                }
                else if (PartyManagerSettings.Settings.TransferPrisonersUseWhitelist)
                {
                    prisoners = prisoners.Where(x => PartyManagerSettings.Settings.TransferPrisonerBlackWhiteList
                                                .Contains(x.Character.Name.ToString())).ToList();
                }
                else
                {
                    prisoners = prisoners.Where(x => !PartyManagerSettings.Settings.TransferPrisonerBlackWhiteList
                                                .Contains(x.Character.Name.ToString())).ToList();
                }


                foreach (var prisoner in prisoners)
                {
                    TransferUnit(prisoner, fromLeft);
                }
                _partyVM.ExecuteRemoveZeroCounts();
            }
            catch (Exception e)
            {
                GenericHelpers.LogException("TransferPrisonersLeft", e);
            }
        }
Exemple #3
0
 public void UpdateValue(SelectorVM <SelectorItemVM> selector)
 {
     try
     {
         if (selector.SelectedIndex < 0)
         {
             return;
         }
         var selectedOption = _dropdownOptions[selector.SelectedIndex];
         var newValue       = ConvertToT(selectedOption, _initialValue);
         Value = newValue;
         _updateCall(Value);
     }
     catch (Exception ex)
     {
         GenericHelpers.LogException($"StringOptionDataVM.{_name}.UpdateValue", ex);
     }
 }
Exemple #4
0
        internal T ConvertToT <R>(R input, T oldValue)
        {
            try
            {
                if (typeof(T) == typeof(CustomSortOrder))
                {
                    return((T)Enum.Parse(typeof(CustomSortOrder), input.ToString()));
                }
                else
                {
                    return((T)Convert.ChangeType(input, typeof(T)));
                }
            }
            catch (Exception ex)
            {
                GenericHelpers.LogException("ConvertToT", ex);
            }

            return(oldValue);
        }
        static bool Prefix(PartyVM __instance, SelectorVM <SelectorItemVM> s)
        {
            try
            {
                if (!__instance.CurrentCharacter.IsPrisoner && s.SelectedIndex != (int)__instance.CurrentCharacter.Character.CurrentFormationClass)
                {
                    var newFormation   = (FormationClass)s.SelectedIndex;
                    var name           = __instance.CurrentCharacter.Character.Name.ToString();
                    var savedFormation = new SavedFormation()
                    {
                        TroopName = name, Formation = newFormation
                    };
                    PartyManagerSettings.Settings.SavedFormations[name] = savedFormation;
                    PartyManagerSettings.Settings.SaveSettings();
                    GenericHelpers.LogDebug("PartyVMUpdateCurrentCharacterFormationPatch", $"{name}:{newFormation}");
                }
            }
            catch (Exception e)
            {
                GenericHelpers.LogException("PartyVMUpdateCurrentCharacterFormationPatch", e);
            }

            return(true);
        }