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


C# Packets.GameBitBuffer类代码示例

本文整理汇总了C#中D3Sharp.Net.Game.Packets.GameBitBuffer的典型用法代码示例。如果您正苦于以下问题:C# GameBitBuffer类的具体用法?C# GameBitBuffer怎么用?C# GameBitBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GameBitBuffer类属于D3Sharp.Net.Game.Packets命名空间,在下文中一共展示了GameBitBuffer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Encode

 public void Encode(GameBitBuffer buffer)
 {
     buffer.WriteInt(32, snoQuest);
     buffer.WriteInt(32, Field1);
     buffer.WriteInt(2, (int)Field2);
 }
开发者ID:darkschasu,项目名称:d3sharp,代码行数:6,代码来源:GameMessageTypes.cs

示例2: Identify

        public static void Identify(IConnection connection, MemoryStream stream)
        {
            //We Should move this part to a more central position
            if (gameMessages == null)
            {
                gameMessages = new Dictionary<Type, Action<GameMessage, GameBitBuffer, IConnection>>();
                var actionInfos = typeof(GameRouter).GetMethods().Where(o => o.GetParameters().Where(a => a.ParameterType == typeof(GameMessage)).Count() == 1 && 
                        o.GetParameters().Where(a => a.ParameterType == typeof(IConnection)).Count() == 1 &&
                        o.GetParameters().Where(a => a.ParameterType == typeof(GameBitBuffer)).Count() == 1
                    ).ToList();
                foreach (var actionInfo in actionInfos)
                {
                    Action<GameMessage, GameBitBuffer, IConnection> action = (Action<GameMessage, GameBitBuffer, IConnection>)Delegate.CreateDelegate(typeof(Action<GameMessage, GameBitBuffer, IConnection>), actionInfo);
                    Type typ = Type.GetType("D3Sharp.Net.Game.Packets." + actionInfo.Name);
                    gameMessages.Add(typ, action);
                }
            }
            //

            GameBitBuffer _incomingBuffer = new GameBitBuffer(512);
            GameBitBuffer _outgoingBuffer = new GameBitBuffer(ushort.MaxValue);

            _outgoingBuffer.WriteInt(32, 0);

            var header = new GameHeader(stream);
            var payload = new byte[header.Length - 6];

            stream.Read(payload, 0, (int)header.Length - 6);

            _incomingBuffer.AppendData(header.Data);
            _incomingBuffer.AppendData(payload);

            while (_incomingBuffer.IsPacketAvailable())
            {
                int end = _incomingBuffer.Position;
                end += _incomingBuffer.ReadInt(32) * 8;

                while ((end - _incomingBuffer.Position) >= 9)
                {
                    GameMessage msg = _incomingBuffer.ParseMessage();

                    Logger.LogIncoming(msg);
                    try
                    {
                        if (gameMessages.ContainsKey(GetMessageType(msg.Id)))
                            gameMessages[GetMessageType(msg.Id)](msg, _outgoingBuffer, connection);
                        else
                            Logger.Debug("Unhandled game message: 0x{0:X4} {1}", msg.Id, msg.GetType().Name);
                    }
                    catch (NotImplementedException)
                    {
                        Logger.Debug("Unhandled game message: 0x{0:X4} {1}", msg.Id, msg.GetType().Name);
                    }
                }

                _incomingBuffer.Position = end;
            }
        }
开发者ID:darkschasu,项目名称:d3sharp,代码行数:58,代码来源:GameRouter.cs

示例3: FlushOutgoingBuffer

 public static void FlushOutgoingBuffer(GameBitBuffer buffer, IConnection connection)
 {
     if (buffer.Length > 32)
     {
         var data = buffer.GetPacketAndReset();
         connection.Send(data);
     }
 }
开发者ID:darkschasu,项目名称:d3sharp,代码行数:8,代码来源:GameRouter.cs

示例4: Parse

 public override void Parse(GameBitBuffer buffer)
 {
     Field0 = new Vector3D();
     Field0.Parse(buffer);
     Field1 = buffer.ReadInt(32);
     Field2 = buffer.ReadInt(32);
 }
开发者ID:darkschasu,项目名称:d3sharp,代码行数:7,代码来源:GameMessageTypes.cs

