예제 #1
0
        public float GetGroupPriority(int frameCountWithoutSync, MyClientInfo forClient)
        {
            ProfilerShort.Begin("MyStreamingEntityStateGroup::GetGroupPriority");

            StreamClientData clientData = m_clientStreamData[forClient.EndpointId.Value];

            if (forClient.IsReplicableReady(Instance as IMyReplicable))
            {
                clientData.CurrentPart = 0;
                clientData.ForceSend   = false;
                clientData.ObjectData  = null;
                clientData.FailedIncompletePackets.Clear();
                clientData.SendPackets.Clear();
                ProfilerShort.End();
                return(0.0f);
            }

            float priority = forClient.HasReplicable(Instance as IMyReplicable) && clientData.Dirty ? Instance.GetPriority(forClient, false) * Instance.PriorityScale() : 0.0f;

            if (priority < 0.01f && (clientData.ForceSend || clientData.FailedIncompletePackets.Count > 0))
            {
                priority = Instance.PriorityScale();
            }

            ProfilerShort.End();
            return(priority);
        }
예제 #2
0
        /// <summary>
        /// Gets group priority, when overloaded it can be useful to scale base priority.
        /// </summary>
        public virtual float GetGroupPriority(int frameCountWithoutSync, MyClientInfo client)
        {
            ProfilerShort.Begin("MyPropertySyncStateGroup::GetGroupPriority");

            if (m_properties.Count == 0)
            {
                ProfilerShort.End();
                return(0);
            }

            if (client.HasReplicable(Owner) == false)
            {
                ProfilerShort.End();
                return(0);
            }
            // Called only on server
            float priority = client.GetPriority(Owner);

            if (priority <= 0)
            {
                ProfilerShort.End();
                return(0);
            }

            float adjustedPriority = 0;

            if (m_clientData[client.State.EndpointId].DirtyProperties.Bits > 0 && m_clientData[client.State.EndpointId].PacketId == null)
            {
                adjustedPriority = PriorityAdjust(frameCountWithoutSync, client.State, priority);
            }

            ProfilerShort.End();

            return(adjustedPriority);
        }
예제 #3
0
        /// <summary>
        /// Gets group priority, when overloaded it can be useful to scale base priority.
        /// </summary>
        public virtual float GetGroupPriority(int frameCountWithoutSync, MyClientInfo client)
        {
            if (m_properties.Count == 0)
            {
                return(0);
            }

            if (client.HasReplicable(Owner) == false)
            {
                return(0);
            }
            // Called only on server
            float priority = client.GetPriority(Owner);

            if (priority <= 0)
            {
                return(0);
            }

            if (m_clientData[client.State.EndpointId].DirtyProperties.Bits > 0 && m_clientData[client.State.EndpointId].PacketId == null)
            {
                return(PriorityAdjust(frameCountWithoutSync, client.State, priority));
            }
            else
            {
                return(0);
            }
        }
예제 #4
0
        public override float GetPriority(MyClientInfo client)
        {
            MyEntity owner  = Inventory.Owner.GetTopMostParent();
            var      parent = MyExternalReplicable.FindByObject(owner);

            if (parent != null && client.HasReplicable(parent) && parent.GetPriority(client) > 0.0f)
            {
                return(1.0f);
            }

            return(0.0f);
        }
        public override float GetPriority(MyClientInfo state, bool cached)
        {
            float priority = 0.0f;

            if (Instance == null || state.State == null)
            {
                return(priority);
            }

            ulong clientEndpoint = state.EndpointId.Value;

            if (cached)
            {
                if (m_cachedPriorityForClient != null && m_cachedPriorityForClient.ContainsKey(clientEndpoint))
                {
                    return(m_cachedPriorityForClient[clientEndpoint]);
                }
            }

            if (m_cachedPriorityForClient == null)
            {
                m_cachedPriorityForClient = new Dictionary <ulong, float>();
            }

            var player = state.State.GetPlayer();

            if (player != null && player.Character == Instance)
            {
                priority = 1.0f;
            }
            else
            {
                priority = base.GetPriority(state, cached);
            }

            if (Instance.IsUsing is MyShipController)
            {
                if (priority < 0.01f)
                {
                    //force pilot to client wve when its too far away.
                    var parent = MyExternalReplicable.FindByObject((Instance.IsUsing as MyShipController).CubeGrid);

                    if (state.HasReplicable(parent))
                    {
                        priority = 1.0f;
                    }
                }
            }

            m_cachedPriorityForClient[clientEndpoint] = priority;
            return(priority);
        }
        public override float GetPriority(MyClientInfo client, bool cached)
        {
            MyEntity owner = Inventory.Owner.GetTopMostParent();

            if (owner != m_owner)
            {
                m_owner  = owner;
                m_parent = MyExternalReplicable.FindByObject(owner);
            }

            if (m_parent != null && client.HasReplicable(m_parent))
            {
                return(1.0f);
            }

            return(0.0f);
        }
