Exemple #1
0
        /// <summary>
        /// Watches for InventoryLoaded events
        /// When an inventory gets loaded, if it's our WeaponInventory, we check if there's already a weapon equipped, and if yes, we equip it
        /// </summary>
        /// <param name="inventoryEvent">Inventory event.</param>
        public virtual void OnMMEvent(MMInventoryEvent inventoryEvent)
        {
            if (inventoryEvent.InventoryEventType == MMInventoryEventType.InventoryLoaded)
            {
                if (!AbilityInitialized)
                {
                    Initialization();
                }

                if (inventoryEvent.TargetInventoryName == WeaponInventoryName)
                {
                    this.Setup();
                    if (WeaponInventory != null)
                    {
                        if (!InventoryItem.IsNull(WeaponInventory.Content [0]))
                        {
                            if (CharacterHandleWeapon == null)
                            {
                                CharacterHandleWeapon = _character.FindAbility <CharacterHandleWeapon>();
                            }
                            CharacterHandleWeapon.Setup();
                            WeaponInventory.Content [0].Equip();
                        }
                    }
                }
            }
            if (inventoryEvent.InventoryEventType == MMInventoryEventType.Pick)
            {
                bool isSubclass = (inventoryEvent.EventItem.GetType().IsSubclassOf(typeof(InventoryEngineWeapon)));
                bool isClass    = (inventoryEvent.EventItem.GetType() == typeof(InventoryEngineWeapon));
                if (isClass || isSubclass)
                {
                    InventoryEngineWeapon inventoryWeapon = (InventoryEngineWeapon)inventoryEvent.EventItem;
                    switch (inventoryWeapon.AutoEquipMode)
                    {
                    case InventoryEngineWeapon.AutoEquipModes.NoAutoEquip:
                        // we do nothing
                        break;

                    case InventoryEngineWeapon.AutoEquipModes.AutoEquip:
                        _nextFrameWeapon     = true;
                        _nextFrameWeaponName = inventoryEvent.EventItem.ItemID;
                        break;

                    case InventoryEngineWeapon.AutoEquipModes.AutoEquipIfEmptyHanded:
                        if (CharacterHandleWeapon.CurrentWeapon == null)
                        {
                            _nextFrameWeapon     = true;
                            _nextFrameWeaponName = inventoryEvent.EventItem.ItemID;
                        }
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// Watches for InventoryLoaded events
        /// When an inventory gets loaded, if it's our WeaponInventory, we check if there's already a weapon equipped, and if yes, we equip it
        /// </summary>
        /// <param name="inventoryEvent">Inventory event.</param>
        public virtual void OnMMEvent(MMInventoryEvent inventoryEvent)
        {
            if (inventoryEvent.InventoryEventType == MMInventoryEventType.InventoryLoaded)
            {
                if (inventoryEvent.TargetInventoryName == WeaponInventoryName)
                {
                    this.Setup();
                    if (WeaponInventory != null)
                    {
                        if (!InventoryItem.IsNull(WeaponInventory.Content [0]))
                        {
                            _characterHandleWeapon.Setup();
                            WeaponInventory.Content [0].Equip();
                        }
                    }
                }
            }
            if (inventoryEvent.InventoryEventType == MMInventoryEventType.Pick)
            {
                if (inventoryEvent.EventItem.GetType() == typeof(InventoryEngineWeapon))
                {
                    InventoryEngineWeapon inventoryWeapon = (InventoryEngineWeapon)inventoryEvent.EventItem;
                    switch (inventoryWeapon.AutoEquipMode)
                    {
                    case InventoryEngineWeapon.AutoEquipModes.NoAutoEquip:
                        // we do nothing
                        break;

                    case InventoryEngineWeapon.AutoEquipModes.AutoEquip:
                        _nextFrameWeapon     = true;
                        _nextFrameWeaponName = inventoryEvent.EventItem.ItemID;
                        break;

                    case InventoryEngineWeapon.AutoEquipModes.AutoEquipIfEmptyHanded:
                        if (_characterHandleWeapon.CurrentWeapon == null)
                        {
                            _nextFrameWeapon     = true;
                            _nextFrameWeaponName = inventoryEvent.EventItem.ItemID;
                        }
                        break;
                    }
                }
            }
        }