using AcDream.Core.Physics; namespace AcDream.Runtime.Physics; /// /// Presentation-free projectile component attached to one canonical Runtime /// entity incarnation. The body is retail's one CPhysicsObj; the /// prepared Setup sphere and prediction version die with the same incarnation. /// 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++; }