Add weapon database and equipment component resources with associated services

This commit is contained in:
2025-10-29 01:26:45 +01:00
parent 87169b17ae
commit 626f81cd85
16 changed files with 245 additions and 11 deletions

View File

@@ -14,6 +14,8 @@ public class GodotInputService : IInputService
public bool IsJumping { get; private set; }
public GameCoreMath MoveDirection { get; private set; }
public GameCoreMath LookDirection { get; private set; }
public bool IsSwapWeaponNext { get; private set; }
public bool IsSwapWeaponPrevious { get; private set; }
public void HandleInputEvent(InputEvent e)
{
@@ -38,10 +40,15 @@ public class GodotInputService : IInputService
IsJumping = Input.IsActionJustPressed("jump");
IsFiring = Input.IsActionPressed("fire");
IsInteracting = Input.IsActionPressed("interact");
IsSwapWeaponNext = Input.IsActionJustPressed("swap_weapon_next");
IsSwapWeaponPrevious = Input.IsActionJustPressed("swap_weapon_previous");
}
public void LateUpdate()
{
LookDirection = GameCoreMath.Zero;
IsSwapWeaponNext = false;
IsSwapWeaponPrevious = false;
}
}

View File

@@ -0,0 +1,55 @@
using System.Linq;
using CryptonymThunder.Code.Factories;
using CryptonymThunder.Code.Resources;
using GameCore.Combat;
using GameCore.Combat.Interfaces;
using Godot;
namespace CryptonymThunder.Code.Services;
public class GodotWeaponDataService : IWeaponDataService
{
private readonly WeaponDatabase _database;
private readonly EffectFactory _effectFactory;
public GodotWeaponDataService(WeaponDatabase database, EffectFactory effectFactory)
{
_database = database;
_effectFactory = effectFactory;
}
public WeaponData GetWeaponData(string weaponId)
{
if (!_database.WeaponData.TryGetValue(weaponId, out var weaponResource))
{
GD.PrintErr($"Weapon ID not found in database: {weaponId}");
return null;
}
var fireCosts = weaponResource.FireCosts
.Select(_effectFactory.Create)
.OfType<ICostEffect>()
.ToList();
var onFireEffects = weaponResource.OnFireEffects
.Select(_effectFactory.Create)
.ToList();
var onHitEffects = weaponResource.OnHitEffects
.Select(_effectFactory.Create)
.ToList();
return new WeaponData(
weaponResource.FireRate,
fireCosts,
onFireEffects,
onHitEffects
);
}
public bool TryGetWeaponData(string weaponId, out WeaponData weaponData)
{
weaponData = GetWeaponData(weaponId);
return weaponData != null;
}
}

View File

@@ -0,0 +1 @@
uid://4jlk57176ic5