Netcode Bootstrap

This commit is contained in:
Luis Gonzalez
2026-05-31 14:27:52 -07:00
parent 99d8d2d2a9
commit 7fa77ce821
1813 changed files with 2921554 additions and 84 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5e118095ea29346b188e4c17f8d29181
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,37 @@
using ProjectM.Simulation;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
namespace ProjectM.Authoring
{
/// <summary>
/// Authoring for the player ghost prefab. Bakes the gameplay components onto the entity and
/// exposes movement tunables for designers. Ghost replication, <c>GhostOwner</c> and
/// AutoCommandTarget are supplied by the GhostAuthoringComponent added on the same prefab
/// GameObject. <c>GetEntity(TransformUsageFlags.Dynamic)</c> ensures a runtime-mutable
/// LocalTransform exists.
/// </summary>
public class PlayerAuthoring : MonoBehaviour
{
[Min(0f)] public float MoveSpeed = 6f;
[Min(0f)] public float TurnRateDegreesPerSec = 720f;
private class PlayerBaker : Baker<PlayerAuthoring>
{
public override void Bake(PlayerAuthoring authoring)
{
var entity = GetEntity(authoring, TransformUsageFlags.Dynamic);
AddComponent<PlayerTag>(entity);
AddComponent(entity, new PlayerMoveStats
{
MoveSpeed = authoring.MoveSpeed,
TurnRateRadiansPerSec = math.radians(authoring.TurnRateDegreesPerSec)
});
AddComponent<PlayerFacing>(entity);
AddComponent<PlayerInput>(entity);
}
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 766c44362be2b4fcaa872e6fb44fc42f
@@ -4,6 +4,8 @@
"references": [
"ProjectM.Simulation",
"Unity.Entities",
"Unity.Entities.Hybrid",
"Unity.Collections",
"Unity.Mathematics",
"Unity.NetCode"
],
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a5cd4882c5ffe499fb63c8c385ddf8d2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,34 @@
using ProjectM.Simulation;
using Unity.Entities;
using UnityEngine;
namespace ProjectM.Authoring
{
/// <summary>
/// Authoring placed once in the gameplay subscene. Bakes a <see cref="PlayerSpawner"/> singleton
/// holding the player ghost prefab entity and a spawn point, which the server's
/// GoInGameServerSystem instantiates on each connect.
/// </summary>
public class PlayerSpawnerAuthoring : MonoBehaviour
{
[Tooltip("The Player ghost prefab to spawn for each connected client.")]
public GameObject PlayerPrefab;
public Vector3 SpawnPoint = Vector3.zero;
private class PlayerSpawnerBaker : Baker<PlayerSpawnerAuthoring>
{
public override void Bake(PlayerSpawnerAuthoring authoring)
{
// The spawner itself needs no transform; it is a data singleton.
var entity = GetEntity(authoring, TransformUsageFlags.None);
AddComponent(entity, new PlayerSpawner
{
PlayerPrefab = GetEntity(authoring.PlayerPrefab, TransformUsageFlags.Dynamic),
SpawnPoint = authoring.SpawnPoint
});
}
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5e56c91ba352644bd900142035ff2799