ba303e5fd0
- 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>
57 lines
3.0 KiB
C#
57 lines
3.0 KiB
C#
using ProjectM.Simulation;
|
|
using Unity.CharacterController;
|
|
using Unity.Entities;
|
|
using UnityEngine;
|
|
|
|
namespace ProjectM.Authoring
|
|
{
|
|
/// <summary>
|
|
/// Authoring for the kinematic-character half of the player ghost (M5b: Unity Character Controller). Added
|
|
/// to the SAME prefab GameObject as <c>PlayerAuthoring</c> + the GhostAuthoringComponent (multiple bakers
|
|
/// per GameObject is supported; both resolve the same Entity). The baker calls
|
|
/// <see cref="KinematicCharacterUtilities.BakeCharacter"/>, which adds the CC runtime components/buffers
|
|
/// (KinematicCharacterProperties, KinematicCharacterBody, StoredKinematicCharacterData, the four CC
|
|
/// buffers, kinematic PhysicsVelocity/PhysicsMass, PhysicsGravityFactor, CharacterInterpolation) and bakes
|
|
/// the GameObject's CapsuleCollider into a PhysicsCollider. We then add our
|
|
/// <see cref="CharacterComponent"/> + <see cref="CharacterControl"/>.
|
|
/// <para>
|
|
/// IMPORTANT: BakeCharacter aborts (logs an error, adds nothing) if the GameObject has a Rigidbody and
|
|
/// requires uniform (1,1,1) scale — so the M5 Rigidbody MUST be removed from the prefab (the M5
|
|
/// CapsuleCollider stays — it is what gets baked into the character's PhysicsCollider).
|
|
/// </para>
|
|
/// </summary>
|
|
[DisallowMultipleComponent]
|
|
public class PlayerCharacterAuthoring : MonoBehaviour
|
|
{
|
|
[Tooltip("Sharpness of ground velocity smoothing (higher = snappier).")]
|
|
public float GroundedMovementSharpness = CharacterComponent.DefaultGroundedSharpness;
|
|
|
|
public AuthoringKinematicCharacterProperties CharacterProperties = AuthoringKinematicCharacterProperties.GetDefault();
|
|
|
|
private class PlayerCharacterBaker : Baker<PlayerCharacterAuthoring>
|
|
{
|
|
public override void Bake(PlayerCharacterAuthoring authoring)
|
|
{
|
|
// Top-down planar character: no gravity (handled in the processor), stay on the plane.
|
|
var props = authoring.CharacterProperties;
|
|
props.SnapToGround = false; // no floor entity to snap to; planar
|
|
props.EvaluateGrounding = true; // floor/obstacle contact still reads as grounded
|
|
props.InterpolatePosition = true; // smooth fixed-step position for presentation
|
|
props.InterpolateRotation = false; // rotation owned by PlayerAimSystem
|
|
props.SimulateDynamicBody = false; // players don't physically shove each other (keep simple)
|
|
|
|
KinematicCharacterUtilities.BakeCharacter(this, authoring.gameObject, props);
|
|
|
|
var entity = GetEntity(TransformUsageFlags.Dynamic | TransformUsageFlags.WorldSpace);
|
|
|
|
AddComponent(entity, new CharacterComponent
|
|
{
|
|
GroundedMovementSharpness = authoring.GroundedMovementSharpness,
|
|
StepAndSlopeHandling = BasicStepAndSlopeHandlingParameters.GetDefault(),
|
|
});
|
|
AddComponent(entity, new CharacterControl());
|
|
}
|
|
}
|
|
}
|
|
}
|