Rework game over logic and game initialization

This commit is contained in:
2025-10-27 15:04:01 -07:00
parent 720696aed0
commit 7e6dca1c29
46 changed files with 653 additions and 610 deletions

View File

@@ -2,7 +2,7 @@
namespace Zennysoft.Ma.Adapter;
public interface IAttackComponent
public interface IAttackComponent : IEntityComponent
{
public IAutoProp<int> CurrentAttack { get; }

View File

@@ -2,7 +2,7 @@
namespace Zennysoft.Ma.Adapter;
public interface IDefenseComponent
public interface IDefenseComponent : IEntityComponent
{
public IAutoProp<int> CurrentDefense { get; }

View File

@@ -0,0 +1,6 @@
namespace Zennysoft.Ma.Adapter;
public interface IEntityComponent
{
public void Reset();
}

View File

@@ -2,7 +2,7 @@
using Zennysoft.Ma.Adapter.Entity;
namespace Zennysoft.Ma.Adapter;
public interface IEquipmentComponent
public interface IEquipmentComponent : IEntityComponent
{
public IAutoProp<EquipableItem> EquippedWeapon { get; }

View File

@@ -2,7 +2,7 @@
namespace Zennysoft.Ma.Adapter;
public interface IExperiencePointsComponent
public interface IExperiencePointsComponent : IEntityComponent
{
public IAutoProp<int> CurrentExp { get; }

View File

@@ -2,7 +2,7 @@
namespace Zennysoft.Ma.Adapter;
public interface IHealthComponent
public interface IHealthComponent : IEntityComponent
{
public IAutoProp<int> CurrentHP { get; }
@@ -17,7 +17,9 @@ public interface IHealthComponent
public void Damage(int damageAmount);
public void SetHealth(int health);
public void SetCurrentHealth(int health);
public void SetMaximumHealth(int health);
public void RaiseMaximumHP(int raiseAmount);
}
}

View File

@@ -2,7 +2,7 @@
namespace Zennysoft.Ma.Adapter;
public interface ILuckComponent
public interface ILuckComponent : IEntityComponent
{
public IAutoProp<int> Luck { get; }

View File

@@ -2,7 +2,7 @@
namespace Zennysoft.Ma.Adapter;
public interface IVTComponent
public interface IVTComponent : IEntityComponent
{
public IAutoProp<int> CurrentVT { get; }

View File

@@ -8,10 +8,6 @@ public partial class GameState
public readonly record struct LoadGame;
public readonly record struct ContinueGame;
public readonly record struct ReturnToMainMenu;
public readonly record struct LoadNextFloor;
public readonly record struct InventoryButtonPressed;

View File

@@ -16,11 +16,6 @@ public partial class GameState
OnAttach(() => Get<IGameRepo>().Pause());
}
public Transition On(in Input.ReturnToMainMenu input)
{
return To<MainMenu>();
}
public Transition On(in Input.UseTeleport input)
{
Output(new Output.OpenFloorExitScreen());

View File

@@ -8,7 +8,7 @@ public partial class GameState
public partial record State
{
[Meta, LogicBlock(typeof(State), Diagram = true)]
public partial record FloorExitScreen : State, IGet<Input.LoadNextFloor>, IGet<Input.ReturnToMainMenu>
public partial record FloorExitScreen : State, IGet<Input.LoadNextFloor>
{
public FloorExitScreen()
{
@@ -20,11 +20,6 @@ public partial class GameState
Output(new Output.LoadNextFloor());
return To<InGame>();
}
public Transition On(in Input.ReturnToMainMenu input)
{
return To<MainMenu>();
}
}
}
}

View File

@@ -8,18 +8,13 @@ public partial class GameState
public partial record State
{
[Meta, LogicBlock(typeof(State), Diagram = true)]
public partial record GameOver : State, IGet<Input.ContinueGame>, IGet<Input.ReturnToMainMenu>
public partial record GameOver : State, IGet<Input.NewGame>
{
public Transition On(in Input.ContinueGame input)
public Transition On(in Input.NewGame input)
{
Output(new Output.InitializeGame());
return To<InGame>();
}
public Transition On(in Input.ReturnToMainMenu input)
{
return To<MainMenu>();
}
}
}
}

View File

@@ -1,34 +0,0 @@
using Chickensoft.Introspection;
using Chickensoft.LogicBlocks;
namespace Zennysoft.Ma.Adapter;
public partial class GameState
{
public partial record State
{
[Meta, LogicBlock(typeof(State), Diagram = true)]
public partial record MainMenu : State, IGet<Input.NewGame>, IGet<Input.ContinueGame>, IGet<Input.LoadGame>
{
public Transition On(in Input.NewGame input)
{
Output(new Output.InitializeGame());
return To<InGame>();
}
public Transition On(in Input.ContinueGame input)
{
Output(new Output.InitializeGame());
Output(new Output.LoadGameFromFile());
return To<InGame>();
}
public Transition On(in Input.LoadGame input)
{
Output(new Output.InitializeGame());
Output(new Output.LoadGameFromFile());
return To<InGame>();
}
}
}
}

View File

@@ -0,0 +1,9 @@
namespace Zennysoft.Ma.Adapter
{
public interface IDroppedItem
{
void RescueItem();
public InventoryItem Item { get; }
}
}

View File

@@ -1,9 +1,9 @@
using Zennysoft.Game.Implementation;
namespace Zennysoft.Ma.Adapter;
namespace Zennysoft.Ma.Adapter;
public interface IInventory
{
public bool PickUpItem(InventoryItem item);
public List<InventoryItem> Items { get; }
public bool TryAdd(InventoryItem inventoryItem);
@@ -13,4 +13,6 @@ public interface IInventory
public void Remove(InventoryItem inventoryItem);
public void Sort(EquipableItem currentWeapon, EquipableItem currentArmor, EquipableItem currentAccessory);
public event Action<string> BroadcastMessage;
}

View File

@@ -0,0 +1,6 @@
namespace Zennysoft.Ma.Adapter;
public interface IThrownItem
{
public InventoryItem ItemThatIsThrown { get; set; }
}

View File

@@ -6,6 +6,8 @@ namespace Zennysoft.Ma.Adapter;
public interface IPlayer : IKillable, ICharacterBody3D
{
public void ResetPlayerData();
public void Activate();
public void Deactivate();
@@ -18,6 +20,10 @@ public interface IPlayer : IKillable, ICharacterBody3D
public void TeleportPlayer(Transform3D newTransform);
public void Equip(EquipableItem equipable);
public void Unequip(EquipableItem equipable);
public IInventory Inventory { get; }
public IHealthComponent HealthComponent { get; }
@@ -33,4 +39,7 @@ public interface IPlayer : IKillable, ICharacterBody3D
public ILuckComponent LuckComponent { get; }
public IEquipmentComponent EquipmentComponent { get; }
public event Action PlayerDied;
public delegate InventoryItem RerollItem(InventoryItem item);
}