| 65 | } |
| 66 | |
| 67 | bool TryModifyingKeyItem(LaraInfo& lara, GAME_OBJECT_ID objectID, std::optional<int> amount, ModificationType modType) |
| 68 | { |
| 69 | // kick off the recursion starting at the last element |
| 70 | auto result = GetArrayInternal<nInfos - 1>(lara, objectID); |
| 71 | |
| 72 | if (result.first) |
| 73 | { |
| 74 | auto& amt = result.first[result.second]; |
| 75 | switch (modType) |
| 76 | { |
| 77 | case ModificationType::Set: |
| 78 | // infinite key items not yet implemented |
| 79 | amt = amount.value(); |
| 80 | break; |
| 81 | default: |
| 82 | int defaultModify = modType == ModificationType::Add ? kDefaultPickupAmount : -kDefaultPickupAmount; |
| 83 | int newVal = int{ result.first[result.second] } + (amount.has_value() ? amount.value() : defaultModify); |
| 84 | result.first[result.second] = std::max(0, newVal); |
| 85 | } |
| 86 | return true; |
| 87 | } |
| 88 | |
| 89 | return false; |
| 90 | } |
| 91 | |
| 92 | bool TryAddingKeyItem(LaraInfo& lara, GAME_OBJECT_ID objectID, std::optional<int> amount) |
| 93 | { |
no test coverage detected