当前位置: 首页>>代码示例>>C#>>正文


C# IMyReplicable.OnSave方法代码示例

本文整理汇总了C#中IMyReplicable.OnSave方法的典型用法代码示例。如果您正苦于以下问题:C# IMyReplicable.OnSave方法的具体用法?C# IMyReplicable.OnSave怎么用?C# IMyReplicable.OnSave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMyReplicable的用法示例。


在下文中一共展示了IMyReplicable.OnSave方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendReplicationCreate

        void SendReplicationCreate(IMyReplicable obj, EndpointId clientEndpoint)
        {
            var typeId = GetTypeIdByType(obj.GetType());
            var networkId = GetNetworkIdByObject(obj);

            var groups = m_replicableGroups[obj];
            Debug.Assert(groups.Count <= 255, "Unexpectedly high number of groups");

            m_sendStream.ResetWrite();
            m_sendStream.WriteTypeId(typeId);
            m_sendStream.WriteNetworkId(networkId);
            m_sendStream.WriteByte((byte)groups.Count);
            for (int i = 0; i < groups.Count; i++)
            {
                m_sendStream.WriteNetworkId(GetNetworkIdByObject(groups[i]));
            }
            obj.OnSave(m_sendStream);

            m_callback.SendReplicationCreate(m_sendStream, clientEndpoint);
            //Server.SendMessage(m_sendStream, clientId, PacketReliabilityEnum.RELIABLE, PacketPriorityEnum.LOW_PRIORITY, MyChannelEnum.Replication);
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:21,代码来源:MyReplicationServer.cs

示例2: SendReplicationCreate

        void SendReplicationCreate(IMyReplicable obj, ClientData clientData, EndpointId clientEndpoint)
        {
            
            if (m_replicationPaused)
            {
                clientData.PausedReplicables.Add(obj);
                return;
            }

            ProfilerShort.Begin("PrepareSave");
            var typeId = GetTypeIdByType(obj.GetType());
            var networkId = GetNetworkIdByObject(obj);

            var groups = m_replicableGroups[obj];
            Debug.Assert(groups.Count <= 255, "Unexpectedly high number of groups");

            m_sendStream.ResetWrite();
            m_sendStream.WriteTypeId(typeId);
            m_sendStream.WriteNetworkId(networkId);


            var streamable = obj as IMyStreamableReplicable;

            bool sendStreamed = streamable != null && streamable.NeedsToBeStreamed;
            if (streamable != null && streamable.NeedsToBeStreamed == false)
            {
                m_sendStream.WriteByte((byte)(groups.Count - 1));
            }
            else
            {
                m_sendStream.WriteByte((byte)groups.Count);
            }


            for (int i = 0; i < groups.Count; i++)
            {
                if (sendStreamed == false && groups[i].GroupType == StateGroupEnum.Streamining)
                {
                    continue;
                }
                m_sendStream.WriteNetworkId(GetNetworkIdByObject(groups[i]));
            }

            ProfilerShort.End();

            ProfilerShort.Begin("SaveReplicable");

            if (sendStreamed)
            {
                clientData.Replicables[obj].IsStreaming = true;
                m_callback.SendReplicationCreateStreamed(m_sendStream, clientEndpoint);
            }
            else
            {
                obj.OnSave(m_sendStream);
                ProfilerShort.Begin("Send");
                m_callback.SendReplicationCreate(m_sendStream, clientEndpoint);
                ProfilerShort.End();
            }
            ProfilerShort.End();
       
            //Server.SendMessage(m_sendStream, clientId, PacketReliabilityEnum.RELIABLE, PacketPriorityEnum.LOW_PRIORITY, MyChannelEnum.Replication);
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:63,代码来源:MyReplicationServer.cs


注:本文中的IMyReplicable.OnSave方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。