🎨 added null checks

This commit is contained in:
2024-01-13 15:15:29 +03:00
parent c64cc61c78
commit 0cd912a1aa
6 changed files with 19 additions and 7 deletions
+1 -1
View File
@@ -12,7 +12,7 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<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 Condition=" '$(Configuration)' == 'Debug' ">
+2 -2
View File
@@ -39,8 +39,8 @@ namespace Ragon.Client
public void Dispose()
{
_callbacks.Remove(_callback);
_localCallbacks.Remove(_callback);
_callbacks?.Remove(_callback);
_localCallbacks?.Remove(_callback);
_callbacks = null!;
_localCallbacks = null!;
+1 -1
View File
@@ -65,7 +65,7 @@ namespace Ragon.Client
{
if (!InvokeLocal)
return;
Changed?.Invoke();
}
@@ -45,6 +45,7 @@ internal class SnapshotHandler : IHandler
public void Handle(RagonBuffer buffer)
{
var entities = new List<RagonEntity>();
var playersCount = buffer.ReadUShort();
RagonLog.Trace("Players: " + playersCount);
for (var i = 0; i < playersCount; i++)
@@ -90,7 +91,8 @@ internal class SnapshotHandler : IHandler
_entityListener.OnEntityCreated(entity);
entity.Read(buffer);
entity.Attach();
entities.Add(entity);
}
var staticEntities = buffer.ReadUShort();
@@ -117,7 +119,8 @@ internal class SnapshotHandler : IHandler
entity.Prepare(_client, entityId, entityType, hasAuthority, player, RagonPayload.Empty);
entity.Read(buffer);
entity.Attach();
entities.Add(entity);
}
if (_client.Status == RagonStatus.LOBBY)
@@ -126,6 +129,9 @@ internal class SnapshotHandler : IHandler
_listenerList.OnJoined();
}
foreach (var entity in entities)
entity.Attach();
_listenerList.OnSceneLoaded();
}
}
+6
View File
@@ -1,5 +1,6 @@
using System;
using Newtonsoft.Json;
using Ragon.Server;
using Ragon.Server.Plugin;
namespace Ragon.Relay;
@@ -21,4 +22,9 @@ public class RelayServerPlugin: BaseServerPlugin
return true;
}
public override IRoomPlugin CreateRoomPlugin(RoomInformation information)
{
return new RelayRoomPlugin();
}
}
@@ -49,7 +49,7 @@ public class BaseServerPlugin: IServerPlugin
return true;
}
public IRoomPlugin CreateRoomPlugin(RoomInformation information)
public virtual IRoomPlugin CreateRoomPlugin(RoomInformation information)
{
return new BaseRoomPlugin();
}