Refactor Player class to use components, also use components in Enemy class types and fiddle with boss structure
This commit is contained in:
@@ -11,6 +11,7 @@ using Zennysoft.Game.Abstractions;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Zennysoft.Game.Implementation.Components;
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class Game : Node3D, IGame
|
||||
@@ -94,7 +95,6 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
PlayerData = new PlayerData()
|
||||
{
|
||||
PlayerStats = _player.Stats,
|
||||
Inventory = _player.Inventory
|
||||
},
|
||||
MapData = new MapData()
|
||||
@@ -321,12 +321,6 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
public IDungeonFloor CurrentFloor => _map.CurrentFloor;
|
||||
|
||||
public void EnemyDefeated(Vector3 defeatedLocation)
|
||||
{
|
||||
_player.GainExp(10 * GameRepo.ExpRate);
|
||||
DropRestorative(defeatedLocation);
|
||||
}
|
||||
|
||||
public InventoryItem RerollItem(InventoryItem itemToReroll, bool insertIntoInventory = true)
|
||||
{
|
||||
var itemDb = new ItemDatabase();
|
||||
@@ -390,7 +384,7 @@ public partial class Game : Node3D, IGame
|
||||
GameRepo.Resume();
|
||||
}
|
||||
|
||||
private void GameEventDepot_RestorativePickedUp(IHealthPack obj) => _player.Stats.SetCurrentVT(_player.Stats.CurrentVT.Value + (int)obj.RestoreAmount);
|
||||
private void GameEventDepot_RestorativePickedUp(IHealthPack obj) => _player.VTComponent.Restore((int)obj.RestoreAmount);
|
||||
|
||||
private void IsPaused_Sync(bool isPaused) => GetTree().Paused = isPaused;
|
||||
|
||||
@@ -398,15 +392,15 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
private void EnactConsumableItemEffects(ConsumableItem consumableItem)
|
||||
{
|
||||
if (_player.Stats.CurrentHP == _player.Stats.MaximumHP && consumableItem.RaiseHPAmount > 0)
|
||||
_player.RaiseHP(consumableItem.RaiseHPAmount);
|
||||
if (_player.Stats.CurrentVT == _player.Stats.MaximumVT && consumableItem.RaiseVTAmount > 0)
|
||||
_player.RaiseVT(consumableItem.RaiseVTAmount);
|
||||
if (_player.HealthComponent.AtFullHealth && consumableItem.RaiseHPAmount > 0)
|
||||
_player.HealthComponent.RaiseMaximumHP(consumableItem.RaiseHPAmount);
|
||||
if (_player.VTComponent.AtFullVT && consumableItem.RaiseVTAmount > 0)
|
||||
_player.VTComponent.RaiseMaximumVT(consumableItem.RaiseVTAmount);
|
||||
|
||||
if (consumableItem.HealHPAmount > 0 && _player.Stats.CurrentHP != _player.Stats.MaximumHP)
|
||||
_player.HealHP(consumableItem.HealHPAmount);
|
||||
if (consumableItem.HealVTAmount > 0 && _player.Stats.CurrentVT != _player.Stats.MaximumVT)
|
||||
_player.HealVT(consumableItem.HealVTAmount);
|
||||
if (consumableItem.HealHPAmount > 0)
|
||||
_player.HealthComponent.Heal(consumableItem.HealHPAmount);
|
||||
if (consumableItem.HealVTAmount > 0)
|
||||
_player.VTComponent.Restore(consumableItem.HealVTAmount);
|
||||
}
|
||||
|
||||
private void EnactEffectItemEffects(EffectItem effectItem)
|
||||
@@ -478,9 +472,9 @@ public partial class Game : Node3D, IGame
|
||||
}
|
||||
|
||||
if (throwableItem.HealHPAmount > 0)
|
||||
_player.HealHP(throwableItem.HealHPAmount);
|
||||
_player.HealthComponent.Heal(throwableItem.HealHPAmount);
|
||||
if (throwableItem.HealVTAmount > 0)
|
||||
_player.HealVT(throwableItem.HealVTAmount);
|
||||
_player.VTComponent.Restore(throwableItem.HealVTAmount);
|
||||
}
|
||||
|
||||
private void RemoveItemOrSubtractFromItemCount(InventoryItem item)
|
||||
|
||||
Reference in New Issue
Block a user