Fix store refunds (#26173)

This commit is contained in:
metalgearsloth 2024-03-17 01:06:17 +11:00 committed by GitHub
parent 6aa77700c1
commit f8d023f286
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -323,7 +323,7 @@ public sealed partial class StoreSystem
if (!component.RefundAllowed || component.BoughtEntities.Count == 0)
return;
for (var i = component.BoughtEntities.Count; i >= 0; i--)
for (var i = component.BoughtEntities.Count - 1; i >= 0; i--)
{
var purchase = component.BoughtEntities[i];
@ -332,7 +332,7 @@ public sealed partial class StoreSystem
component.BoughtEntities.RemoveAt(i);
if (_actions.TryGetActionData(purchase, out var actionComponent))
if (_actions.TryGetActionData(purchase, out var actionComponent, logError: false))
{
_actionContainer.RemoveAction(purchase, actionComponent);
}
@ -340,6 +340,8 @@ public sealed partial class StoreSystem
EntityManager.DeleteEntity(purchase);
}
component.BoughtEntities.Clear();
foreach (var (currency, value) in component.BalanceSpent)
{
component.Balance[currency] += value;