void Awake() { _button = gameObject.GetComponent <ButtonPF>(); _button.onClick.AddListener(new UnityAction(HandleOnClick)); _button.OnRightClick.AddListener(new UnityAction(HandleOnRightClick)); _button.OnEnter.AddListener(new UnityAction(HandleOnEnter)); _button.OnExit.AddListener(new UnityAction(HandleOnExit)); _label = gameObject.transform.Find("HeaderInActive").gameObject.GetComponent <TextMeshProUGUI>(); _labelActive = gameObject.transform.Find("HeaderActive").gameObject.GetComponent <TextMeshProUGUI>(); _colors = new Color[] { UIRoot.Instance.GetQuestNotificationObjectiveColor(QuestObjectiveState.None).AddendumColor.linear, UIRoot.Instance.GetQuestNotificationObjectiveColor(QuestObjectiveState.Completed).AddendumColor.linear, UIRoot.Instance.GetQuestNotificationObjectiveColor(QuestObjectiveState.Started).AddendumColor.linear, UIRoot.Instance.GetQuestNotificationObjectiveColor(QuestObjectiveState.Failed).AddendumColor.linear }; _mask = gameObject.transform.Find("BackgroundInActive/Highlight").gameObject.GetComponent <Image>(); _maskActive = gameObject.transform.Find("BackgroundActive/Highlight").gameObject.GetComponent <Image>(); _markIsThisRound = gameObject.transform.Find("BackgroundInActive/Decal").gameObject; _iconIsFlatFooted = gameObject.transform.Find("IsFlatFooted").gameObject; _iconIsUnableToAct = gameObject.transform.Find("IsUnableToAct").gameObject; _iconIsSurprising = gameObject.transform.Find("IsSurprising").gameObject; _iconStandardAction = gameObject.transform.Find("StandardAction").gameObject; _iconMoveAction = gameObject.transform.Find("MoveAction").gameObject; _iconSwiftAction = gameObject.transform.Find("SwiftAction").gameObject; _objects = new GameObject[] { gameObject.transform.Find("BackgroundInActive").gameObject, gameObject.transform.Find("HeaderInActive").gameObject, }; _objectsActive = new GameObject[] { gameObject.transform.Find("BackgroundActive").gameObject, gameObject.transform.Find("HeaderActive").gameObject, }; }
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); }
public static CombatTrackerManager CreateObject() { UICommon uiCommon = Game.Instance.UI.Common; GameObject hudLayout = uiCommon?.transform.Find("HUDLayout")?.gameObject; GameObject escMenuButtonBlock = uiCommon?.transform.Find("EscMenuWindow/Window/ButtonBlock")?.gameObject; if (!hudLayout || !escMenuButtonBlock) { return(null); } // initialize window GameObject combatTracker = new GameObject("TurnBasedUpdatedCombatTracker", typeof(RectTransform), typeof(CanvasGroup)); combatTracker.transform.SetParent(hudLayout.transform); combatTracker.transform.SetSiblingIndex(0); RectTransform rectCombatTracker = (RectTransform)combatTracker.transform; rectCombatTracker.anchorMin = new Vector2(0f, 0f); rectCombatTracker.anchorMax = new Vector2(1f, 1f); rectCombatTracker.pivot = new Vector2(1f, 1f); rectCombatTracker.position = Camera.current.ScreenToWorldPoint (new Vector3(Screen.width, Screen.height, Camera.current.WorldToScreenPoint(hudLayout.transform.position).z)); rectCombatTracker.position -= rectCombatTracker.forward; rectCombatTracker.rotation = Quaternion.identity; // initialize body GameObject body = Instantiate(escMenuButtonBlock, combatTracker.transform, false); body.name = "Body"; Image imgBody = body.GetComponent <Image>(); Image imgMetamagic = uiCommon.transform.Find("ServiceWindow/SpellBook/ContainerNoBook/Background")?.gameObject.GetComponent <Image>(); if (imgMetamagic) { imgBody.sprite = imgMetamagic.sprite; } RectTransform rectBody = (RectTransform)body.transform; rectBody.anchorMin = new Vector2(1f, 1f); rectBody.anchorMax = new Vector2(1f, 1f); rectBody.pivot = new Vector2(1f, 1f); rectBody.localPosition = new Vector3(0f, 0f, 0f); rectBody.rotation = Quaternion.identity; ContentSizeFitter contentSizeFitter = body.AddComponent <ContentSizeFitter>(); contentSizeFitter.horizontalFit = ContentSizeFitter.FitMode.Unconstrained; contentSizeFitter.verticalFit = ContentSizeFitter.FitMode.MinSize; VerticalLayoutGroup verticalLayoutGroup = body.GetComponent <VerticalLayoutGroup>(); verticalLayoutGroup.childAlignment = TextAnchor.UpperRight; verticalLayoutGroup.childControlWidth = true; verticalLayoutGroup.childControlHeight = false; verticalLayoutGroup.childForceExpandWidth = true; verticalLayoutGroup.childForceExpandHeight = false; // initialize special action buttons GameObject actionButtons = new GameObject("SpecialActionButtons", typeof(RectTransform)); RectTransform rectActionButtons = (RectTransform)actionButtons.transform; rectActionButtons.SetParent(rectBody, false); rectActionButtons.pivot = new Vector2(1f, 1f); rectActionButtons.sizeDelta = new Vector2(0f, UNIT_BUTTON_HEIGHT * 2); rectActionButtons.SetSiblingIndex(0); void SetActionButton(ButtonPF button, string name, float left, float buttom, float right, float top) { button.name = name; button.transform.SetParent(rectActionButtons, false); RectTransform rect = (RectTransform)button.transform; rect.anchoredPosition = new Vector2(0f, 0f); rect.anchorMin = new Vector2(left, buttom); rect.anchorMax = new Vector2(right, top); rect.pivot = new Vector2(1f, 1f); rect.rotation = Quaternion.identity; rect.sizeDelta = new Vector2(0f, 0f); } // ... end turn button ButtonPF buttonEndTurn = body.transform.Find("Btn_Quit").gameObject.GetComponent <ButtonPF>(); SetActionButton(buttonEndTurn, "Button_EndTurn", 0.5f, 0.5f, 1f, 1f); // ... delay turn button ButtonPF buttonDelay = body.transform.Find("Btn_Save").gameObject.GetComponent <ButtonPF>(); SetActionButton(buttonDelay, "Button_Delay", 0.5f, 0f, 1f, 0.5f); // ... 5-foot step button ButtonPF buttonFiveFoorStep = body.transform.Find("Btn_Load").gameObject.GetComponent <ButtonPF>(); SetActionButton(buttonFiveFoorStep, "Button_FiveFootStep", 0f, 0f, 0.5f, 0.5f); // ... full-attack button ButtonPF buttonFullAttack = body.transform.Find("Btn_Options").gameObject.GetComponent <ButtonPF>(); SetActionButton(buttonFullAttack, "Button_FullAttack", 0f, 0.5f, 0.5f, 1f); // initialize separator RectTransform rectSeparator = body.transform.Find("Separator") as RectTransform; rectSeparator.pivot = new Vector2(1f, 1f); rectSeparator.sizeDelta = new Vector2(0f, UNIT_BUTTON_SPACE); // clear unused buttons for (int i = body.transform.childCount - 1; i >= 0; i--) { GameObject child = body.transform.GetChild(i).gameObject; if (child.name != "SpecialActionButtons" && child.name != "Separator") { child.SafeDestroy(); } } // initialize button block (unit buttons) GameObject unitButtons = new GameObject("UnitButtons", typeof(RectTransform)); RectTransform rectUnitButtons = (RectTransform)unitButtons.transform; rectUnitButtons.SetParent(rectBody, false); rectUnitButtons.pivot = new Vector2(1f, 1f); return(combatTracker.AddComponent <CombatTrackerManager>()); }
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"); } } } } }
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); } } } }