• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Plugins.HookContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Process

        public override void Process(ClientConnection conn, byte[] readBuffer, int length, int num)
        {
            if (conn.State == SlotState.ACCEPTED)
            {
                SlotManager.Schedule (conn, conn.DesiredQueue);
                return;
            }

            int whoAmI = conn.SlotIndex;

            if (NetPlay.slots[whoAmI].state == SlotState.ASSIGNING_SLOT)
            {
                NetPlay.slots[whoAmI].state = SlotState.SENDING_WORLD;
            }

            var ctx = new HookContext() { Connection = conn, Player = conn.Player };
            var args = new HookArgs.WorldRequestMessage()
            {
                SpawnX = Main.spawnTileX,
                SpawnY = Main.spawnTileY
            };
            HookPoints.WorldRequestMessage.Invoke(ref ctx, ref args);

            //NetMessage.SendData(7, whoAmI);
            var msg = NetMessage.PrepareThreadInstance();
            msg.WorldData(args.SpawnX, args.SpawnY);
            msg.Send(whoAmI);
        }
开发者ID:emreuyls,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:28,代码来源:WorldRequestMessage.cs


示例2: Process

        public override void Process(int whoAmI, byte[] readBuffer, int length, int num)
        {
            int playerId = readBuffer[num++]; //TODO: maybe check for forgery
            byte action = readBuffer[num];
            if (action == 1)
            {
                var player = Main.players[whoAmI];

                var ctx = new HookContext
                {
                    Connection = player.Connection,
                    Sender = player,
                    Player = player,
                };

                var args = new HookArgs.PlayerTriggeredEvent
                {
                    Type = WorldEventType.BOSS,
                    Name = "Skeletron",
                };

                HookPoints.PlayerTriggeredEvent.Invoke (ref ctx, ref args);

                if (ctx.CheckForKick () || ctx.Result == HookResult.IGNORE)
                    return;

                ProgramLog.Users.Log ("{0} @ {1}: Skeletron summoned by {2}.", player.IPAddress, whoAmI, player.Name);
                NetMessage.SendData (Packet.PLAYER_CHAT, -1, -1, string.Concat (player.Name, " has summoned Skeletron!"), 255, 255, 128, 150);
                NPC.SpawnSkeletron();
            }
            else if (action == 2)
            {
                NetMessage.SendData (51, -1, whoAmI, "", playerId, action, 0f, 0f, 0);
            }
        }
开发者ID:rakiru,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:35,代码来源:SummonSkeletronMessage.cs


