Пример #1
0
        internal void SendWeaponReload(Weapon w)
        {
            if (IsServer)
            {
                if (!PrunedPacketsToClient.ContainsKey(w.Comp.Data.Repo.Base))
                {
                    const PacketType type = PacketType.WeaponReload;
                    w.Comp.Data.Repo.Base.UpdateCompBasePacketInfo(w.Comp);

                    PacketInfo         oldInfo;
                    WeaponReloadPacket iPacket;
                    if (PrunedPacketsToClient.TryGetValue(w.Reload, out oldInfo))
                    {
                        iPacket          = (WeaponReloadPacket)oldInfo.Packet;
                        iPacket.EntityId = w.Comp.MyCube.EntityId;
                        iPacket.Data     = w.Reload;
                    }
                    else
                    {
                        iPacket          = PacketReloadPool.Get();
                        iPacket.MId      = ++w.MIds[(int)type];
                        iPacket.EntityId = w.Comp.MyCube.EntityId;
                        iPacket.SenderId = MultiplayerId;
                        iPacket.PType    = type;
                        iPacket.Data     = w.Reload;
                        iPacket.WeaponId = w.WeaponId;
                    }

                    PrunedPacketsToClient[w.Reload] = new PacketInfo {
                        Entity = w.Comp.MyCube,
                        Packet = iPacket,
                    };
                }
                else
                {
                    SendCompBaseData(w.Comp);
                }
            }
            else
            {
                Log.Line($"SendWeaponReload should never be called on Client");
            }
        }
Пример #2
0
        internal void SendConstructFoci(GridAi ai)
        {
            if (IsServer)
            {
                ++ai.Construct.Data.Repo.FocusData.Revision;

                if (!PrunedPacketsToClient.ContainsKey(ai.Construct.Data.Repo))
                {
                    PacketInfo          oldInfo;
                    ConstructFociPacket iPacket;
                    if (PrunedPacketsToClient.TryGetValue(ai.Construct.Data.Repo.FocusData, out oldInfo))
                    {
                        iPacket          = (ConstructFociPacket)oldInfo.Packet;
                        iPacket.EntityId = ai.MyGrid.EntityId;
                        iPacket.Data     = ai.Construct.Data.Repo.FocusData;
                    }
                    else
                    {
                        iPacket          = PacketConstructFociPool.Get();
                        iPacket.MId      = ++ai.MIds[(int)PacketType.ConstructFoci];
                        iPacket.EntityId = ai.MyGrid.EntityId;
                        iPacket.SenderId = MultiplayerId;
                        iPacket.PType    = PacketType.ConstructFoci;
                        iPacket.Data     = ai.Construct.Data.Repo.FocusData;
                    }

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