當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。