diff --git a/Ragon.Client/Ragon.Client.csproj b/Ragon.Client/Ragon.Client.csproj index b1ce773..8bc8504 100644 --- a/Ragon.Client/Ragon.Client.csproj +++ b/Ragon.Client/Ragon.Client.csproj @@ -12,7 +12,7 @@ true none - /Users/edmand46/RagonProjects/ragon-oss-examples/Assets/Ragon/Runtime/Plugins + /Users/edmand46/UnityProjects/itd-client/Assets/Ragon/Runtime/Plugins/ diff --git a/Ragon.Client/Sources/Entity/RagonEntity.cs b/Ragon.Client/Sources/Entity/RagonEntity.cs index 39ae162..afb2e9b 100644 --- a/Ragon.Client/Sources/Entity/RagonEntity.cs +++ b/Ragon.Client/Sources/Entity/RagonEntity.cs @@ -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!; diff --git a/Ragon.Client/Sources/Entity/RagonProperty.cs b/Ragon.Client/Sources/Entity/RagonProperty.cs index df2ddec..e6c27d4 100644 --- a/Ragon.Client/Sources/Entity/RagonProperty.cs +++ b/Ragon.Client/Sources/Entity/RagonProperty.cs @@ -65,7 +65,7 @@ namespace Ragon.Client { if (!InvokeLocal) return; - + Changed?.Invoke(); } diff --git a/Ragon.Client/Sources/Handler/SnapshotHandler.cs b/Ragon.Client/Sources/Handler/SnapshotHandler.cs index efbebc9..555f336 100644 --- a/Ragon.Client/Sources/Handler/SnapshotHandler.cs +++ b/Ragon.Client/Sources/Handler/SnapshotHandler.cs @@ -45,6 +45,7 @@ internal class SnapshotHandler : IHandler public void Handle(RagonBuffer buffer) { + var entities = new List(); 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(); } } \ No newline at end of file diff --git a/Ragon.Relay/Sources/RelayServerPlugin.cs b/Ragon.Relay/Sources/RelayServerPlugin.cs index 97b05f6..710d727 100644 --- a/Ragon.Relay/Sources/RelayServerPlugin.cs +++ b/Ragon.Relay/Sources/RelayServerPlugin.cs @@ -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(); + } } \ No newline at end of file diff --git a/Ragon.Server/Sources/Plugin/BaseServerPlugin.cs b/Ragon.Server/Sources/Plugin/BaseServerPlugin.cs index 88b8183..0311f5c 100644 --- a/Ragon.Server/Sources/Plugin/BaseServerPlugin.cs +++ b/Ragon.Server/Sources/Plugin/BaseServerPlugin.cs @@ -49,7 +49,7 @@ public class BaseServerPlugin: IServerPlugin return true; } - public IRoomPlugin CreateRoomPlugin(RoomInformation information) + public virtual IRoomPlugin CreateRoomPlugin(RoomInformation information) { return new BaseRoomPlugin(); }