Skip to content

Instanced Inventory Item

Dominik Morse edited this page Nov 9, 2023 · 10 revisions

UMounteaInstancedItem

What is UMounteaInstancedItem?

Imagine you're playing a video game and you find a magic sword. Now, this isn't just any magic sword; it's a one-of-a-kind sword with its own story, stats, and special powers. UMounteaInstancedItem is like the identity card for that exact sword. It's not just a template; it's the specific sword you're swinging around in the game.

What Can It Do?

  • Unique Identity: Each UMounteaInstancedItem is like a unique item in your game's level. Even if two swords look alike, each has its own special details and history.
  • Track Origins: It knows whether your sword was created using a template (like UMounteaInventoryItemBase) or if it was picked from a list of possible swords.
  • Keep Count: If by some magic you can clone your sword, this system will keep track of how many copies you have.
  • Store Details: It remembers all the cool stuff about your sword, like enchantments or if it's forged with dragon fire.
  • Update Others: It sends out alerts to the game when you pick up the sword, drop it, or when anything about it changes.

Important Parts of UMounteaInstancedItem

Where the Item Comes From

  • ItemDataSource: Thinks about where the item originally comes from – is it made right away in the game or is it chosen from a pre-made list?
  • SourceItem: This is the actual item if it’s not from a list.
  • SourceTable: If the item is from a list, this is the list it’s from.
  • SourceRow: This is where in the list the item is found.

Keeping Track of the Item

  • InstanceID: A special number that's different for every item, like a serial number.
  • Quantity: How many of this item you have.
  • ItemFlags: These are like sticky notes on the item that say what it can do or what it is, it can be something like "Equipped" or "Enhanced".

Behind the Scenes

  • RepKey: A secret code used to make sure the game shows the same thing to all players, even on different computers.
  • OwningInventory: This tells us who owns the item in the game.
  • World: This tells us which part of the game world knows about the item.

What Happens When Things Change?

When Items Are Added or Removed

  • OnItemAdded: It's like the box sends a signal when a new item is put in.
  • OnItemRemoved: It sends another signal when an item is taken out.

Setting Up and Changing the Item

  • ConstructItem: It's like opening a new box and putting an item inside it for the first time.
  • UpdateQuantity: Changing the number of items in the box.
  • DestroyItem: It’s like making the item vanish from the box forever.

Learning About the Item

  • GetItemFlags: It's like reading all the sticky notes on the item.
  • AddItemFlag: Putting a new sticky note on the item.
  • RemoveItemFlag: Taking a sticky note off.

Checking the Item’s Details

  • IsFlagSet: Checking if a specific sticky note is on the item.
  • AreFlagsSet: Making sure certain sticky notes are all there.

Flow

flowchart TD;
    InitializeNewItem --> |True| SetWorld
    InitializeNewItem --> |True| SetSourceItemOrTable
    InitializeNewItem --> |False| End[End Function]

    SetSourceItemOrTable --> |SourceItem| SetSourceItem
    SetSourceItemOrTable --> |SourceTable| SetSourceTable
    SetSourceItemOrTable --> |None| End
    SetSourceItem --> SetValidData
    SetSourceTable --> SetValidData

    SetValidData --> |True| OnItemBeginPlay
    OnItemBeginPlay --> OnItemInitialized
    SetValidData --> |False| LogError --> DestroyItem

    OnItemInitialized --> TraceLifetimeBegin

    UpdateQuantity --> MarkDirtyForReplication
    AddItemFlag --> MarkDirtyForReplication
    SetItemFlags --> MarkDirtyForReplication
    RemoveItemFlag --> MarkDirtyForReplication
    SetOwningInventory --> MarkDirtyForReplication
    SetWorldFromLevel --> SetWorld
    SetWorld --> MarkDirtyForReplication

    MarkDirtyForReplication --> Replicate
    Replicate --> |Network| OnRep_Item
    Replicate --> |Network| OnRep_Quantity
Loading

Clone this wiki locally