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 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); }