コード例 #1
0
        void Notify(SyncBase sync)
        {
            if (Owner != null && sync != null)
            {
                if (Sync.IsServer)
                {
                    foreach (var data in m_clientData)
                    {
                        if (data.Value != null)
                        {
                            data.Value.DirtyProperties[sync.Id] = true;
                        }
                    }

                    if (MyMultiplayer.GetReplicationServer() != null)
                    {
                        MyMultiplayer.GetReplicationServer().AddToDirtyGroups(this);
                    }
                }
                else
                {
                    m_dirtyProperties[sync.Id] = true;
                }
            }
        }
コード例 #2
0
        protected override float GetGroupPriority(int frameCountWithoutSync, MyClientInfo client, PrioritySettings settings)
        {
            ProfilerShort.Begin("MyCharacterPhysicsStateGroup::GetGroupPriority");
            const float highQualityDistance = 20; // under 8m, character physics sync gets high priority to have smooth movement

            MyMultiplayer.GetReplicationServer().AddToDirtyGroups(this);

            if (ResponsibleForUpdate(Entity, client.EndpointId))
            {
                if (client.PriorityMultiplier >= 1.0f)
                {
                    ProfilerShort.End();
                    return(1000.0f);
                }
            }

            var  clientPos     = ((MyClientState)client.State).Position;
            var  characterPos  = Entity.PositionComp.GetPosition();
            bool isHighQuality = Vector3D.DistanceSquared(clientPos, characterPos) < highQualityDistance * highQualityDistance;

            var priority = base.GetGroupPriority(frameCountWithoutSync, client, isHighQuality ? m_highQuality : settings);

            ProfilerShort.End();
            return(priority);
        }
コード例 #3
0
        /// <summary>
        /// Marks dirty for all clients.
        /// </summary>
        public void MarkDirty()
        {
            foreach (var client in m_clientData)
            {
                client.Value.DirtyProperties.Reset(true);
            }

            MyMultiplayer.GetReplicationServer().AddToDirtyGroups(this);
        }
コード例 #4
0
        void InventoryChanged(MyInventoryBase obj)
        {
            if (m_clientInventoryUpdate == null)
            {
                return;
            }
            foreach (var clientData in m_clientInventoryUpdate)
            {
                m_clientInventoryUpdate[clientData.Key].Dirty = true;
            }

            MyMultiplayer.GetReplicationServer().AddToDirtyGroups(this);
        }
コード例 #5
0
        public void OnAck(MyClientStateBase forClient, byte packetId, bool delivered)
        {
            var data = m_clientData[forClient.EndpointId];

            Debug.Assert(data.PacketId == null || data.PacketId == packetId, "Packet ID does not match, error in replication server, reporting ACK for something invalid");

            if (delivered)
            {
                data.SentProperties.Bits = 0; // Nothing sent now
            }
            else
            {
                // Not delivered, add sent to dirty
                data.DirtyProperties.Bits |= data.SentProperties.Bits;
                MyMultiplayer.GetReplicationServer().AddToDirtyGroups(this);
            }
            data.PacketId = null;
        }
コード例 #6
0
        public void OnAck(MyClientStateBase forClient, byte packetId, bool delivered)
        {
            InventoryClientData clientData;

            if (m_clientInventoryUpdate.TryGetValue(forClient.EndpointId.Value, out clientData))
            {
                InventoryDeltaInformation packetInfo;
                if (clientData.SendPackets.TryGetValue(packetId, out packetInfo))
                {
                    if (delivered == false)
                    {
                        clientData.FailedIncompletePackets.Add(packetInfo);
                        MyMultiplayer.GetReplicationServer().AddToDirtyGroups(this);
                    }

                    clientData.SendPackets.Remove(packetId);
                }
            }
        }
コード例 #7
0
        public void CreateClientData(MyClientStateBase forClient)
        {
            if (m_clientInventoryUpdate == null)
            {
                m_clientInventoryUpdate = new Dictionary <ulong, InventoryClientData>();
            }

            InventoryClientData data;

            if (m_clientInventoryUpdate.TryGetValue(forClient.EndpointId.Value, out data) == false)
            {
                m_clientInventoryUpdate[forClient.EndpointId.Value] = new InventoryClientData();
                data = m_clientInventoryUpdate[forClient.EndpointId.Value];
            }
            data.Dirty = false;

            List <MyPhysicalInventoryItem> items = Inventory.GetItems();

            foreach (var serverItem in items)
            {
                MyFixedPoint amount = serverItem.Amount;

                var gasItem = serverItem.Content as MyObjectBuilder_GasContainerObject;
                if (gasItem != null)
                {
                    amount = (MyFixedPoint)gasItem.GasLevel;
                }

                ClientInvetoryData item = new ClientInvetoryData()
                {
                    Item = serverItem, Amount = amount
                };
                data.ClientItemsSorted[serverItem.ItemId] = item;
                data.ClientItems.Add(item);
            }

            MyMultiplayer.GetReplicationServer().AddToDirtyGroups(this);
        }