Files
Project-M/Assets/_Project/Scripts/Simulation/Connection/ConnectionConfig.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

38 lines
1.6 KiB
C#

using Unity.Collections;
using Unity.Entities;
namespace ProjectM.Simulation
{
/// <summary>
/// Connection intent for the M4 LAN host/join flow. Lives in Simulation so both the server and
/// client worlds can read it. A UI (the UITK frontend menu via <c>WorldLauncher</c>) — or, in the editor, the auto-host system —
/// writes the desired <see cref="Mode"/> + endpoint and sets <see cref="Requested"/> true; the
/// per-world ConnectionControlSystem turns it into a netcode <c>NetworkStreamRequestListen</c> /
/// <c>NetworkStreamRequestConnect</c> and clears <see cref="Requested"/>. Direct IP/LAN only for now —
/// Unity Relay is deferred to a later pass. Created per-world as a singleton.
/// </summary>
/// <summary>Connection intent values (byte-const, matching the project's op/id convention — not an enum, so
/// they stay safe if a consumer is ever [BurstCompile]d). Written to <see cref="ConnectionConfig.Mode"/>.</summary>
public static class ConnectionMode
{
public const byte None = 0;
public const byte Host = 1;
public const byte Join = 2;
}
public struct ConnectionConfig : IComponentData
{
/// <summary>What to do with this world's network stream.</summary>
public byte Mode;
/// <summary>Dotted IPv4 to connect to (Join). Ignored for Host (binds AnyIpv4).</summary>
public FixedString64Bytes Address;
/// <summary>Listen/connect port.</summary>
public ushort Port;
/// <summary>Set true to request the control system act on Mode this frame; it clears the flag.</summary>
public bool Requested;
}
}