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


C# IMyReplicable.OnDestroy方法代码示例

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


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

示例1: SetReplicableReady

        /// <summary>
        /// Marks replicable as successfully created, ready to receive events and state groups data.
        /// </summary>
        void SetReplicableReady(NetworkId networkId, IMyReplicable replicable)
        {
            MyPendingReplicable pendingReplicable;
            if (m_pendingReplicables.TryGetValue(networkId, out pendingReplicable))
            {
                var ids = pendingReplicable.StateGroupIds;

                AddNetworkObjectClient(networkId, replicable);

                using (m_tmpGroups)
                {
                    replicable.GetStateGroups(m_tmpGroups);
                    Debug.Assert(ids.Count == m_tmpGroups.Count, "Number of state groups on client and server for replicable does not match");
                    for (int i = 0; i < m_tmpGroups.Count; i++)
                    {
                        if (m_tmpGroups[i] != replicable)
                            AddNetworkObjectClient(ids[i], m_tmpGroups[i]);
                    }
                }

                m_pendingReplicables.Remove(networkId);
                m_eventBuffer.ProcessEvents(networkId, m_eventHandler);

                m_sendStream.ResetWrite();
                m_sendStream.WriteNetworkId(networkId);
                m_callback.SendReplicableReady(m_sendStream);
            }
            else
            {
                // Replicable was already destroyed on server, during it's load on client
                m_eventBuffer.RemoveEvents(networkId);
                replicable.OnDestroy();
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:37,代码来源:MyReplicationClient.cs

示例2: SetReplicableReady

        /// <summary>
        /// Marks replicable as successfully created, ready to receive events and state groups data.
        /// </summary>
        void SetReplicableReady(NetworkId networkId, IMyReplicable replicable, bool loaded)
        {
            MyPendingReplicable pendingReplicable;
            if (m_pendingReplicables.TryGetValue(networkId, out pendingReplicable))
            {
                m_pendingReplicables.Remove(networkId);

                if (loaded)
                {
                    var ids = pendingReplicable.StateGroupIds;

                    AddNetworkObjectClient(networkId, replicable);

                    using (m_tmpGroups)
                    {
                        
                        IMyStreamableReplicable streamable = replicable as IMyStreamableReplicable;
                        if (streamable != null && pendingReplicable.IsStreaming)
                        {
                            var group = streamable.GetStreamingStateGroup();
                            m_tmpGroups.Add(group);
                        }

                        replicable.GetStateGroups(m_tmpGroups);
                        Debug.Assert(ids.Count == m_tmpGroups.Count, "Number of state groups on client and server for replicable does not match");
                        for (int i = 0; i < m_tmpGroups.Count; i++)
                        {
                            if (m_tmpGroups[i] != replicable && m_tmpGroups[i].GroupType != StateGroupEnum.Streamining)
                            {
                                AddNetworkObjectClient(ids[i], m_tmpGroups[i]);
                            }
                        }
                    }
                    m_eventBuffer.ProcessEvents(networkId, m_eventHandler, m_isBlockedHandler, NetworkId.Invalid);
                }
                else
                {
                    MyLog.Default.WriteLine("Failed to create replicable ! Type : " + replicable.ToString());
                    m_eventBuffer.RemoveEvents(networkId);

                    IMyStreamableReplicable streamable = replicable as IMyStreamableReplicable;
                    if (streamable != null && pendingReplicable.IsStreaming)
                    {
                        var group = streamable.GetStreamingStateGroup();
                        group.Destroy();
                        NetworkId streaingGroupId;
                        if (TryGetNetworkIdByObject(group, out streaingGroupId))
                        {
                            RemoveNetworkedObject(group);
                        }
                        MyLog.Default.WriteLine("removing streaming group for not loaded replicable !");
                    }
                }

                m_sendStream.ResetWrite();
                m_sendStream.WriteNetworkId(networkId);
                m_sendStream.WriteBool(loaded);
                m_callback.SendReplicableReady(m_sendStream);
            }
            else
            {
                m_pendingReplicables.Remove(networkId);
                using (m_tmpGroups)
                {
                    IMyStreamableReplicable streamable = replicable as IMyStreamableReplicable;
                    if (streamable != null && streamable.NeedsToBeStreamed)
                    {
                        var group = streamable.GetStreamingStateGroup();
                        m_tmpGroups.Add(group);
                        MyLog.Default.WriteLine("removing streaming group for not loaded replicable !" );
                    }

                    replicable.GetStateGroups(m_tmpGroups);
                    foreach (var g in m_tmpGroups)
                    {
                        if (g != null) // when terminal repblicable fails to attach to block its state group is null becouase its created inside hook method.
                        {
                            g.Destroy();
                        }
                    }
                }      
                replicable.OnDestroy();
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:87,代码来源:MyReplicationClient.cs


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