/// <summary> /// Initialize the default values. /// </summary> public override void Init(Inventory inventory) { base.Init(inventory); // Initialize the animation states. m_UseStates.Initialize(m_ItemType); }
/// <summary> /// Initializes the item after it has been added to the Inventory. /// </summary> /// <param name="item">The item that this extension belongs to.</param> /// <param name="inventory">The parent character's inventory.</param> public override void Init(Item item, Inventory inventory) { base.Init(item, inventory); m_CharacterRigidbody = inventory.GetComponent <Rigidbody>(); // Register for character events if the GameObject is active. OnEnable normally registers for these callbacks but in this case OnEnable has already occurred. if (m_GameObject.activeSelf) { EventHandler.RegisterEvent(m_Character, "OnAnimatorItemEndUse", EndUse); } SharedManager.InitializeSharedFields(m_Character, this); // Independent look characters do not need to communicate with the camera. Do not initialze the SharedFields on the network to prevent non-local characters from // using the main camera to determine their look direction. The SharedFields have been implemented by the NetworkMonitor component. #if ENABLE_MULTIPLAYER if (!m_IndependentLook.Invoke() && m_IsLocalPlayer.Invoke()) { #else if (!m_IndependentLook.Invoke()) { #endif SharedManager.InitializeSharedFields(Utility.FindCamera(m_Character).gameObject, this); } // Initialize the animation states. m_RecoilStates.Initialize(m_ParentItem.ItemType); }
/// <summary> /// Initializes the item after it has been added to the Inventory. /// </summary> /// <param name="item">The item that this extension belongs to.</param> /// <param name="inventory">The parent character's inventory.</param> public override void Init(Item item, Inventory inventory) { base.Init(item, inventory); // Initialize the animation states. m_UseStates.Initialize(m_ParentItem.ItemType); }
/// <summary> /// Initializes the item after it has been added to the Inventory. /// </summary> /// <param name="inventory">The parent character's inventory.</param> public override void Init(Inventory inventory) { base.Init(inventory); m_CharacterRigidbody = inventory.GetComponent <Rigidbody>(); // Initialize the animation states. m_RecoilStates.Initialize(m_ItemType); }
/// <summary> /// Initializes the item after it has been added to the Inventory. /// </summary> /// <param name="inventory">The parent character's inventory.</param> public override void Init(Inventory inventory) { base.Init(inventory); // Initialize the animation states. m_UseStates.Initialize(m_ItemType); m_CharacterTransform = m_Character.transform; }
/// <summary> /// Initializes the item after it has been added to the Inventory. /// </summary> /// <param name="inventory">The parent character's inventory.</param> public override void Init(Inventory inventory) { base.Init(inventory); m_CharacterTransform = m_Character.transform; // Initialize the animation states. m_UseStates.Initialize(m_ItemType); EventHandler.RegisterEvent <Item, bool, bool>(m_Character, "OnInventoryConsumableItemCountChange", ConsumableItemCountChange); }
/// <summary> /// Initializes the item after it has been added to the Inventory. /// </summary> /// <param name="inventory">The parent character's inventory.</param> public override void Init(Inventory inventory) { base.Init(inventory); // Initialize the animation states. m_RecoilStates.Initialize(m_ItemType); // Determine which hand the item is in for the recoil animation. var hand = GetComponentInParent <ItemPlacement>().transform.parent; var rightHand = inventory.GetComponent <Animator>().GetBoneTransform(HumanBodyBones.RightHand); m_RecoilStateIndex = (rightHand == hand ? m_AnimatorMonitor.RightArmLayerIndex : m_AnimatorMonitor.LeftArmLayerIndex); }
/// <summary> /// Initializes the item after it has been added to the Inventory. /// </summary> /// <param name="inventory">The parent character's inventory.</param> public virtual void Init(Inventory inventory) { m_Inventory = inventory; m_Character = inventory.gameObject; #if ENABLE_MULTIPLAYER m_NetworkMonitor = m_Character.GetComponent <NetworkMonitor>(); #endif m_AnimatorMonitor = inventory.GetComponent <AnimatorMonitor>(); m_Controller = inventory.GetComponent <RigidbodyCharacterController>(); // Initialize the animation states. m_DefaultStates.Initialize(m_ItemType); if (m_CanAim) { m_AimStates.Initialize(m_ItemType); } m_EquipStates.Initialize(m_ItemType); m_UnequipStates.Initialize(m_ItemType); EventHandler.RegisterEvent(gameObject, "OnInventoryItemEquipping", OnItemEquipping); EventHandler.RegisterEvent(gameObject, "OnInventoryItemUnequipping", OnItemUnequipping); EventHandler.RegisterEvent(gameObject, "OnInventoryItemEquipped", OnItemEquipped); EventHandler.RegisterEvent(gameObject, "OnInventoryItemUnequipped", OnItemUnequipped); for (int i = 0; i < m_ItemExtensions.Length; ++i) { m_ItemExtensions[i].Init(this, inventory); } for (int i = 0; i < m_Colliders.Length; ++i) { m_Colliders[i].enabled = false; } SharedManager.InitializeSharedFields(m_Character, this); // Independent look characters do not need to communicate with the camera. Do not initialze the SharedFields on the network to prevent non-local characters from // using the main camera to determine their look direction. The SharedFields have been implemented by the NetworkMonitor component. #if ENABLE_MULTIPLAYER if (!m_IndependentLook.Invoke() && m_IsLocalPlayer.Invoke()) { #else if (!m_IndependentLook.Invoke()) { #endif SharedManager.InitializeSharedFields(Utility.FindCamera(m_Character).gameObject, this); } }