예제 #7
0
        public override float GetPriority(MyClientInfo client)
        {
            if (m_clientList == null)
            {
                m_clientList = new HashSet <ulong>();
            }

            if (m_clientList.Contains(client.EndpointId.Value))
            {
                return(1.0f);
            }

            MyEntity owner  = Inventory.Owner.GetTopMostParent();
            var      parent = MyExternalReplicable.FindByObject(owner);

            if (parent != null && client.HasReplicable(parent))
            {
                m_clientList.Add(client.EndpointId.Value);
                return(1.0f);
            }

            return(0.0f);
        }
예제 #8
0
        public override float GetPriority(MyClientInfo state)
        {
            float priority = 0.0f;

            if (Instance == null || state.State == null)
            {
                return(priority);
            }

            var player = state.State.GetPlayer();

            if (player != null && player.Character == Instance)
            {
                priority = 1.0f;
            }
            else
            {
                priority = base.GetPriority(state);
            }

            if (Instance.IsUsing is MyShipController)
            {
                if (priority < 0.01f)
                {
                    //force pilot to client wve when its too far away.
                    var parent = MyExternalReplicable.FindByObject((Instance.IsUsing as MyShipController).CubeGrid);

                    if (state.HasReplicable(parent))
                    {
                        priority = 1.0f;
                    }
                }
            }

            return(priority);
        }
        /// <summary>
        /// Gets group priority, when overloaded it can be useful to scale base priority.
        /// </summary>
        public virtual float GetGroupPriority(int frameCountWithoutSync, MyClientInfo client)
        {
            if (m_properties.Count == 0)
            {
                return 0;
            }

            if (client.HasReplicable(Owner) == false)
            {
                return 0;
            }
            // Called only on server
            float priority = client.GetPriority(Owner);
            if (priority <= 0)
                return 0;

            if (m_clientData[client.State.EndpointId].DirtyProperties.Bits > 0 && m_clientData[client.State.EndpointId].PacketId == null)
                return PriorityAdjust(frameCountWithoutSync, client.State, priority);
            else
                return 0;
        }
        public override float GetPriority(MyClientInfo state, bool cached)
        {
            float priority = 0.0f;

            if (Instance == null || state.State == null)
            {
                return(priority);
            }

            ulong clientEndpoint = state.EndpointId.Value;

            if (cached)
            {
                if (m_cachedPriorityForClient != null && m_cachedPriorityForClient.ContainsKey(clientEndpoint))
                {
                    return(m_cachedPriorityForClient[clientEndpoint]);
                }
            }

            if (m_cachedPriorityForClient == null)
            {
                m_cachedPriorityForClient = new Dictionary <ulong, float>();
            }

            var player = state.State.GetPlayer();

            if (player != null && player.Character == Instance)
            {
                priority = 1.0f;
            }
            else
            {
                //Sync all characters now, as they can serve as antenna relay
                priority = 0.1f;
                //priority = base.GetPriority(state, cached);
            }

            if (Instance.IsUsing is MyShipController)
            {
                //Pilot cannot have higher priority than the grid they control. Otherwise bugs ensue
                var parent = MyExternalReplicable.FindByObject((Instance.IsUsing as MyShipController).CubeGrid);

                if (state.HasReplicable(parent))
                {
                    priority = parent.GetPriority(state, cached);
                }
                else
                {
                    priority = 0.0f;
                }
            }

            if (MyFakes.MP_ISLANDS)
            {
                BoundingBoxD aabb;

                if (player.Character != null)
                {
                    if (MyIslandSyncComponent.Static.GetIslandAABBForEntity(player.Character, out aabb))
                    {
                        var ipriority = GetBasePriority(aabb.Center, aabb.Size, state);

                        MyIslandSyncComponent.Static.SetPriorityForIsland(player.Character, state.EndpointId.Value, ipriority);

                        return(ipriority);
                    }
                }
            }


            m_cachedPriorityForClient[clientEndpoint] = priority;
            return(priority);
        }