示例3: ClientConnection

        public ClientConnection(Socket socket, int slot)
            : base(socket)
        {
            //var buf = NetMessage.buffer[id];
            //socket.SendBufferSize = 128000;
            connectedAt = time.Elapsed;

            if (slot >= 0) AssignSlot (slot);

            socket.LingerState = new LingerOption (true, 10);

            var ctx = new Terraria_Server.Plugins.HookContext
            {
                Connection = this,
            };

            var args = new Terraria_Server.Plugins.HookArgs.NewConnection ();

            Terraria_Server.Plugins.HookPoints.NewConnection.Invoke (ref ctx, ref args);

            if (ctx.CheckForKick ())
                return;

            lock (All)
            {
                indexInAll = All.Count;
                All.Add (this);
            }

            StartReceiving (new byte [4192]);
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:31,代码来源:ClientConnection.cs


示例4: Process

        public override void Process(ClientConnection conn, byte[] readBuffer, int length, int num)
        {
            var data = Encoding.ASCII.GetString (readBuffer, num, length - 1);
            var lines = data.Split ('\n');

            foreach (var line in lines)
            {
                if (line == "tdcm1")
                {
                    //player.HasClientMod = true;
                    ProgramLog.Log ("{0} is a TDCM protocol version 1 client.", conn.RemoteAddress);
                }
                else if (line == "tdsmcomp1")
                {
                    conn.CompressionVersion = 1;
                    ProgramLog.Log ("{0} supports TDSM compression version 1.", conn.RemoteAddress);
                }
            }

            var ctx = new HookContext
            {
                Connection = conn,
            };

            var args = new HookArgs.DisconnectReceived
            {
                Content = data,
                Lines   = lines,
            };

            HookPoints.DisconnectReceived.Invoke (ref ctx, ref args);

            ctx.CheckForKick ();
        }
开发者ID:rakiru,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:34,代码来源:DisconnectMessage.cs


示例5: OnUnkownPacketSend

        public static void OnUnkownPacketSend(ref HookContext ctx, ref HookArgs.UnkownSendPacket args)
        {
            switch (args.PacketId)
            {
                case (int)Packets.CLIENT_MOD_GOD:
                    {
                        NetMessageExtension msg = new NetMessageExtension();

                        if (args.RemoteClient != -1)
                        {
                            var player = Main.players[args.RemoteClient];

                            if (player.HasClientMod)
                            {
                                if (Server.AllowTDCMRPG)
                                {
                                    Server.notifyOps(
                                        String.Format("Failed attempt to {0} God Mode on an RPG Server.", true, (args.Number == 1) ? "give" : "remove"));
                                    return;
                                }

                                Server.notifyOps(
                                    String.Format("{0} {1} God Mode.", true, player.Name, (args.Number == 1) ? "has" : "doesn't have"));

                                msg.GodTDCMClient(args.Number == 1);
                                args.Message = msg;
                                ctx.SetResult(HookResult.IGNORE); //Let TDSM know it's to ignore returning.
                            }
                        }
                        break;
                    }

            }
        }
开发者ID:TimeBomb,项目名称:Essentials-TDSM,代码行数:34,代码来源:Net.cs


示例6: Process

        public override void Process(int whoAmI, byte[] readBuffer, int length, int num)
        {
            short identity = BitConverter.ToInt16(readBuffer, num);
            num += 2;
            byte owner = readBuffer[num];

            owner = (byte)whoAmI;

            int index = Projectile.FindExisting(identity, owner);
            if (index == 1000) return;

            var player = Main.players[whoAmI];

            var ctx = new HookContext
            {
                Connection = player.Connection,
                Player = player,
                Sender = player,
            };

            var args = new HookArgs.KillProjectileReceived
            {
                Id = identity,
                Owner = owner,
                Index = (short)index,
            };

            HookPoints.KillProjectileReceived.Invoke(ref ctx, ref args);

            if (ctx.CheckForKick())
            {
                return;
            }

            if (ctx.Result == HookResult.IGNORE)
            {
                return;
            }

            if (ctx.Result == HookResult.RECTIFY)
            {
                var msg = NetMessage.PrepareThreadInstance();
                msg.Projectile(Main.projectile[index]);
                msg.Send(whoAmI);
                return;
            }

            var projectile = Main.projectile[index];

            if (projectile.Owner == owner && projectile.identity == identity)
            {
                projectile.Kill(null, null);
                projectile.Reset();
                NetMessage.SendData(29, -1, whoAmI, "", (int)identity, (float)owner);
            }
        }
开发者ID:emreuyls,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:56,代码来源:KillProjectileMessage.cs


示例7: Process

        public override void Process(int whoAmI, byte[] readBuffer, int length, int num)
        {
            int x = BitConverter.ToInt32(readBuffer, num);
            num += 4;
            int y = BitConverter.ToInt32(readBuffer, num);
            num += 4;

            var player = Main.players[whoAmI];

            if (Math.Abs(player.Position.X / 16 - x) >= 7 || Math.Abs(player.Position.Y / 16 - y) >= 7)
            {
                return;
            }

            int chestIndex = Chest.FindChest(x, y);

            var ctx = new HookContext
            {
                Connection = player.Connection,
                Player = player,
                Sender = player,
            };

            var args = new HookArgs.ChestOpenReceived
            {
                X = x,
                Y = y,
                ChestIndex = (short)chestIndex,
            };

            HookPoints.ChestOpenReceived.Invoke(ref ctx, ref args);

            if (ctx.CheckForKick())
            {
                return;
            }

            if (ctx.Result == HookResult.IGNORE)
            {
                return;
            }

            if (ctx.Result == HookResult.DEFAULT && chestIndex > -1)
            {
                var user = Chest.UsingChest(chestIndex);
                if (user >= 0 && user != whoAmI) return;

                for (int i = 0; i < Chest.MAX_ITEMS; i++)
                {
                    NetMessage.SendData(32, whoAmI, -1, "", chestIndex, (float)i);
                }
                NetMessage.SendData(33, whoAmI, -1, "", chestIndex);
                Main.players[whoAmI].chest = chestIndex;
                return;
            }
        }
开发者ID:emreuyls,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:56,代码来源:OpenChestMessage.cs


示例8: Process

        public override void Process(int whoAmI, byte[] readBuffer, int length, int num)
        {
            int playerIndex = readBuffer[num];

            if (playerIndex != whoAmI)
            {
                NetPlay.slots[whoAmI].Kick ("Cheating detected (PLAYER_PVP_CHANGE forgery).");
                return;
            }

            var pvp = readBuffer[num + 1] == 1;
            var player = Main.players[whoAmI];

            var ctx = new HookContext
            {
                Connection = player.Connection,
                Player = player,
                Sender = player,
            };

            var args = new HookArgs.PvpSettingReceived
            {
                PvpFlag = pvp,
            };

            HookPoints.PvpSettingReceived.Invoke (ref ctx, ref args);

            if (ctx.CheckForKick ())
            {
                return;
            }

            if (ctx.Result == HookResult.IGNORE)
            {
                return;
            }

            if (ctx.Result == HookResult.RECTIFY)
            {
                NetMessage.SendData(30, whoAmI, -1, "", whoAmI);
                return;
            }

            player.hostile = pvp;

            string message = (player.hostile) ? " has enabled PvP!" : " has disabled PvP!";

            NetMessage.SendData(30, -1, whoAmI, "", whoAmI);
            NetMessage.SendData(25, -1, -1, player.Name + message, 255, (float)Main.teamColor[player.team].R, (float)Main.teamColor[player.team].G, (float)Main.teamColor[player.team].B);
        }
开发者ID:rakiru,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:50,代码来源:PlayerPvPChangeMessage.cs


示例9: OnServerStateChange

 void OnServerStateChange(ref HookContext ctx, ref HookArgs.ServerStateChange args)
 {
     if (args.ServerChangeState == ServerState.LOADED)
     {
         ProgramLog.Plugin.Log("Starting fishy mod...");
         fishy = new Fishy();
         ProgramLog.Plugin.Log("Fishy mod Started.");
     }
     else if (args.ServerChangeState == ServerState.STOPPING || args.ServerChangeState == ServerState.RESTARTING)
     {
         ProgramLog.Plugin.Log("Stopping fishy mod...");
         fishy.Stop();
         ProgramLog.Plugin.Log("Fishy mod Stopped.");
     }
 }
开发者ID:elevatorguy,项目名称:TDSM_fishy,代码行数:15,代码来源:fishyPlugin.cs


示例10: Process

        public override void Process(int whoAmI, byte[] readBuffer, int length, int num)
        {
            int start = num - 1;
            int playerIndex = readBuffer[num++];

            if (playerIndex != whoAmI)
            {
                NetPlay.slots[whoAmI].Kick ("Cheating detected (KILL_PLAYER forgery).");
                return;
            }

            var player = Main.players[whoAmI];

            var ctx = new HookContext
            {
                Connection = NetPlay.slots[whoAmI].conn,
                Sender = player,
                Player = player,
            };

            var args = new HookArgs.ObituaryReceived
            {
                Direction = (int)readBuffer[num++] - 1,
                Damage = BitConverter.ToInt16 (readBuffer, num++),
                PvpFlag = readBuffer[++num]
            };
            string obituary;
            if (!ParseString(readBuffer, num + 1, length - num - 1 + start, out obituary))
            {
                NetPlay.slots[whoAmI].Kick("Invalid characters in obituary message.");
                return;
            }
            args.Obituary = obituary;

            HookPoints.ObituaryReceived.Invoke (ref ctx, ref args);

            if (ctx.CheckForKick ())
                return;

            if (ctx.Result == HookResult.IGNORE)
                return;

            ProgramLog.Death.Log ("{0} @ {1}: [Death] {2}{3}", player.IPAddress, whoAmI, player.Name ?? "<null>", args.Obituary);

            player.KillMe (args.Damage, args.Direction, args.PvpFlag == 1, args.Obituary);

            NetMessage.SendData(44, -1, whoAmI, args.Obituary, whoAmI, args.Direction, args.Damage, args.PvpFlag);
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:48,代码来源:KillPlayerPvPMessage.cs


示例11: Process

        public override void Process(int whoAmI, byte[] readBuffer, int length, int num)
        {
            int x = BitConverter.ToInt32(readBuffer, num);
            num += 4;
            int y = BitConverter.ToInt32(readBuffer, num);

            if (Main.tile.At(x, y).Type != 21)
                return;

            var player = Main.players[whoAmI];

            var ctx = new HookContext
            {
                Connection = player.Connection,
                Player = player,
                Sender = player,
            };

            var args = new HookArgs.ChestBreakReceived
            {
                X = x, Y = y,
            };

            HookPoints.ChestBreakReceived.Invoke (ref ctx, ref args);

            if (ctx.CheckForKick ())
            {
                return;
            }

            if (ctx.Result == HookResult.IGNORE)
            {
                return;
            }

            if (ctx.Result == HookResult.RECTIFY)
            {
                NetMessage.SendTileSquare(whoAmI, x, y, 3);
                return;
            }

            WorldModify.KillTile(x, y, false, false, false, player);
            if (!Main.tile.At(x, y).Active || Main.tile.At(x, y).Type != 21)
            {
                NetMessage.SendData(17, -1, -1, "", 0, (float)x, (float)y);
            }
        }
开发者ID:rakiru,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:47,代码来源:KillTileMessage.cs


示例12: Process

        //TODO: redesign signs
        public override void Process(int whoAmI, byte[] readBuffer, int length, int num)
        {
            int start = num - 1;
            short signIndex = BitConverter.ToInt16(readBuffer, num);
            num += 2;
            int x = BitConverter.ToInt32(readBuffer, num);
            num += 4;
            int y = BitConverter.ToInt32(readBuffer, num);
            num += 4;

            short existing = (short)Sign.ReadSign (x, y);
            if (existing >= 0)
                signIndex = existing;

            string SignText;
            if (!ParseString(readBuffer, num, length - num + start, out SignText))
                return; // invalid characters

            var player = Main.players[whoAmI];

            var ctx = new HookContext
            {
                Connection = player.Connection,
                Sender = player,
                Player = player,
            };

            var args = new HookArgs.SignTextSet
            {
                X = x, Y = y,
                SignIndex = signIndex,
                Text = SignText,
                OldSign = Main.sign[signIndex],
            };

            HookPoints.SignTextSet.Invoke (ref ctx, ref args);

            if (ctx.CheckForKick () || ctx.Result == HookResult.IGNORE)
                return;

            if (Main.sign[signIndex] == null) Main.sign[signIndex] = new Sign ();
            Main.sign[signIndex].x = args.X;
            Main.sign[signIndex].y = args.Y;
            Sign.TextSign (signIndex, args.Text);
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:46,代码来源:WriteSignMessage.cs


示例13: LoadPlugins

        public static void LoadPlugins()
        {
            ProgramLog.Log(Languages.Startup_LoadingPlugins);
            Terraria_Server.Plugins.PluginManager.Initialize(Statics.PluginPath, Statics.LibrariesPath);

            var ctx = new HookContext()
            {
                Sender = ConsoleSender = new ConsoleSender()
            };

            var eArgs = new HookArgs.ServerStateChange()
            {
                ServerChangeState = ServerState.INITIALIZING
            };

            HookPoints.ServerStateChange.Invoke(ref ctx, ref eArgs);
            PluginManager.LoadPlugins();
            ProgramLog.Log(Languages.Startup_PluginsLoaded + ' ' + PluginManager.PluginCount);
        }
开发者ID:BomllsJ,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:19,代码来源:Program.cs


示例14: Process

        public override void Process(int whoAmI, byte[] readBuffer, int length, int num)
        {
            int x = BitConverter.ToInt32(readBuffer, num);
            num += 4;
            int y = BitConverter.ToInt32(readBuffer, num);
            num += 4;

            int signIndex = Sign.ReadSign(x, y);

            var player = Main.players[whoAmI];

            var ctx = new HookContext
            {
                Connection = player.Connection,
                Sender = player,
                Player = player,
            };

            var args = new HookArgs.SignTextGet
            {
                X = x, Y = y,
                SignIndex = (short)signIndex,
                Text = (signIndex >= 0 && Main.sign[signIndex] != null) ? Main.sign[signIndex].text : null,
            };

            HookPoints.SignTextGet.Invoke (ref ctx, ref args);

            if (ctx.CheckForKick () || ctx.Result == HookResult.IGNORE)
                return;

            if (args.Text != null)
            {
                var msg = NetMessage.PrepareThreadInstance ();
                msg.WriteSign (signIndex, x, y, args.Text);
                msg.Send (whoAmI);
            }
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:37,代码来源:ReadSignMessage.cs


示例15: Process

        public override void Process(int whoAmI, byte[] readBuffer, int length, int num)
        {
            if (readBuffer[num++] != whoAmI)
            {
                NetPlay.slots[whoAmI].Kick ("Cheating detected (PLAYER_STATE_UPDATE forgery).");
                return;
            }

            var player = Main.players[whoAmI];

            var ctx = new HookContext
            {
                Connection = player.Connection,
                Sender = player,
                Player = player,
            };

            var args = new HookArgs.StateUpdateReceived ();

            args.Parse (readBuffer, num);

            HookPoints.StateUpdateReceived.Invoke (ref ctx, ref args);

            if (ctx.CheckForKick ())
                return;

            player.oldVelocity = player.Velocity;
            args.ApplyParams (player);
            args.ApplyKeys (player);
            player.fallStart = (int)(player.Position.Y / 16f);

            if (NetPlay.slots[whoAmI].state == SlotState.PLAYING)
            {
                NetMessage.SendData(13, -1, whoAmI, "", whoAmI);
            }
        }
开发者ID:jason14747,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:36,代码来源:PlayerStateUpdateMessage.cs


示例16: Hurt

        /// <summary>
        /// Hurts player
        /// </summary>
        /// <param name="aggressor">Sender who hurt the Player</param>
        /// <param name="Damage">Damage to do</param>
        /// <param name="hitDirection">Direction of attack</param>
        /// <param name="pvp">Whether attack is PvP</param>
        /// <param name="quiet">Whether to announce</param>
        /// <param name="deathText">Text to display upon death</param>
        /// <param name="crit">Whether the hit is critical</param>
        /// <returns>Damage done</returns>
        public double Hurt(ISender aggressor, int Damage, int hitDirection, bool pvp = false, bool quiet = false, string deathText = " was slain...", bool crit = false)
        {
            if (this.immune) return 0.0;

            var proj = aggressor as Projectile;
            var plr = aggressor as Player;

            var ctx = new HookContext
            {
                Sender = aggressor,
                Player = proj != null ? (proj.Creator as Player) : plr,
            };

            ctx.Connection = ctx.Player != null ? ctx.Player.Connection : null;

            var args = new HookArgs.PlayerHurt
            {
                Victim = this,
                Damage = Damage,
                HitDirection = hitDirection,
                Pvp = pvp,
                Quiet = quiet,
                Obituary = deathText,
                Critical = crit,
            };

            HookPoints.PlayerHurt.Invoke (ref ctx, ref args);

            if (ctx.CheckForKick () || ctx.Result == HookResult.IGNORE)
                return 0.0;

            if (ctx.Result == HookResult.RECTIFY)
            {
                var conn = ctx.Connection;
                if (conn != null)
                {
                    var msg = NetMessage.PrepareThreadInstance ();
                    msg.PlayerHealthUpdate (whoAmi);
                    msg.Send (conn);
                }
                return 0.0;
            }

            NetMessage.SendData (26, -1, plr != null ? plr.whoAmi : -1, args.Obituary, whoAmi, args.HitDirection, args.Damage, args.Pvp ? 1 : 0, args.Critical ? 1 : 0);

            return HurtInternal (args.Damage, args.HitDirection, args.Pvp, args.Quiet, args.Obituary, args.Critical);
        }
开发者ID:rakiru,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:58,代码来源:Player.cs


示例17: OnPluginsLoaded

 void OnPluginsLoaded(ref HookContext ctx, ref HookArgs.PluginsLoaded args)
 {
     LoadPerms();
 }
开发者ID:Skiles,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:4,代码来源:TDSMPermissions.cs


示例18: onPlayerJoin

 void onPlayerJoin(ref HookContext ctx, ref HookArgs.PlayerEnteringGame args)
 {
     //ctx.Player.A = AccessLevel.OP;
 }
开发者ID:Skiles,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:4,代码来源:TDSMPermissions.cs


示例19: OnSignEdit

 void OnSignEdit(ref HookContext ctx, ref HookArgs.SignTextSet args)
 {
     foreach (Region rgn in regionManager.Regions)
         {
             if (rgn.HasPoint(new Vector2(args.X, args.Y)))
             {
                 if (ctx.Sender is Player)
                 {
                     if (IsRestrictedForUser(ctx.Player, rgn, DoorChange))
                     {
                         ctx.SetResult(HookResult.IGNORE);
                         ctx.Player.sendMessage("You cannot edit this area!", ChatColor.Red);
                         return;
                     }
                 }
             }
         }
 }
开发者ID:emreuyls,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:18,代码来源:Regions.cs


示例20: OnServerStateChange

 void OnServerStateChange(ref HookContext ctx, ref HookArgs.ServerStateChange args)
 {
     if (args.ServerChangeState == ServerState.LOADED)
             regionManager.LoadRegions();
 }
开发者ID:emreuyls,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:5,代码来源:Regions.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Test2d.Record类代码示例发布时间:2022-05-26
下一篇:
C# Logging.ProgressLogger类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap