33 lines
925 B
C#
33 lines
925 B
C#
using Unity.Burst;
|
|
using Unity.Collections;
|
|
using Unity.Entities;
|
|
using Unity.NetCode;
|
|
|
|
namespace EE2Clone.NetCode
|
|
{
|
|
/// <summary>
|
|
/// Server-side system that monitors for disconnected players and logs events.
|
|
/// </summary>
|
|
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
|
|
public partial struct ConnectionMonitorSystem : ISystem
|
|
{
|
|
public void OnCreate(ref SystemState state)
|
|
{
|
|
state.RequireForUpdate<NetworkId>();
|
|
}
|
|
|
|
public void OnUpdate(ref SystemState state)
|
|
{
|
|
// Count active connections for logging/debugging
|
|
int connectionCount = 0;
|
|
foreach (var _ in SystemAPI.Query<RefRO<NetworkId>>()
|
|
.WithAll<NetworkStreamInGame>())
|
|
{
|
|
connectionCount++;
|
|
}
|
|
|
|
// Future: detect disconnections and handle AI takeover
|
|
}
|
|
}
|
|
}
|