Initial import
This commit is contained in:
32
Assets/Scripts/NetCode/ConnectionMonitorSystem.cs
Normal file
32
Assets/Scripts/NetCode/ConnectionMonitorSystem.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user