示例5: SimpleMessage

        public static void SimpleMessage(GameMessage _msg, GameBitBuffer buffer, IConnection connection)
        {
            var msg = (SimpleMessage)_msg;

            switch (msg.Id)
            {
                case 0x0030: // Sent with DwordDataMessage(0x0125, Value:0) and SimpleMessage(0x0125)
                    {
                        #region hardcoded1
                        #region HirelingInfo
                        SendMessage(new HirelingInfoUpdateMessage()
                        {
                            Id = 0x009D,
                            Field0 = 0x00000001,
                            Field1 = false,
                            Field2 = -1,
                            Field3 = 0x00000000,
                        }, buffer);

                        SendMessage(new HirelingInfoUpdateMessage()
                        {
                            Id = 0x009D,
                            Field0 = 0x00000002,
                            Field1 = false,
                            Field2 = -1,
                            Field3 = 0x00000000,
                        }, buffer);

                        SendMessage(new HirelingInfoUpdateMessage()
                        {
                            Id = 0x009D,
                            Field0 = 0x00000003,
                            Field1 = false,
                            Field2 = -1,
                            Field3 = 0x00000000,
                        }, buffer);
                        #endregion
                        #region Attribute Values 0x789E00E2
                        SendMessage(new AttributeSetValueMessage()
                        {
                            Id = 0x004C,
                            Field0 = 0x789E00E2,
                            Field1 = new NetAttributeKeyValue()
                            {
                                Field0 = 0x000FFFFF,
                                Attribute = GameAttribute.Attributes[0x015B], // Banter_Cooldown
                                Int = 0x000007C9,
                                Float = 0f,
                            },
                        }, buffer);

                        SendMessage(new AttributeSetValueMessage()
                        {
                            Id = 0x004C,
                            Field0 = 0x789E00E2,
                            Field1 = new NetAttributeKeyValue()
                            {
                                Field0 = 0x00020CBE,
                                Attribute = GameAttribute.Attributes[0x01CC], // Buff_Active
                                Int = 0x00000001,
                                Float = 0f,
                            },
                        }, buffer);

                        SendMessage(new AttributeSetValueMessage()
                        {
                            Id = 0x004C,
                            Field0 = 0x789E00E2,
                            Field1 = new NetAttributeKeyValue()
                            {
                                Field0 = 0x00033C40,
                                Attribute = GameAttribute.Attributes[0x01CC], // Buff_Active
                                Int = 0x00000000,
                                Float = 0f,
                            },
                        }, buffer);

                        SendMessage(new AttributeSetValueMessage()
                        {
                            Id = 0x004C,
                            Field0 = 0x789E00E2,
                            Field1 = new NetAttributeKeyValue()
                            {
                                Attribute = GameAttribute.Attributes[0x00D7], // Immobolize
                                Int = 0x00000000,
                                Float = 0f,
                            },
                        }, buffer);

                        SendMessage(new AttributeSetValueMessage()
                        {
                            Id = 0x004C,
                            Field0 = 0x789E00E2,
                            Field1 = new NetAttributeKeyValue()
                            {
                                Attribute = GameAttribute.Attributes[0x00D6], // Untargetable
                                Int = 0x00000000,
                                Float = 0f,
                            },
                        }, buffer);
//.........这里部分代码省略.........
开发者ID:darkschasu,项目名称:d3sharp,代码行数:101,代码来源:GameRouter.cs

示例6: SendMessage

 public static void SendMessage(GameMessage msg, GameBitBuffer buffer)
 {
     buffer.EncodeMessage(msg);
 }
开发者ID:darkschasu,项目名称:d3sharp,代码行数:4,代码来源:GameRouter.cs

示例7: JoinBNetGameMessage

        public static void JoinBNetGameMessage(GameMessage _msg, GameBitBuffer buffer, IConnection connection)
        {
            var msg = (JoinBNetGameMessage)_msg;

            if (msg.Id != 0x000A)
                throw new NotImplementedException();

            SendMessage(new VersionsMessage()
            {
                Id = 0x000D,
                SNOPackHash = msg.SNOPackHash,
                ProtocolHash = GameRouter.ImplementedProtocolHash,
                Version = "0.3.0.7333",
            }, buffer);
            FlushOutgoingBuffer(buffer, connection);

            SendMessage(new ConnectionEstablishedMessage()
            {
                Id = 0x002E,
                Field0 = 0x00000000,
                Field1 = 0x4BB91A16,
                Field2 = msg.SNOPackHash,
            }, buffer);
            SendMessage(new GameSetupMessage()
            {
                Id = 0x002F,
                Field0 = 0x00000077,
            }, buffer);

            SendMessage(new SavePointInfoMessage()
            {
                Id = 0x0045,
                snoLevelArea = -1,
            }, buffer);

            SendMessage(new HearthPortalInfoMessage()
            {
                Id = 0x0046,
                snoLevelArea = -1,
                Field1 = -1,
            }, buffer);

            SendMessage(new ActTransitionMessage()
            {
                Id = 0x00A8,
                Field0 = 0x00000000,
                Field1 = true,
            }, buffer);

            #region Quest
            SendMessage(new QuestUpdateMessage()
            {
                Id = 0x0093,
                snoQuest = 0x00015694,
                snoLevelArea = -1,
                Field2 = -1,
                Field3 = false,
                Field4 = false,
            }, buffer);

            SendMessage(new QuestMeterMessage()
            {
                Id = 0x0094,
                snoQuest = 0x00015694,
                Field1 = -1,
                Field2 = -1f,
            }, buffer);

            SendMessage(new QuestUpdateMessage()
            {
                Id = 0x0093,
                snoQuest = 0x0001199F,
                snoLevelArea = -1,
                Field2 = -1,
                Field3 = false,
                Field4 = false,
            }, buffer);

            SendMessage(new QuestMeterMessage()
            {
                Id = 0x0094,
                snoQuest = 0x0001199F,
                Field1 = -1,
                Field2 = -1f,
            }, buffer);

            SendMessage(new QuestUpdateMessage()
            {
                Id = 0x0093,
                snoQuest = 0x00011A1D,
                snoLevelArea = -1,
                Field2 = -1,
                Field3 = false,
                Field4 = false,
            }, buffer);

            SendMessage(new QuestMeterMessage()
            {
                Id = 0x0094,
                snoQuest = 0x00011A1D,
//.........这里部分代码省略.........
开发者ID:darkschasu,项目名称:d3sharp,代码行数:101,代码来源:GameRouter.cs


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