public void AddNewReplicateObject(IReplicatableObject replicator, string Id, byte OwnerId) { if (replicator == null) { DebugLogging("Replicator is null. AddNewReplicatedObject Failed"); return; } if (RepObjPairs.ContainsKey(Id)) { return; } ReplicationInfoContainer repinfo = replicator.GetInfoContainer(); repinfo.Id = Id; repinfo.OwnerNetId = OwnerId; repinfo.RPCRequestHandler += (data) => SendTcpPacket(encoding.GetBytes("RPC," + repinfo.Id + ",").Concat(data).ToArray()); repinfo.ReAssignResourcesRequestHandler += (data) => { string resIddata = ""; replicator.GetResourceObj().GetAllDependResources().ForEach((res) => { resIddata += "," + res.Id; }); SendTcpPacket("ResUp," + repinfo.Id + resIddata); }; DebugLogging("Regist New RepObj : " + repinfo.Id); RepObjPairs.Add(Id, replicator); OnNewRepObjectAdded?.Invoke(replicator); }
public void RegistReplicationObject(IReplicatableObject replicator, string Id, byte OwnerId) { if (replicator == null) { UnityEngine.Debug.Log("Replicator is null. RegistReplicatedObject Failed"); return; } if (ReplicationDict.ContainsKey(Id)) { return; } ReplicationInfoContainer repinfo = replicator.GetInfoContainer(); repinfo.Id = Id; repinfo.OwnerNetId = OwnerId; UnityEngine.Debug.Log("Regist New RepObj : " + repinfo.Id); ReplicationDict.Add(Id, replicator); OnNewObejctRegisted?.Invoke(replicator); }
public void RegistNewReplicationObject(IReplicatableObject replicator, string ObjId, ClientDataContainer_ForTool Register) { ReplicationInfoContainer repinfo = replicator.GetInfoContainer(); RepObjects.Add(replicator); repinfo.Id = ObjId; repinfo.OwnerNetId = Register.NetworkId; repinfo.RPCRequestHandler += (data) => SendTcpPacket(encoding.GetBytes("RPC," + repinfo.Id + ",").Concat(data).ToArray()); repinfo.ReAssignResourcesRequestHandler += (data) => { string resIddata = ""; replicator.GetResourceObj().GetAllDependResources().ForEach((res) => { resIddata += "," + res.Id; }); SendTcpPacket("ResUp," + repinfo.Id + resIddata); }; DebugLogging("Regist New RepObj : " + repinfo.Id); RepObjPairs.Add(ObjId, replicator); OnNewRepObjectAdded?.Invoke(replicator); }