Add audio and particle services, update GamePresenter for game state management

This commit is contained in:
2025-10-30 03:24:51 +01:00
parent c373ed4953
commit 90d3abd83f
4 changed files with 86 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using CryptonymThunder.Code.Autoloads;
using CryptonymThunder.Code.Extensions;
using CryptonymThunder.Code.Presenters;
@@ -58,4 +59,46 @@ public class GodotWorldQuery(GamePresenter ownerNode) : IWorldQuery
var rotatedZ = -vector.X * (float)Math.Sin(yawRadians) + vector.Z * (float)Math.Cos(yawRadians);
return new Vector3(rotatedX, vector.Y, rotatedZ);
}
public IEnumerable<Entity> OverlapSphere(Vector3 position, float radius, Entity? ownerToExclude = null)
{
var spaceState = _godotWorld.DirectSpaceState;
var query = new PhysicsShapeQueryParameters3D();
var sphere = new SphereShape3D();
sphere.Radius = radius;
query.Shape = sphere;
query.Transform = new Transform3D(Basis.Identity, position.ToGodot());
query.CollisionMask = 1;
query.CollideWithBodies = true;
query.CollideWithAreas = false;
if (ownerToExclude.HasValue)
{
var ownerPresenter = ownerNode.GetPresenterNode(ownerToExclude.Value);
if (ownerPresenter != null)
{
query.Exclude = [((PhysicsBody3D)ownerPresenter).GetRid()];
}
}
var results = spaceState.IntersectShape(query);
if (results.Count == 0)
{
yield break;
}
foreach (var result in results)
{
if (result["collider"].Obj is Node3D collider)
{
if (_presenterRegistry.TryGetEntity(collider.GetInstanceId(), out var hitEntity))
{
yield return hitEntity;
}
}
}
}
}