public EquippedItemsInventory(CharacterInventory owner) { _owner = owner; _primaryHandSlot = new EquippedToolInventory(this); _primaryHandSlot.ToolAddedEvent += OnPrimaryToolAdded; _primaryHandSlot.ToolRemovedEvent += _owner.SaveToolAbilitiesPrimary; _secondaryHandSlot = new EquippedToolInventory(this); _secondaryHandSlot.ToolAddedEvent += OnSecondaryToolAdded; _secondaryHandSlot.ToolRemovedEvent += _owner.SaveToolAbilitiesSecondary; GameWorldControlState.GetInstance().SelectAbilityEvent += SelectAbility; GameWorldControlState.GetInstance().PrimaryHandAbilityOnClickEvent += _primaryHandSlot.ActiveAbilityOnClick; GameWorldControlState.GetInstance().SecondaryHandAbilityOnClickEvent += _secondaryHandSlot.ActiveAbilityOnClick; }
/// <summary> /// Handles equiping of tools to hands based on the tool's equipConstraints /// </summary> /// <param name="tool"></param> /// <param name="toolSlot"></param> /// <returns></returns> public InventoryItem AddToolAt(ToolInventoryItem tool, EquippedToolInventory toolSlot) { InventoryItem result = null; if (toolSlot == _primaryHandSlot) { //Check equip constraints switch (tool.EquipConstraint) { //Can equip case EquipConstraint.Primary: { result = _primaryHandSlot.AddItem(tool); break; } case EquipConstraint.None: { result = _primaryHandSlot.AddItem(tool); break; } //Can only equip if nothing in secondary hand case EquipConstraint.TwoHanded: { if (!_secondaryHandSlot.HasTool) { result = _primaryHandSlot.AddItem(tool); } break; } default: { result = tool; break; } } } else if (toolSlot == _secondaryHandSlot) { //Don't let a tool be equipped to the second hand if there is a two-handed tool in the primary hand if (_primaryHandSlot.ToolEquipConstraint != EquipConstraint.TwoHanded) { //Check equip constraints switch (tool.EquipConstraint) { //Can equip case EquipConstraint.Secondary: { result = _secondaryHandSlot.AddItem(tool); break; } case EquipConstraint.None: { result = _secondaryHandSlot.AddItem(tool); break; } default: { result = tool; break; } } } } else { result = null; } return(result); }
public ToolAbilityInventory(ToolType toolType, EquippedToolInventory owner) : base(10) { tempOwner = owner; _toolType = toolType; // _items = new LinkedList<InventoryItem/*AbilityInventoryItem*/>(); }
//Removes event handlers public void Destroy() { tempOwner = null; }