Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EquipItem #144

Open
pavlicekdominik opened this issue Nov 1, 2023 · 0 comments
Open

EquipItem #144

pavlicekdominik opened this issue Nov 1, 2023 · 0 comments
Assignees
Milestone

Comments

@pavlicekdominik
Copy link
Member

Function: EquipItem

Purpose: To equip an item into a designated equipment slot. If the slot is already occupied, it follows a set policy (e.g., replacing the item).

Inputs:

  • ItemToEquip: UInstancedItem*: The instance of the item that needs to be equipped.
  • TargetSlotName: FName: The name of the equipment slot where the item should be placed.

Returns:

  • bool: True if the item is successfully equipped, False otherwise.

Description:

Equips an item into a designated slot. If the slot is occupied, the function's behavior depends on the game's equip-replace policy. If the policy is set to "Disallow," the function will return false. If it's set to "Replace," the current item in the slot will be unequipped, and the new item will be equipped.

Pseudocode:

Function EquipItem(ItemToEquip: UInstancedItem*, TargetSlotName: FName) -> bool:

    // Validate the input item
    If ItemToEquip is nullptr:
        Return false

    // Check if the target slot exists in the equipment system
    If not DoesSlotExist(TargetSlotName):
        Return false

    // Retrieve the target equipment slot based on its name
    TargetSlot = GetEquipmentSlot(SearchCriteria with SlotName = TargetSlotName)

    // Ensure that the item is compatible with the intended slot
    If not IsItemCompatibleWithSlot(ItemToEquip, TargetSlot):
        Return false

    // Check if the equipment slot already contains an item
    If TargetSlot.ItemSlot.ItemInstance is not nullptr:

        // Determine the game's policy on equipping items into occupied slots
        replacePolicy = GetGameEquipReplacePolicy()

        // If the policy disallows equipping over occupied slots, return false
        If replacePolicy == "Disallow":
            Return false
        // If the policy allows replacing the item, unequip the current item from the slot
        Else If replacePolicy == "Replace":
            UnequipItem(TargetSlotName)

    // Equip the new item into the slot
    TargetSlot.ItemSlot.ItemInstance = ItemToEquip

    // Mark the item as 'Equipped'
    ItemToEquip.AddItemFlag("Equipped")

    // Return true to indicate the successful equipping of the item
    Broadcast Event: "ItemEquipped" with parameters (ItemToEquip, TargetSlotName)
    Return true

End Function
@pavlicekdominik pavlicekdominik self-assigned this Nov 1, 2023
@pavlicekdominik pavlicekdominik converted this from a draft issue Nov 1, 2023
@pavlicekdominik pavlicekdominik added this to the 1.0.0.X milestone Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant