/// <summary> /// Register for any interested events. /// </summary> public override void Awake() { base.Awake(); m_ItemSetManager = m_GameObject.GetCachedComponent <ItemSetManager>(); // If the CategoryID is 0 then the category hasn't been initialized. Use the first category index. if (m_ItemSetCategoryID == 0 && m_ItemSetManager.CategoryItemSets.Length > 0) { m_ItemSetCategoryID = m_ItemSetManager.CategoryItemSets[0].CategoryID; } m_ItemSetCategoryIndex = m_ItemSetManager.CategoryIDToIndex(m_ItemSetCategoryID); var equipUnequipAbilities = GetAbilities <EquipUnequip>(); if (equipUnequipAbilities != null) { // The ItemSet CategoryID must match for the ToggleEquip ability to be able to use the EquipUnequip ability. for (int i = 0; i < equipUnequipAbilities.Length; ++i) { if (equipUnequipAbilities[i].ItemSetCategoryID == m_ItemSetCategoryID) { m_EquipUnequipItemAbility = equipUnequipAbilities[i]; break; } } } }
/// <summary> /// Retrieves the equip unequip ability. /// </summary> public override void OnStart() { var target = GetDefaultGameObject(m_TargetGameObject.Value); if (target != m_PrevTarget) { m_CharacterLocomotion = target.GetCachedComponent <UltimateCharacterLocomotion>(); // Find the specified ability. var abilities = m_CharacterLocomotion.GetAbilities <EquipUnequip>(); // The category ID must match. for (int i = 0; i < abilities.Length; ++i) { if (abilities[i].ItemSetCategoryID == m_CategoryID.Value) { m_EquipUnequip = abilities[i]; break; } } if (m_EquipUnequip == null) { Debug.LogWarning("Error: Unable to find a Equip Unequip ability with category id " + m_CategoryID.Value); return; } m_PrevTarget = target; } }
/// <summary> /// Initializes the default values. /// </summary> /// <param name="gameObject">The GameObject this object is attached to.</param> /// <param name="itemSetManager">The ItemSetManager which owns the ItemSet.</param> /// <param name="categoryID">The ID of the category that the ItemSet belongs to.</param> /// <param name="categoryIndex">The index of the category that the ItemSet belongs to.</param> /// <param name="index">The index of the ItemSet.</param> public void Initialize(GameObject gameObject, ItemSetManagerBase itemSetManager, uint categoryID, int categoryIndex, int index) { // The ItemSet may have already been initialized. if (m_ItemSetManager != null) { return; } base.Initialize(gameObject); m_ItemSetManager = itemSetManager; var toggleEquipAbilities = gameObject.GetCachedComponent <UltimateCharacterLocomotion>().GetAbilities <ToggleEquip>(); if (toggleEquipAbilities != null) { for (int i = 0; i < toggleEquipAbilities.Length; ++i) { if (toggleEquipAbilities[i].ItemSetCategoryID == categoryID) { m_ToggleEquip = toggleEquipAbilities[i]; break; } } } var equipUnequipAbilities = gameObject.GetCachedComponent <UltimateCharacterLocomotion>().GetAbilities <EquipUnequip>(); if (equipUnequipAbilities != null) { for (int i = 0; i < equipUnequipAbilities.Length; ++i) { if (equipUnequipAbilities[i].ItemSetCategoryID == categoryID) { m_EquipUnequip = equipUnequipAbilities[i]; break; } } } m_CategoryIndex = categoryIndex; m_Index = index; if (m_ItemIdentifiers == null) { m_ItemIdentifiers = new IItemIdentifier[m_Slots.Length]; } }
/// <summary> /// Initializes the default values. /// </summary> /// <param name="gameObject">The GameObject this object is attached to.</param> /// <param name="itemSetManager">The ItemSetManager which owns the ItemSet.</param> /// <param name="categoryID">The ID of the category that the ItemSet belongs to.</param> /// <param name="categoryIndex">The index of the category that the ItemSet belongs to.</param> /// <param name="index">The index of the ItemSet.</param> public void Initialize(GameObject gameObject, ItemSetManagerBase itemSetManager, uint categoryID, int categoryIndex, int index) { // The ItemSet may have already been initialized. if (m_ItemSetManager != null) { return; } base.Initialize(gameObject); m_ItemSetManager = itemSetManager; var equipUnequipAbilities = gameObject.GetCachedComponent <UltimateCharacterLocomotion>().GetAbilities <EquipUnequip>(); if (equipUnequipAbilities != null) { for (int i = 0; i < equipUnequipAbilities.Length; ++i) { if (equipUnequipAbilities[i].ItemSetCategoryID == categoryID) { m_EquipUnequip = equipUnequipAbilities[i]; break; } } } m_CategoryIndex = categoryIndex; m_Index = index; if (m_ItemIdentifiers == null) { m_ItemIdentifiers = new IItemIdentifier[m_Slots.Length]; } m_EmptyItemSet = true; for (int i = 0; i < m_Slots.Length; ++i) { if (m_Slots[i] != null) { m_EmptyItemSet = false; return; } } EventHandler.RegisterEvent <int, int>(m_ItemSetManager.gameObject, "OnItemSetManagerUpdateItemSet", OnUpdateItemSet); }
public void Initialize(RigidbodyCharacterController controller) { useAction = controller.GetAction <Use>(); aimAction = controller.GetAction <Aim>(); equipUnequipAction = controller.GetAction <EquipUnequip>(); }