acdream/src/AcDream.Runtime/Physics/RuntimeProjectile.cs
Erik 2aee33569f refactor(runtime): own projectile simulation
Move projectile component identity, prediction invalidation, spatial worksets, authoritative corrections, and the retail physics step into AcDream.Runtime. Keep App as the DAT-shape and presentation adapter so ACE outcomes and visible behavior remain unchanged.
2026-07-26 14:17:42 +02:00

40 lines
1.2 KiB
C#

using AcDream.Core.Physics;
namespace AcDream.Runtime.Physics;
/// <summary>
/// Presentation-free projectile component attached to one canonical Runtime
/// entity incarnation. The body is retail's one <c>CPhysicsObj</c>; the
/// prepared Setup sphere and prediction version die with the same incarnation.
/// </summary>
public interface IRuntimeProjectile
{
PhysicsBody Body { get; }
ProjectileCollisionSphere CollisionSphere { get; }
ulong PredictionAuthorityVersion { get; }
}
internal sealed class RuntimeProjectile : IRuntimeProjectile
{
internal RuntimeProjectile(
PhysicsBody body,
ProjectileCollisionSphere collisionSphere)
{
Body = body ?? throw new ArgumentNullException(nameof(body));
if (!collisionSphere.IsValid)
{
throw new ArgumentOutOfRangeException(
nameof(collisionSphere),
"A Runtime projectile requires one valid prepared Setup sphere.");
}
CollisionSphere = collisionSphere;
}
public PhysicsBody Body { get; }
public ProjectileCollisionSphere CollisionSphere { get; }
public ulong PredictionAuthorityVersion { get; private set; }
internal void InvalidatePrediction() =>
PredictionAuthorityVersion++;
}