public static bool AwakePrefix(CharacterQuickSlotManager __instance, ref QuickSlot[] ___m_quickSlots, ref Character ___m_character, ref Transform ___m_quickslotTrans) { ___m_character = __instance.GetComponent <Character>(); ___m_quickslotTrans = __instance.transform.Find("QuickSlots"); // Add our 8 QuickSlots for (var x = 0; x < ExtendedQuickslots.numSlots; ++x) { // Create a GameObject with a name that shouldn't overlap with anything else GameObject gameObject = new GameObject(string.Format("EXQS_{0}", x)); // Add a QuickSlot object and set the name based on how the client will process it QuickSlot qs = gameObject.AddComponent <QuickSlot>(); qs.name = string.Format("{0}", x + 12); // Set the parent so the code below will find the new objects and treat them like the originals gameObject.transform.SetParent(___m_quickslotTrans); } QuickSlot[] componentsInChildren = ___m_quickslotTrans.GetComponentsInChildren <QuickSlot>(); ___m_quickSlots = new QuickSlot[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { int num = int.Parse(componentsInChildren[i].name); ___m_quickSlots[num - 1] = componentsInChildren[i]; ___m_quickSlots[num - 1].Index = num - 1; } for (int j = 0; j < ___m_quickSlots.Length; j++) { ___m_quickSlots[j].SetOwner(___m_character); } return(false); }
private void ClearSkillBar(CharacterQuickSlotManager qsManager) { for (int i = 0; i < numSlots; i++) { qsManager.ClearQuickSlot(i); } }
static bool CharacterQuickSlotManager_Awake_Pre(CharacterQuickSlotManager __instance) { #region quit if (!_extraGamepadQuickslots) { return(true); } #endregion SetupQuickslots(__instance.transform.Find("QuickSlots")); return(true); }
public static void Prefix(CharacterQuickSlotManager __instance, ref Transform ___m_quickslotTrans) { var self = __instance; var trans = self.transform.Find("QuickSlots"); ___m_quickslotTrans = trans; for (int i = 0; i < SlotsToAdd; i++) { GameObject gameObject = new GameObject($"EQS_{i}"); QuickSlot qs = gameObject.AddComponent <QuickSlot>(); qs.name = "" + (i + 12); gameObject.transform.SetParent(trans); } }
public static void Prefix(CharacterQuickSlotManager __instance) { var self = __instance; Transform m_quickslotTrans = self.transform.Find("QuickSlots"); At.SetValue(m_quickslotTrans, typeof(CharacterQuickSlotManager), self, "m_quickslotTrans"); for (int x = 0; x < settings.NumberOfQuickSlotsToAdd; x++) { GameObject gameObject = new GameObject(string.Format("EXQS_{0}", x)); QuickSlot qs = gameObject.AddComponent <QuickSlot>(); qs.name = "" + (x + 12); gameObject.transform.SetParent(m_quickslotTrans); } }
public static void PostQuickSlotInput(CharacterQuickSlotManager __instance, int _index) { try { Character m_character = (Character)AccessTools.Field(typeof(CharacterQuickSlotManager), "m_character").GetValue(__instance); QuickSlot[] m_quickSlots = (QuickSlot[])AccessTools.Field(typeof(CharacterQuickSlotManager), "m_quickSlots").GetValue(__instance); var ext = m_quickSlots[_index]?.RegisteredItem?.GetComponent <QuickSlotSetExt>(); if (m_quickSlots[_index] != null && ext != null && ext.Slots.Count > 0) { foreach (var qs in ext.Slots) { Item skill = m_character.Inventory.SkillKnowledge.GetItemFromItemID(qs.ItemID); if (qs.ItemID == -1) { //__instance.ClearQuickSlot(qs.Index); } else if (skill != null) { __instance.SetQuickSlot(qs.Index, skill); } else { Item it = m_character.Inventory.GetOwnedItems(qs.ItemID).FirstOrDefault(); if (it == null) // Item is not in inventory, perhaps equipped? { if (m_character.LeftHandEquipment?.ItemID == qs.ItemID) { it = m_character.LeftHandEquipment; } else if (m_character.CurrentWeapon?.ItemID == qs.ItemID) { it = m_character.CurrentWeapon; } else // Item is nowhere to be found, create from prefab (downsides expected!) { it = ResourcesPrefabManager.Instance.GetItemPrefab(qs.ItemID); } } __instance.SetQuickSlot(qs.Index, it); } } } } catch (Exception ex) { DynamicQuickslots.Instance.MyLogger.LogError("QuickSlotInput: " + ex.Message); } }
// PopulateSkillBar populates the default-behaviour Outward skill bar with enties from either // quickSlots1[] or quickSlots2[] based on the value of barMode private void PopulateSkillBar(Character character) { CharacterQuickSlotManager qsManager = character.QuickSlotMngr; if (qsManager.isActiveAndEnabled) { CharacterInventory inventory = qsManager.gameObject.GetComponent <CharacterInventory>(); CharacterSkillKnowledge knownSkills = inventory.SkillKnowledge; ItemManager itemManager = ItemManager.Instance; if (dev) { Debug.Log("Populating Skill Bar"); } // The entries we are going to use to populate Outward's default-behaviour skill bar is dependent on // whether we want the first skill bar or the second skill bar switch (charCurrentBarMode[character.UID]) { // In the case where we want entries from the first skill bar... case BarMode.FIRST: ClearSkillBar(qsManager); for (int i = 0; i < numSlots; i++) { if (charQuickSlotArrays[character.UID][0, i] != 0) { // This line loads a skill into the variable called "entry"... var entry = knownSkills.GetItemFromItemID(charQuickSlotArrays[character.UID][0, i]); // ...But if "entry" isn't a skill, load an item instead if (entry == null) { if (inventory.GetOwnedItems(charQuickSlotArrays[character.UID][0, i]).Count() == 0) { entry = ResourcesPrefabManager.Instance.GetItemPrefab(charQuickSlotArrays[character.UID][0, i]); } else { entry = inventory.GetOwnedItems(charQuickSlotArrays[character.UID][0, i]).First(); } } qsManager.SetQuickSlot(i, entry, false); } else { qsManager.ClearQuickSlot(i); } } // We are done doing stuff in the case of the first skill bar, so BREAK! break; // In the case where we want to add entries from the second skill bar... case BarMode.SECOND: ClearSkillBar(qsManager); for (int i = 0; i < numSlots; i++) { if (charQuickSlotArrays[character.UID][1, i] != 0) { // This line loads a skill into the variable called "entry"... var entry = knownSkills.GetItemFromItemID(charQuickSlotArrays[character.UID][1, i]); // ...But if "entry" isn't a skill, load an item instead if (entry == null) { if (inventory.GetOwnedItems(charQuickSlotArrays[character.UID][1, i]).Count() == 0) { entry = ResourcesPrefabManager.Instance.GetItemPrefab(charQuickSlotArrays[character.UID][1, i]); } else { entry = inventory.GetOwnedItems(charQuickSlotArrays[character.UID][1, i]).First(); } } qsManager.SetQuickSlot(i, entry, false); } else { qsManager.ClearQuickSlot(i); } } // We are done doing stuff in the case of the second skill bar, so BREAK! break; } } }
private void CQSManager_OnAssigningQuickSlotHook(On.CharacterQuickSlotManager.orig_OnAssigningQuickSlot_1 orig, CharacterQuickSlotManager qsManager, Item _itemToQuickSlot) { orig(qsManager, _itemToQuickSlot); if (dev) { Debug.Log("ASSIGNING " + _itemToQuickSlot + " to slot index " + _itemToQuickSlot.QuickSlotIndex + " on " + barMode.ToString() + " skill bar"); } if (_itemToQuickSlot.QuickSlotIndex == -1) { Debug.Log("Found the code where _itemToQuickSlot.QuickSlotIndex == -1"); } else { Character character = qsManager.GetComponent <Character>(); SaveSkillSlotByIndex(character, _itemToQuickSlot.QuickSlotIndex, _itemToQuickSlot); } }
private void characterQuickSlotCtor(On.CharacterQuickSlotManager.orig_ctor orig, CharacterQuickSlotManager self) { orig(self); //LoadQuickSlotsFromJSON(self); }
private void SwitchQuickSlot(CharacterQuickSlotManager self) { LoadQuickSlotsFromJSON(self); if (self.isActiveAndEnabled) { if (dev) { Debug.Log("Switching Quick Slots"); } switch (barMode) { //Tab has been pressed while in secondary mode //switch it to default mode case BarMode.DEFAULT: if (dev) { Debug.Log("In Default Mode"); } for (int i = 0; i < slotAmount; i++) { //get a reference to the items current in the bar in secondary mode Item itemFromLastBar = self.GetQuickSlot(i).ActiveItem; //check the replacement item isnt null if (defaultSlotItems[i] != null) { if (dev) { Debug.Log("Switching QuickSlot Index " + i + " from " + itemFromLastBar + " TO " + defaultSlotItems[i]); Debug.Log(itemFromLastBar); } //add these references to temp array SetSecondarySlotArrayAtIndex(i, itemFromLastBar); self.SetQuickSlot(i, defaultSlotItems[i], false); } //if it is null else { //clear the slot if (dev) { Debug.Log("There is no replacement skill for this quick slot, clearing "); } self.ClearQuickSlot(i); } } break; case BarMode.SECONDARY: if (dev) { Debug.Log("In Secondary Mode"); } //Iterate current slots and add them to DefaultSlotArray for (int i = 0; i < slotAmount; i++) { Item itemFromLastBar = self.GetQuickSlot(i).ActiveItem; if (secondarySlotItems[i] != null) { if (dev) { Debug.Log("Switching QuickSlot Index " + i + " from " + itemFromLastBar + " TO " + secondarySlotItems[i]); } SetDefaultSlotArrayAtIndex(i, itemFromLastBar); self.SetQuickSlot(i, secondarySlotItems[i], false); } else { if (dev) { Debug.Log("There is no replacement skill for this quick slot, clearing "); } self.ClearQuickSlot(i); } } break; } } }
private void LoadQuickSlotsFromJSON(CharacterQuickSlotManager self) { CharacterInventory charInvent = self.gameObject.GetComponent <CharacterInventory>(); CharacterSkillKnowledge charSkills = charInvent.SkillKnowledge; ItemManager itemMan = ItemManager.Instance; //Load Quickslots for Bar 1 for (int i = 0; i < slotAmount; i++) { if (dev) { Debug.Log("LOADING QUICK SLOT " + i + " FOR BAR 1"); } var itemID = qsm.currentCharacter["DefaultBarIDS"][i]; if (itemID != 0) { if (dev) { Debug.Log("ID of slot " + i + " from JSON is : " + itemID); } var item = charSkills.GetItemFromItemID(itemID.AsInt); //this isnt a skill if (item == null) { item = charInvent.GetOwnedItems(itemID).First(); } defaultSlotItems[i] = item; } else { if (dev) { Debug.Log("QUICK SLOT " + i + " Has No ID"); } } } for (int i = 0; i < slotAmount; i++) { if (dev) { Debug.Log("LOADING QUICK SLOT " + i + " FOR BAR 2"); } var itemID = qsm.currentCharacter["SecondaryBarIDS"][i]; if (itemID != 0) { if (dev) { Debug.Log("ID of slot " + i + " from JSON is : " + itemID); } var item = charSkills.GetItemFromItemID(itemID.AsInt); //this isnt a skill if (item == null) { item = charInvent.GetOwnedItems(itemID).First(); } secondarySlotItems[i] = item; } else { if (dev) { Debug.Log("QUICK SLOT " + i + " Has No ID"); } } } }
private void onAsignSlotHook(On.CharacterQuickSlotManager.orig_OnAssigningQuickSlot_1 orig, CharacterQuickSlotManager self, Item _itemToQuickSlot) { orig(self, _itemToQuickSlot); if (dev) { Debug.Log("ASSIGNING Quickslot Index" + _itemToQuickSlot.QuickSlotIndex + " to " + _itemToQuickSlot + " on bar mode " + barMode.ToString()); } if (_itemToQuickSlot.QuickSlotIndex == -1) { //Debug.Log("On Assign Quick slot index is -1"); } else { SaveQuickSlotByIndex(_itemToQuickSlot.QuickSlotIndex, _itemToQuickSlot); } //qsm.LoadConfig(); }