static void Postfix(ActionBarGroupSlot __instance)
            {
                var t = __instance.transform;

                if (t == null)
                {
                    return;
                }
                var subgroup = t.Find("SubGroup");

                if (subgroup == null)
                {
                    return;
                }

                var horizontalLayout = subgroup.GetComponent <HorizontalLayoutGroupWorkaround>();

                if (horizontalLayout)
                {
                    UnityEngine.Object.DestroyImmediate(horizontalLayout);
                }

                if (subgroup.GetComponent <GridLayoutGroupWorkaround>() == null)
                {
                    var grid = subgroup.gameObject.AddComponent <GridLayoutGroupWorkaround>();
                }
            }
Пример #2
0
        public static void Postfix(ActionBarGroupSlot __instance, ref List <AbilityData> ___Conversion, ref ButtonPF ___ToggleAdditionalSpells)
        {
            MechanicActionBarSlotItem mechanicActionBarSlotItem = __instance.MechanicSlot as MechanicActionBarSlotItem;

            if (mechanicActionBarSlotItem != null)
            {
                //UnityModManager.Logger.Log("Rua 1");
                var     itemType   = mechanicActionBarSlotItem.Item.Blueprint.Type;
                int     spellLevel = mechanicActionBarSlotItem.Item.Blueprint.SpellLevel;
                Ability ability    = mechanicActionBarSlotItem.Item.Ability;
                //UnityModManager.Logger.Log("Rua 2");
                if (spellLevel >= 2 && ability != null && (itemType == UsableItemType.Potion || itemType == UsableItemType.Scroll || itemType == UsableItemType.Wand))
                {
                    //UnityModManager.Logger.Log("Rua 3");
                    var unit = mechanicActionBarSlotItem.Item.Owner;
                    //UnityModManager.Logger.Log("Rua 4");
                    foreach (Ability _ability in unit.Abilities)
                    {
                        if (_ability.Blueprint.GetComponent <ConsumeItemComponent>() != null && mechanicActionBarSlotItem.Item.Ability != null)
                        {
                            //UnityModManager.Logger.Log("Rua 5");
                            AbilityData abld = new AbilityData(_ability)
                            {
                                ParamSpellSlot = new SpellSlot {
                                    Spell = new AbilityData(ability)
                                }
                                //PotionForOther = true
                            };
                            //UnityModManager.Logger.Log("Rua 6");
                            if (mechanicActionBarSlotItem.Item.Blueprint.Type == UsableItemType.Potion)
                            {
                                // if it's potion, ___Conversion has become  { [give others potion ability]} before this Postfix.
                                ___Conversion.Add(abld);
                            }
                            else
                            {
                                //elsewise, create a new ___Conversion list.
                                ___Conversion = new List <AbilityData>()
                                {
                                    abld
                                };
                            }
                            //UnityModManager.Logger.Log($"Rua 7: Conversion has {___Conversion.Count} elements");
                            //UnityModManager.Logger.Log("Rua 8");
                            if (___ToggleAdditionalSpells != null)
                            {
                                ___ToggleAdditionalSpells.gameObject.SetActive(true);
                            }
                            //UnityModManager.Logger.Log("Rua 9");
                        }
                    }
                }
            }
        }
Пример #3
0
        static public void Postfix(ActionBarGroupSlot __instance, ref ActionBarSpellsGroup ___SubGroup, ref UnitEntityData ___Selected, ref List <AbilityData> ___Conversion)
        {
            MechanicActionBarSlotItem mechanicActionBarSlotItem = __instance.MechanicSlot as MechanicActionBarSlotItem;

            if (mechanicActionBarSlotItem != null && (mechanicActionBarSlotItem.Item.Blueprint.Type == UsableItemType.Scroll || mechanicActionBarSlotItem.Item.Blueprint.Type == UsableItemType.Wand))
            {
                Ability ability = mechanicActionBarSlotItem.Item.Ability;
                if (ability != null)
                {
                    if (___SubGroup != null)
                    {
                        ___SubGroup.Toggle(___Selected, ___Conversion, ability.Data);
                    }
                }
            }
        }
