🎨 added null checks
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<DebugType>none</DebugType>
|
<DebugType>none</DebugType>
|
||||||
<OutputPath>/Users/edmand46/RagonProjects/ragon-oss-examples/Assets/Ragon/Runtime/Plugins</OutputPath>
|
<OutputPath>/Users/edmand46/UnityProjects/itd-client/Assets/Ragon/Runtime/Plugins/</OutputPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ namespace Ragon.Client
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_callbacks.Remove(_callback);
|
_callbacks?.Remove(_callback);
|
||||||
_localCallbacks.Remove(_callback);
|
_localCallbacks?.Remove(_callback);
|
||||||
|
|
||||||
_callbacks = null!;
|
_callbacks = null!;
|
||||||
_localCallbacks = null!;
|
_localCallbacks = null!;
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ internal class SnapshotHandler : IHandler
|
|||||||
|
|
||||||
public void Handle(RagonBuffer buffer)
|
public void Handle(RagonBuffer buffer)
|
||||||
{
|
{
|
||||||
|
var entities = new List<RagonEntity>();
|
||||||
var playersCount = buffer.ReadUShort();
|
var playersCount = buffer.ReadUShort();
|
||||||
RagonLog.Trace("Players: " + playersCount);
|
RagonLog.Trace("Players: " + playersCount);
|
||||||
for (var i = 0; i < playersCount; i++)
|
for (var i = 0; i < playersCount; i++)
|
||||||
@@ -90,7 +91,8 @@ internal class SnapshotHandler : IHandler
|
|||||||
_entityListener.OnEntityCreated(entity);
|
_entityListener.OnEntityCreated(entity);
|
||||||
|
|
||||||
entity.Read(buffer);
|
entity.Read(buffer);
|
||||||
entity.Attach();
|
|
||||||
|
entities.Add(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
var staticEntities = buffer.ReadUShort();
|
var staticEntities = buffer.ReadUShort();
|
||||||
@@ -117,7 +119,8 @@ internal class SnapshotHandler : IHandler
|
|||||||
|
|
||||||
entity.Prepare(_client, entityId, entityType, hasAuthority, player, RagonPayload.Empty);
|
entity.Prepare(_client, entityId, entityType, hasAuthority, player, RagonPayload.Empty);
|
||||||
entity.Read(buffer);
|
entity.Read(buffer);
|
||||||
entity.Attach();
|
|
||||||
|
entities.Add(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_client.Status == RagonStatus.LOBBY)
|
if (_client.Status == RagonStatus.LOBBY)
|
||||||
@@ -126,6 +129,9 @@ internal class SnapshotHandler : IHandler
|
|||||||
_listenerList.OnJoined();
|
_listenerList.OnJoined();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var entity in entities)
|
||||||
|
entity.Attach();
|
||||||
|
|
||||||
_listenerList.OnSceneLoaded();
|
_listenerList.OnSceneLoaded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Ragon.Server;
|
||||||
using Ragon.Server.Plugin;
|
using Ragon.Server.Plugin;
|
||||||
|
|
||||||
namespace Ragon.Relay;
|
namespace Ragon.Relay;
|
||||||
@@ -21,4 +22,9 @@ public class RelayServerPlugin: BaseServerPlugin
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override IRoomPlugin CreateRoomPlugin(RoomInformation information)
|
||||||
|
{
|
||||||
|
return new RelayRoomPlugin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ public class BaseServerPlugin: IServerPlugin
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRoomPlugin CreateRoomPlugin(RoomInformation information)
|
public virtual IRoomPlugin CreateRoomPlugin(RoomInformation information)
|
||||||
{
|
{
|
||||||
return new BaseRoomPlugin();
|
return new BaseRoomPlugin();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user