Add weapon database and equipment component resources with associated services
This commit is contained in:
@@ -12,6 +12,7 @@ using GameCore.Events;
|
||||
using GameCore.Input;
|
||||
using GameCore.Inventory;
|
||||
using GameCore.Movement;
|
||||
using GameCore.Player;
|
||||
using Godot;
|
||||
|
||||
namespace CryptonymThunder.Code.Presenters;
|
||||
@@ -20,6 +21,7 @@ namespace CryptonymThunder.Code.Presenters;
|
||||
public partial class GamePresenter : Node
|
||||
{
|
||||
[Export] private ArchetypeDatabase ArchetypesDatabase { get; set; }
|
||||
[Export] private WeaponDatabase WeaponDatabase { get; set; }
|
||||
[Export] private EntityArchetype PlayerArchetype { get; set; }
|
||||
[Export] private SimulationConfigResource SimulationConfig { get; set; }
|
||||
|
||||
@@ -45,8 +47,12 @@ public partial class GamePresenter : Node
|
||||
}
|
||||
|
||||
_world = new World(_inputService, _worldQuery, simConfig);
|
||||
|
||||
var effectFactory = new EffectFactory();
|
||||
var componentFactory = new ComponentFactory(effectFactory);
|
||||
var weaponDataService = new GodotWeaponDataService(WeaponDatabase, effectFactory);
|
||||
|
||||
_presenterFactory = new PresenterFactory(_world, new ComponentFactory(), _presenterRegistry, this);
|
||||
_presenterFactory = new PresenterFactory(_world, componentFactory, _presenterRegistry, this);
|
||||
|
||||
_world.RegisterSystem(new PlayerInputSystem());
|
||||
_world.RegisterSystem(new RotationSystem());
|
||||
@@ -58,6 +64,9 @@ public partial class GamePresenter : Node
|
||||
_world.RegisterSystem(new PickupSystem());
|
||||
_world.RegisterSystem(new InventorySystem(_world));
|
||||
_world.RegisterSystem(new ItemAcquisitionSystem(_world));
|
||||
_world.RegisterSystem(new WeaponAcquisitionSystem(_world));
|
||||
_world.RegisterSystem(new WeaponSwapSystem());
|
||||
_world.RegisterSystem(new EquipmentSystem(_world, weaponDataService));
|
||||
|
||||
_world.RegisterSystem(new WeaponSystem());
|
||||
_world.RegisterSystem(new ProjectileSystem());
|
||||
@@ -69,6 +78,15 @@ public partial class GamePresenter : Node
|
||||
|
||||
_world.Subscribe<EntityDiedEvent>(OnEntityDied);
|
||||
_world.Subscribe<SpawnEntityEvent>(OnSpawnEntity);
|
||||
_world.Subscribe<EquipWeaponEvent>(OnWeaponEquipped);
|
||||
_world.Subscribe<WeaponFiredEvent>(e =>
|
||||
{
|
||||
GD.Print($"Weapon fired by Entity ID: {e.Owner.Id}");
|
||||
});
|
||||
_world.Subscribe<WeaponFireFailedEvent>(e =>
|
||||
{
|
||||
GD.Print($"Weapon fire failed!");
|
||||
});
|
||||
|
||||
RegisterAllSceneEntities();
|
||||
|
||||
@@ -76,7 +94,12 @@ public partial class GamePresenter : Node
|
||||
_presenters.Add(playerData.Entity.Id, playerData.Presenter);
|
||||
_presenterComponents.Add(playerData.Entity.Id, playerData.Components);
|
||||
}
|
||||
|
||||
|
||||
private void OnWeaponEquipped(EquipWeaponEvent e)
|
||||
{
|
||||
GD.Print($"Weapon equipped: {e.NewWeaponItemId} for Entity ID: {e.Owner.Id}");
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
_inputService?.HandleInputEvent(@event);
|
||||
|
||||
Reference in New Issue
Block a user