Пример #4
0
        static public void Postfix(ActionBarGroupSlot __instance, AbilityData spell, ref List <AbilityData> ___Conversion, ref ButtonPF ___ToggleAdditionalSpells)
        {
            //if (spell == null) UnityModManager.Logger.Log("Rua! spel is null!!!");
            Spellbook spellbook = spell.Spellbook;

            if (spellbook != null)
            {
                //UnityModManager.Logger.Log($"spellbook is {spellbook.Blueprint.Name}");
                MechanicActionBarSlotSpontaneusSpell mechanicActionBarSlotSpontaneusSpell = __instance.MechanicSlot as MechanicActionBarSlotSpontaneusSpell;
                SpellSlot spellSlot2 = (mechanicActionBarSlotSpontaneusSpell != null) ? mechanicActionBarSlotSpontaneusSpell.Spell.ParamSpellSlot : null;
                //if (mechanicActionBarSlotSpontaneusSpell == null) UnityModManager.Logger.Log("mechanicABSSS is null");
                //if (spellSlot2 == null) UnityModManager.Logger.Log("spellslot2 is null");
                if (spellSlot2 != null)
                {
                    //UnityModManager.Logger.Log("miaomiao1!!!");
                    foreach (Ability ability2 in spell.Caster.Abilities)
                    {
                        if (ability2.Blueprint.GetComponent <FastStudyComponent>())
                        {
                            //UnityModManager.Logger.Log($"Rua, have fast study.");
                            //UnityModManager.Logger.Log($"spell is {spell.Name}");
                            AbilityData item2 = new AbilityData(ability2)
                            {
                                ParamSpellSlot  = spellSlot2,
                                ParamSpellLevel = spell.SpellLevel,
                                ParamSpellbook  = spellbook
                            };
                            ___Conversion.Add(item2);
                        }
                    }
                }
                //UnityModManager.Logger.Log("miaomiao2!!!");
                BlueprintAbility spellBlueprint = spell.Blueprint;
                if (___Conversion.Any((AbilityData s) => s.Blueprint != spellBlueprint) || (spellBlueprint.Variants != null && spellBlueprint.Variants.Any <BlueprintAbility>()))
                {
                    if (___ToggleAdditionalSpells != null)
                    {
                        ___ToggleAdditionalSpells.gameObject.SetActive(true);
                    }
                }
            }
        }
            static bool Prefix(ActionBarGroupSlot __instance, ref List <AbilityData> ___Conversion, ref ButtonPF ___ToggleAdditionalSpells, AbilityData spell)
            {
                Spellbook spellBook = spell.Spellbook;

                if (spellBook == null)
                {
                    return(false);
                }
                ___Conversion = spellBook.GetSpontaneousConversionSpells(spell).EmptyIfNull <BlueprintAbility>().Select <BlueprintAbility, AbilityData>((Func <BlueprintAbility, AbilityData>)(b => new AbilityData(b, spellBook)
                {
                    ConvertedFrom = spell
                })).ToList <AbilityData>();
                SpellSlot spellSlot = (__instance.MechanicSlot as MechanicActionBarSlotMemorizedSpell)?.SpellSlot;

                if (spellSlot != null)
                {
                    foreach (Ability ability in spell.Caster.Abilities)
                    {
                        if (ability.Blueprint.GetComponent <AbilityRestoreSpellSlot>() != null)
                        {
                            ___Conversion.Add(new AbilityData(ability)
                            {
                                ParamSpellSlot = spellSlot
                            });
                        }

                        var store_spell = ability.Blueprint.GetComponent <AbilityConvertSpell>();
                        if (store_spell != null && store_spell.canBeUsedOn(spell))
                        {
                            ___Conversion.Add(new AbilityData(ability)
                            {
                                ParamSpellSlot = spellSlot
                            });
                        }
                    }
                }
                AbilityData paramSpell = (__instance.MechanicSlot as MechanicActionBarSlotSpontaneusSpell)?.Spell;

                if (paramSpell != null)
                {
                    SpellSlot paramSpellSlot = new SpellSlot(paramSpell.SpellLevel, SpellSlotType.Common, 0); //create fake slot for AbilityConvertSpell
                    paramSpellSlot.Spell = paramSpell;
                    foreach (Ability ability in spell.Caster.Abilities)
                    {
                        if (ability.Blueprint.GetComponent <AbilityRestoreSpontaneousSpell>() != null) //try with spontnaeous convert spell
                        {
                            ___Conversion.Add(new AbilityData(ability)
                            {
                                ParamSpellbook  = paramSpell.Spellbook,
                                ParamSpellLevel = new int?(paramSpell.SpellLevel)
                            });
                        }

                        var store_spell = ability.Blueprint.GetComponent <AbilityConvertSpell>();
                        if (store_spell != null && store_spell.canBeUsedOn(spell))
                        {
                            ___Conversion.Add(new AbilityData(ability)
                            {
                                ParamSpellSlot = paramSpellSlot
                            });
                        }
                    }
                }
                BlueprintAbility spellBlueprint = spell.Blueprint;

                if (!___Conversion.Any <AbilityData>((Func <AbilityData, bool>)(s => s.Blueprint != spellBlueprint)) && (spellBlueprint.Variants == null || !(spellBlueprint.Variants).Any <BlueprintAbility>()) || ___ToggleAdditionalSpells == null)
                {
                    return(false);
                }
                ___ToggleAdditionalSpells.gameObject.SetActive(true);
                return(false);
            }