Add attribute system with core stats and gameplay components

This commit is contained in:
2025-10-13 12:10:45 +02:00
commit ce3596efaa
55 changed files with 1161 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
using GameCore.Combat.Interfaces;
using GameCore.Events;
using GameCore.Input;
using GameCore.Movement;
namespace GameCore.Combat.Effects;
public class BulkProjectileEffect(string archetypeId, int count, float spreadAngle, float speed) : IEffect
{
private static readonly Random _random = new();
public void Execute(EffectContext context)
{
var ownerInput = context.World.GetComponent<InputStateComponent>(context.Owner);
if (ownerInput == null)
return;
var ownerRotation = context.World.GetComponent<RotationComponent>(context.Owner);
if (ownerRotation == null) return;
var spreadRadians = spreadAngle * (float)System.Math.PI / 180f;
for (var i = 0; i < count; i++)
{
var direction = ownerInput.MuzzleDirection;
if (spreadRadians > 0f)
{
var randomYaw = ((float)_random.NextDouble() * 2f - 1f) * spreadRadians;
var randomPitch = ((float)_random.NextDouble() * 2f - 1f) * spreadRadians;
direction = context.World.WorldQuery.RotateVectorByYaw(direction, randomYaw);
direction.Y += (float)System.Math.Sin(randomPitch);
direction = direction.Normalize();
}
var initialVelocity = direction * speed;
context.World.PublishEvent(new SpawnEntityEvent(
archetypeId,
ownerInput.MuzzlePosition,
ownerRotation.Rotation,
context.Owner,
initialVelocity
));
}
}
}