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


C# Plugin.HookContext类代码示例

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


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

示例1: LeftHook

 void LeftHook(ref HookContext ctx, ref HookArgs.PlayerLeftGame args)
 {
     // If player has a last command stored, remove it now.
     if ( history.ContainsKey(ctx.Sender.SenderName) ) {
         history.Remove(ctx.Sender.SenderName);
     }
 }
开发者ID:D1G1T4L3CH0,项目名称:TDSM-Plugin_LastCommand,代码行数:7,代码来源:lcmd.cs

示例2: ClientConnection

        public ClientConnection(Socket sock)
            : base(sock)
        {
            if (SlotId == 0)
                SlotId = -1;

            var remoteEndPoint = (IPEndPoint)sock.RemoteEndPoint;
            _remoteAddress = new TcpAddress(remoteEndPoint.Address, remoteEndPoint.Port);

            sock.LingerState = new LingerOption(true, 10);
            sock.NoDelay = true;

            var ctx = new HookContext
            {
                Connection = this
            };

            var args = new HookArgs.NewConnection();

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

            if (ctx.CheckForKick())
                return;

            _isReceiving = true; //The connection was established, so we can begin reading
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:26,代码来源:ClientConnection.cs

示例3: SendData

 public static bool SendData(int msgType, int remoteClient = -1, int ignoreClient = -1, string text = "", int number = 0, float number2 = 0f, float number3 = 0f, float number4 = 0f, int number5 = 0)
 {
     #if Full_API
     var ctx = new HookContext()
     {
         Sender = HookContext.ConsoleSender
     };
     var args = new HookArgs.SendNetData()
     {
         MsgType = msgType,
         RemoteClient = remoteClient,
         IgnoreClient = ignoreClient,
         Text = text,
         Number = number,
         Number2 = number2,
         Number3 = number3,
         Number4 = number4,
         Number5 = number5
     };
     HookPoints.SendNetData.Invoke(ref ctx, ref args);
     return ctx.Result == HookResult.DEFAULT;
     #else
     return false;
     #endif
 }
开发者ID:skylord123,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:25,代码来源:NetMessageCallback.cs

示例4: SetAuthentication

        public void SetAuthentication(string auth, string by)
        {
            #if Full_API
            var ctx = new Plugin.HookContext()
            {
                Player = this as Terraria.Player,
                Connection = this.Connection.Socket
            };
            var changing = new Plugin.HookArgs.PlayerAuthenticationChanging()
            {
                AuthenticatedAs = auth,
                AuthenticatedBy = by
            };

            Plugin.HookPoints.PlayerAuthenticationChanging.Invoke(ref ctx, ref changing);
            if (ctx.Result != Plugin.HookResult.DEFAULT)
                return;

            this.AuthenticatedAs = auth;
            this.AuthenticatedBy = by;

            ctx = new Plugin.HookContext()
            {
                Player = this as Terraria.Player,
                Connection = this.Connection.Socket
            };
            var changed = new Plugin.HookArgs.PlayerAuthenticationChanged()
            {
                AuthenticatedAs = this.AuthenticatedAs,
                AuthenticatedBy = this.AuthenticatedBy
            };

            Plugin.HookPoints.PlayerAuthenticationChanged.Invoke(ref ctx, ref changed);
            #endif
        }
开发者ID:skylord123,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:35,代码来源:BasePlayer.cs

示例5: OnProgramStarted

        public static bool OnProgramStarted(string[] cmd)
        {
            System.Threading.Thread.CurrentThread.Name = "Run";
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            ProgramStart();
            #pragma warning disable 0162
            if (!Globals.FullAPIDefined)
            {
                Console.WriteLine("Your TDSM.API.dll is incorrect, and does not expose all methods.");
                return false;
            }
            #pragma warning restore 0162

            var ctx = new HookContext()
            {
                Sender = HookContext.ConsoleSender
            };
            var args = new HookArgs.ProgramStart()
            {
                Arguments = cmd
            };
            HookPoints.ProgramStart.Invoke(ref ctx, ref args);

            return ctx.Result == HookResult.DEFAULT;
        }
开发者ID:apemanzilla,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:26,代码来源:MainCallback.cs

示例6: OnStateChange

 void OnStateChange(ref HookContext ctx, ref HookArgs.ServerStateChange args)
 {
     if (args.ServerChangeState == TDSM.API.ServerState.Initialising)
     {
         ProgramLog.Plugin.Log("SQLite connector is: " + (_connector == null ? "disabled" : "enabled"));
     }
 }
开发者ID:apemanzilla,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:7,代码来源:Plugin.cs

示例7: OnGreetPlayer

        public static bool OnGreetPlayer(int playerId)
        {
            #if Full_API
            var player = Main.player[playerId];

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

            var args = new HookArgs.PlayerPreGreeting
            {
                Slot = playerId,
                Motd = String.IsNullOrEmpty(Main.motd) ? (Lang.mp[18] + " " + Main.worldName) : Main.motd,
                MotdColour = new Microsoft.Xna.Framework.Color(255, 240, 20)
            };

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

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

            if (ctx.Result == HookResult.DEFAULT)
            {
                player.SendMessage(args.Motd, 255, args.MotdColour.R, args.MotdColour.G, args.MotdColour.B);

                string list = "";
                for (int i = 0; i < 255; i++)
                {
                    if (Main.player[i].active)
                    {
                        if (list == "")
                            list += Main.player[i].name;
                        else
                            list = list + ", " + Main.player[i].Name;
                    }
                }

                player.SendMessage("Current players: " + list + ".", 255, 255, 240, 20);
            }

            ProgramLog.Users.Log("{0} @ {1}: ENTER {2}", Netplay.Clients[playerId].Socket.GetRemoteAddress(), playerId, player.name);

            var args2 = new HookArgs.PlayerEnteredGame
            {
                Slot = playerId
            };

            ctx.SetResult(HookResult.DEFAULT, false);
            HookPoints.PlayerEnteredGame.Invoke(ref ctx, ref args2);
            ctx.CheckForKick();
            #endif

            return false; //We implemented our own, so do not continue on with vanilla
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:59,代码来源:VanillaHooks.cs

示例8: OnStateChange

 void OnStateChange(ref HookContext ctx, ref HookArgs.ServerStateChange args)
 {
     if (args.ServerChangeState == TDSM.API.ServerState.Initialising)
     {
         //Data connectors must have loaded by now
         //Get TDSM to swap the current permission handler to our own
         TDSM.API.Permissions.PermissionsManager.SetHandler(_instance);
     }
 }
开发者ID:skylord123,项目名称:TDSM_SQLPermissions,代码行数:9,代码来源:SQLPermissions.cs

示例9: OnNPCKilled

        public static void OnNPCKilled(Terraria.NPC npc)
        {
            var ctx = new HookContext();
            var args = new HookArgs.NPCKilled()
            {
                Type = npc.type,
                NetId = npc.netID
            };

            HookPoints.NPCKilled.Invoke(ref ctx, ref args);
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:11,代码来源:NPCCallback.cs

示例10: OnInvasionNPCSpawn

        public static void OnInvasionNPCSpawn(int x, int y)
        {
            var ctx = new HookContext();
            var args = new HookArgs.InvasionNPCSpawn()
            {
                X = x,
                Y = y
            };

            HookPoints.InvasionNPCSpawn.Invoke(ref ctx, ref args);
        }
开发者ID:skylord123,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:11,代码来源:NPCCallback.cs

示例11: CommmandHook

 void CommmandHook(ref HookContext ctx, ref HookArgs.Command args)
 {
     // If the command issued is not !...
     if ( args.Prefix != "!" ) {
         string WhoCalled = ctx.Sender.SenderName; // get the name of the sender
         // If there is a command saved for the sender already...
         if ( history.ContainsKey( WhoCalled ) ) {
             history[WhoCalled] = args.Prefix + " " + args.ArgumentString; // Replace the sender's last command.
         } else {
             history.Add( WhoCalled, args.Prefix + " " + args.ArgumentString ); // Record the sender's command for the first time.
         }
     }
 }
开发者ID:D1G1T4L3CH0,项目名称:TDSM-Plugin_LastCommand,代码行数:13,代码来源:lcmd.cs

示例12: CanSpawnNPC

        public static bool CanSpawnNPC(int x, int y, int type, int start = 0)
        {
            var ctx = new HookContext();
            var args = new HookArgs.NPCSpawn()
            {
                X = x,
                Y = y,
                Type = type,
                Start = start
            };

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

            return ctx.Result == HookResult.DEFAULT;
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:15,代码来源:NPCCallback.cs

示例13: Initialise

 public static void Initialise()
 {
     #if Full_API
     if (Terraria.Main.dedServ)
     {
         var ctx = new HookContext()
         {
             Sender = HookContext.ConsoleSender
         };
         var args = new HookArgs.ServerStateChange()
         {
             ServerChangeState = ServerState.Initialising
         };
         HookPoints.ServerStateChange.Invoke(ref ctx, ref args);
     }
     #endif
 }
开发者ID:apemanzilla,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:17,代码来源:MainCallback.cs

示例14: OnReadConfig

        void OnReadConfig(ref HookContext ctx, ref HookArgs.ConfigurationLine args)
        {
            switch (args.Key)
            {
                case "sqlite":
                    if (_connector == null)
                    {
                        var cn = new SQLiteConnector(args.Value);

                        cn.Open();

                        Storage.SetConnector(cn);

                        _connector = cn;
                    }
                    break;
            }
        }
开发者ID:apemanzilla,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:18,代码来源:Plugin.cs

示例15: OnReadConfig

        void OnReadConfig(ref HookContext ctx, ref HookArgs.ConfigurationLine args)
        {
            switch (args.Key)
            {
                case "mysql":
                    if (!Storage.IsAvailable)
                    {
                        MySQLConnector cn = null;

                        try
                        {
                            cn = new MySQLConnector(args.Value);
                            cn.Open();
                        }
                        catch (Exception e)
                        {
                            ProgramLog.Error.Log("Exception connecting to MySQL database: {0}", e);
                            return;
                        }
                        Storage.SetConnector(_connector = cn);
                    }
                    break;
            }
        }
开发者ID:CJKay,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:24,代码来源:SqlPermissions.cs


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