Files
Project-M/Assets/_Project/Scripts/Simulation/Player/CharacterComponents.cs
T
kronic ba303e5fd0 Hygiene B3: single-sourcing & magic-number consolidation
- StructureCatalogAuthoring: WallCostOre -> WallCostBiomass (it bakes a Biomass cost; [FormerlySerializedAs] preserves the scene value).
- Harvester/Fabricator authoring: resource-id byte defaults reference ResourceId.Ore/.Charge instead of magic 2/4.
- RegionMath.RegionBoundaryX (= ExpeditionOffsetX*0.5) single-sources the region-flip X used by HudSystem + OnboardingSystem (was 500f in 3 places).
- CharacterComponent.DefaultGroundedSharpness single-sources the CC sharpness 15f (GetDefault, DashSystem, PlayerDeathStateSystem, PlayerCharacterAuthoring).
- InventorySlot [InternalBufferCapacity] references Tuning.InventoryMaxSlots.
- ConnectionMode enum -> byte-const class (project convention; removes the latent enum-in-Burst trap); field + one Seed() param become byte.
- Tuning.ChargerWindupTicks single-sources the Charger telegraph windup (EnemyBaker + TuningConfig.Defaults; was a bare 30 that could drift).
- (TicksPerSecond deliberately NOT added: no seconds->ticks conversion site exists; the tick-count fields are per-authoring designer tunables, so a const would be unreferenced.)

451/451 EditMode tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-07 23:29:43 -07:00

53 lines
2.5 KiB
C#

using System;
using Unity.CharacterController;
using Unity.Entities;
using Unity.Mathematics;
namespace ProjectM.Simulation
{
/// <summary>
/// Tunables for the top-down kinematic character (M5b: Unity Character Controller package). Twin-stick /
/// planar: NO jump, NO air control, NO gravity, NO view pitch. The per-tick target speed comes from the
/// data-driven <see cref="EffectiveCharacterStats.MoveSpeed"/> via <see cref="PlayerControlSystem"/>; this
/// component only carries the smoothing sharpness + step/slope handling the CC processor needs. Authored
/// on the player prefab by <c>PlayerCharacterAuthoring</c>. Not a ghost — movement replicates through the
/// owner-predicted LocalTransform (re-simulated on the owner, interpolated on remotes).
/// </summary>
[Serializable]
public struct CharacterComponent : IComponentData
{
/// <summary>The CC's default grounded-movement smoothing sharpness — the single source for GetDefault, the
/// authoring default, DashSystem's base, and the death-state reset.</summary>
public const float DefaultGroundedSharpness = 15f;
/// <summary>How quickly RelativeVelocity is lerped toward the target velocity on the ground.</summary>
public float GroundedMovementSharpness;
/// <summary>Step/slope handling params (defaults; planar ground so mostly inert).</summary>
public BasicStepAndSlopeHandlingParameters StepAndSlopeHandling;
public static CharacterComponent GetDefault()
{
return new CharacterComponent
{
GroundedMovementSharpness = DefaultGroundedSharpness,
StepAndSlopeHandling = BasicStepAndSlopeHandlingParameters.GetDefault(),
};
}
}
/// <summary>
/// Per-tick, NON-replicated control for the CC processor, derived each predicted tick from the replicated
/// <see cref="PlayerInput"/> by <see cref="PlayerControlSystem"/>. Derived (not authored, not a ghost): a
/// pure function of replicated input + recomputed stats, so it reproduces identically on server, owning
/// client, and across rollback re-simulation.
/// </summary>
[Serializable]
public struct CharacterControl : IComponentData
{
/// <summary>World-space desired velocity (already scaled by MoveSpeed, Y == 0). The processor lerps
/// RelativeVelocity toward this each tick.</summary>
public float3 MoveVelocity;
}
}