/// <summary> /// 生成单个Component的Patch /// </summary> /// <param name="leftEntity"></param> /// <param name="leftComponent"></param> /// <param name="rightEntity"></param> /// <param name="rightComponent"></param> public override void OnDiffComponent(IGameEntity leftEntity, IGameComponent leftComponent, IGameEntity rightEntity, IGameComponent rightComponent) { var serializer = serializerManager.GetSerializer(leftComponent.GetComponentId()); var bitMask = serializer.DiffNetworkObject(leftComponent as INetworkObject, rightComponent as INetworkObject); if (bitMask.HasValue()) { var componentPatch = ModifyComponentPatch.Allocate(leftComponent, rightComponent, bitMask); currentEntityPatch.AddComponentPatch(componentPatch); componentPatch.ReleaseReference(); } }
private AbstractComponentPatch CreateEmptyComponentPatch(ComponentReplicateOperationType opType) { switch (opType) { case ComponentReplicateOperationType.Add: return(Patch.AddComponentPatch.Allocate()); case ComponentReplicateOperationType.Del: return(DeleteComponentPatch.Allocate()); case ComponentReplicateOperationType.Mod: return(ModifyComponentPatch.Allocate()); default: throw new Exception(string.Format("invalid ComponentReplicateOperationType {0}", opType)); } }