playMaker

Author Topic: Equipment Toggle Status(int Compare)  (Read 153 times)

ken168

  • Playmaker Newbie
  • *
  • Posts: 12
Equipment Toggle Status(int Compare)
« on: November 17, 2025, 03:46:05 AM »
Hello everyone, I'm designing some items for my character. Equipping these items changes the character's stats, such as increasing HP or attack power.

I've currently designed 10 items, each with different abilities. Some change int or float values, while others change bool values. I've assigned an ID to each item. For example, ID=1 means HP +20, ID=2 means double jump, and ID=0 means no item is equipped.

A character can equip a maximum of 5 items. I've stored the equipped IDs in an array, which might contain the sequence: 2, 5, 0, 0, 0.

I've set up 10 states within the FSM, each representing one of the 10 items and executing the corresponding character state change.

When the game starts, the EquipmentManager reads this array, finds the values ​​sequentially(Get Next), and then uses `int Compare` to compare values ​​from 1 to 10. If they are equal, the corresponding state is executed.

While this seems fine, I don't think it's a very good approach. If I have 100 items, there will be 100 states, making the `int Compare` operation extremely long.

Is there a better way to compare numbers?

For example, if the first value in the array is 2, then execute the 2(state) directly; if the second value is 5, then execute the 5(state) directly.

Thank you.