Core Game Loop Additions
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using Unity.Entities;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies which world REGION an entity belongs to. M6 splits the single server world into two
|
||||
/// spatial regions at a large coordinate offset — the persistent home <see cref="RegionId.Base"/> and
|
||||
/// the procedurally-arranged <see cref="RegionId.Expedition"/> — and uses per-connection GhostRelevancy
|
||||
/// to replicate each region only to the connections whose player is currently in it. Server-side only
|
||||
/// (NOT a [GhostField]; the server makes all relevancy decisions). Added to players on spawn and to
|
||||
/// every region-scoped ghost the server spawns. Untagged ghosts are global (relevant to everyone).
|
||||
/// </summary>
|
||||
public struct RegionTag : IComponentData
|
||||
{
|
||||
/// <summary>Region id (see <see cref="RegionId"/>): 0 = base, 1 = expedition.</summary>
|
||||
public byte Region;
|
||||
}
|
||||
|
||||
/// <summary>Region ids for <see cref="RegionTag.Region"/> (a byte, not an enum, to keep server/Burst code trivial).</summary>
|
||||
public static class RegionId
|
||||
{
|
||||
/// <summary>The persistent, shared home base.</summary>
|
||||
public const byte Base = 0;
|
||||
|
||||
/// <summary>The procedural expedition field (offset far from the base on +X).</summary>
|
||||
public const byte Expedition = 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deterministic mapping of a region id to its world-space origin. The base region keeps the existing
|
||||
/// home-base coordinates; the expedition region lives at a large +X offset so the two never overlap in
|
||||
/// the single shared PhysicsWorld. Pure (no RNG/wall-clock) — server-authoritative teleports and field
|
||||
/// spawners resolve region positions through here.
|
||||
/// </summary>
|
||||
public static class RegionMath
|
||||
{
|
||||
/// <summary>World-space X offset of the expedition region from the base region.</summary>
|
||||
public const float ExpeditionOffsetX = 1000f;
|
||||
|
||||
/// <summary>World-space origin of <paramref name="region"/>, given the base center (BaseGridMath.PlotCenter).</summary>
|
||||
public static float3 RegionOrigin(byte region, float3 baseCenter)
|
||||
{
|
||||
return region == RegionId.Expedition
|
||||
? baseCenter + new float3(ExpeditionOffsetX, 0f, 0f)
|
||||
: baseCenter;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user