Fix up item usage

This commit is contained in:
2025-03-07 18:40:14 -08:00
parent 93c04440d4
commit fe3c539a62
15 changed files with 125 additions and 65 deletions

View File

@@ -1,5 +1,6 @@
using Chickensoft.Collections;
using Godot;
using Zennysoft.Game.Abstractions;
namespace Zennysoft.Game.Ma.Implementation;
@@ -11,12 +12,16 @@ public interface IGameRepo : IDisposable
event Action? CloseInventory;
event Action<string>? AnnounceMessage;
event Action<string>? AnnounceMessageOnMainScreenEvent;
event Action<string>? AnnounceMessageInInventoryEvent;
event Action<int>? DoubleExpTimeStart;
event Action? DoubleExpTimeEnd;
event Action<IInventoryItem>? RemoveItemFromInventoryEvent;
void Pause();
void Resume();
@@ -29,6 +34,10 @@ public interface IGameRepo : IDisposable
public void AnnounceMessageOnMainScreen(string message);
public void AnnounceMessageInInventory(string message);
public void RemoveItemFromInventory(IInventoryItem item);
public double ExpRate { get; }
}
@@ -37,9 +46,11 @@ public class GameRepo : IGameRepo
public event Action? Ended;
public event Action? OpenInventory;
public event Action? CloseInventory;
public event Action<string>? AnnounceMessage;
public event Action<string>? AnnounceMessageOnMainScreenEvent;
public event Action<string>? AnnounceMessageInInventoryEvent;
public event Action<int>? DoubleExpTimeStart;
public event Action? DoubleExpTimeEnd;
public event Action<IInventoryItem>? RemoveItemFromInventoryEvent;
public IAutoProp<bool> IsPaused => _isPaused;
private readonly AutoProp<bool> _isPaused;
@@ -68,8 +79,7 @@ public class GameRepo : IGameRepo
public void StartDoubleEXP(TimeSpan lengthOfEffect)
{
CloseInventory?.Invoke();
AnnounceMessageOnMainScreen("Experience points temporarily doubled.");
AnnounceMessageInInventory("Experience points temporarily doubled.");
DoubleExpTimeStart?.Invoke(lengthOfEffect.Seconds);
ExpRate = 2;
}
@@ -82,7 +92,17 @@ public class GameRepo : IGameRepo
public void AnnounceMessageOnMainScreen(string message)
{
AnnounceMessage?.Invoke(message);
AnnounceMessageOnMainScreenEvent?.Invoke(message);
}
public void AnnounceMessageInInventory(string message)
{
AnnounceMessageInInventoryEvent?.Invoke(message);
}
public void RemoveItemFromInventory(IInventoryItem item)
{
RemoveItemFromInventoryEvent?.Invoke(item);
}
public void OnGameEnded()