CC Package and Physics

This commit is contained in:
2026-06-02 08:56:26 -07:00
parent a5af81c8a8
commit 2ee30c01fd
37 changed files with 1295 additions and 142 deletions
@@ -0,0 +1,34 @@
using Unity.Burst;
using Unity.Entities;
using Unity.NetCode;
namespace ProjectM.Simulation
{
/// <summary>
/// Bridges replicated <see cref="PlayerInput"/> + data-driven <see cref="EffectiveCharacterStats"/> into
/// the CC processor's per-tick <see cref="CharacterControl"/>. Replaces the M5 <c>PlayerMoveSystem</c>:
/// instead of writing PhysicsVelocity, it writes the desired world velocity that
/// <see cref="CharacterProcessor"/> lerps toward inside the fixed-step character update. Runs in
/// <see cref="PredictedSimulationSystemGroup"/> after <see cref="StatRecomputeSystem"/> (fresh MoveSpeed)
/// and before the predicted fixed-step group (where the character physics steps). Derived purely from
/// replicated input + recomputed stats → identical on server, owning client, and across rollback.
/// Filtered to <see cref="Simulate"/> for predicted ghosts only.
/// </summary>
[UpdateInGroup(typeof(PredictedSimulationSystemGroup))]
[UpdateAfter(typeof(StatRecomputeSystem))]
[BurstCompile]
public partial struct PlayerControlSystem : ISystem
{
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
foreach (var (control, input, stats) in
SystemAPI.Query<RefRW<CharacterControl>, RefRO<PlayerInput>, RefRO<EffectiveCharacterStats>>()
.WithAll<Simulate>())
{
control.ValueRW.MoveVelocity =
CharacterControlMath.DesiredMovement(input.ValueRO.Move, stats.ValueRO.MoveSpeed);
}
}
}
}