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

Equipment Slot Helpers #147

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

Equipment Slot Helpers #147

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

Comments

@pavlicekdominik
Copy link
Member

Function: DoesSlotExist

Purpose: To check if an equipment slot with the given name exists.

Inputs:

  • SlotName: FName: The name of the slot to check for existence.

Returns: bool: True if the slot exists, False otherwise.

Description: Checks the equipment system to see if a slot with the specified name is available.

Pseudocode:

Function DoesSlotExist(SlotName: FName) -> bool:

    For each equipmentSlot in EquipmentSlots:
        If equipmentSlot.SlotName == SlotName:
            Return true

    Return false
End Function

Function: GetEquipmentSlot

Purpose: To retrieve a single equipment slot based on the specified criteria.

Inputs:

  • Criteria: FEquipmentSlotSearchCriteria: The criteria to search for.

Returns: FEquipmentItemSlot: An equipment slot that matches the criteria.

Description: Searches the equipment system for the first slot matching the criteria.

Pseudocode:

Function GetEquipmentSlot(Criteria: FEquipmentSlotSearchCriteria) -> FEquipmentItemSlot:

    If Criteria.IsValid():

        For each equipmentSlot in EquipmentSlots:
            If Criteria.SearchByName and equipmentSlot.SlotName == Criteria.SlotName:
                Return equipmentSlot
            If Criteria.SearchByItem and equipmentSlot.ItemSlot.ItemInstance == Criteria.ItemInstance:
                Return equipmentSlot
            If Criteria.SearchByGuid and equipmentSlot.SlotGuid == Criteria.SlotGuid:
                Return equipmentSlot
            If Criteria.SearchByTag and equipmentSlot.AcceptedTags.HasTag(Criteria.Tag):
                Return equipmentSlot
            If Criteria.ItemCategory and equipmentSlot.AcceptedCategories.Contains(Criteria.ItemCategory):
                Return equipmentSlot

    Else:

        Return nullptr

    End If

    Return nullptr

Function: GetEquipmentSlots

Purpose: To retrieve equipment slots based on the specified criteria, or just all.

Inputs:

  • Criteria: FEquipmentSlotSearchCriteria: The criteria to search for.

Returns: TArray<FEquipmentItemSlot>: A list of equipment slots that match the criteria.

Description: Searches the equipment system for slots matching the criteria. If no criteria are provided, it returns all slots.

Pseudocode:

Function GetEquipmentSlots(Criteria: FEquipmentSlotSearchCriteria) -> TArray<FEquipmentItemSlot>:

    ResultSlots = TArray<FEquipmentItemSlot>()

    If Criteria.IsValid():

        For each equipmentSlot in EquipmentSlots:
            If Criteria.SearchByName and equipmentSlot.SlotName == Criteria.SlotName:
                ResultSlots.Add(equipmentSlot)
                Continue
            If Criteria.SearchByItem and equipmentSlot.ItemSlot.ItemInstance == Criteria.ItemInstance:
                ResultSlots.Add(equipmentSlot)
                Continue
            If Criteria.SearchByGuid and equipmentSlot.SlotGuid == Criteria.SlotGuid:
                ResultSlots.Add(equipmentSlot)
                Continue
            If Criteria.SearchByTag and equipmentSlot.AcceptedTags.HasTag(Criteria.Tag):
                ResultSlots.Add(equipmentSlot)
                Continue
            If Criteria.ItemCategory and equipmentSlot.AcceptedCategories.Contains(Criteria.ItemCategory):
                ResultSlots.Add(equipmentSlot)
                Continue

    Else:

        Return EquipmentSlots

    End If

    Return ResultSlots

End Function

Function: IsSlotValid

Purpose: To validate the integrity of an FEquipmentItemSlot.

Inputs:

  • FEquipmentItemSlot Slot: The equipment slot intended for validation.

Returns: bool: True if the slot is valid, False otherwise.

Description: Ensures that the provided slot has:

  • A valid slot name.
  • A unique slot GUID.
  • A valid item slot if an item is equipped.
  • Consistent accepted tags and categories.

Pseudocode:

Function IsSlotValid(Slot: FEquipmentItemSlot) -> bool:

    // Check for a valid slot name.
    If Slot.SlotName is empty:
        Return false

    // Check for a valid slot GUID.
    If Slot.SlotGuid is invalid:
        Return false

    Return true
End Function

Function: CanItemBeEquipped

Purpose: To check if an item can be equipped in a given equipment slot.

Inputs:

  • UInstancedItem* Item: The item intended to be equipped.
  • FEquipmentItemSlot Slot: The equipment slot to which the item is intended to be equipped.

Returns: bool: True if the item can be equipped in the slot, False otherwise.

Description: This function verifies if the item's tags and category match the accepted tags and categories of the equipment slot.

Pseudocode:

Function CanItemBeEquipped(Item: UInstancedItem*, Slot: FEquipmentItemSlot) -> bool:

    // Check for item tags compatibility.
    If not Slot.Tags.HasAny(Item.ItemTags):
        Return false

    // Check for item category compatibility.
    If not Slot.AcceptedCategories.Contains(Item.ItemCategory):
        Return false

    Return true
End Function

Function: IsSlotOccupied

Purpose: To determine if an equipment slot is currently occupied by an item.

Inputs:

  • FEquipmentItemSlot Slot: The equipment slot to check.

Returns: bool: True if the slot is occupied, False otherwise.

Description: A straightforward function to verify if an item occupies the slot.

Pseudocode:

Function IsSlotOccupied(Slot: FEquipmentItemSlot) -> bool:

    If Slot.ItemSlot.ItemInstance is not nullptr:
        Return true
    Else:
        Return false
End Function
@pavlicekdominik pavlicekdominik self-assigned this Nov 1, 2023
@pavlicekdominik pavlicekdominik added this to the 1.0.0.X milestone Nov 1, 2023
pavlicekdominik added a commit that referenced this issue Nov 26, 2023
Completely changing Equipment Interface ( #142 ) and Equipment Component ( #142 ).
Created new Equipment Slot ( #143 ) and helpers ( #146, #147 ).
pavlicekdominik added a commit that referenced this issue Nov 27, 2023
Completely changing Equipment Interface ( #142 ) and Equipment Component ( #142 ).
Created new Equipment Slot ( #143 ) and helpers ( #146, #147 ).
pavlicekdominik added a commit that referenced this issue Nov 27, 2023
Completely changing Equipment Interface ( #142 ) and Equipment Component ( #142 ).
Created new Equipment Slot ( #143 ) and helpers ( #146, #147 ).
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