Ejemplo n.º 1
0
        internal void SendAiData(GridAi ai)
        {
            if (IsServer)
            {
                PacketInfo   oldInfo;
                AiDataPacket iPacket;
                if (PrunedPacketsToClient.TryGetValue(ai.Data.Repo, out oldInfo))
                {
                    iPacket          = (AiDataPacket)oldInfo.Packet;
                    iPacket.EntityId = ai.MyGrid.EntityId;
                    iPacket.Data     = ai.Data.Repo;
                }
                else
                {
                    iPacket          = PacketAiPool.Get();
                    iPacket.MId      = ++ai.MIds[(int)PacketType.AiData];
                    iPacket.EntityId = ai.MyGrid.EntityId;
                    iPacket.SenderId = MultiplayerId;
                    iPacket.PType    = PacketType.AiData;
                    iPacket.Data     = ai.Data.Repo;
                }

                ++ai.Data.Repo.Revision;

                PrunedPacketsToClient[ai.Data.Repo] = new PacketInfo {
                    Entity = ai.MyGrid,
                    Packet = iPacket,
                };
            }
            else
            {
                Log.Line($"SendAiData should never be called on Client");
            }
        }