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


C# HookContext.SetResult方法代码示例

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


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

示例1: 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

示例2: OnNetMessageReceived

        //        [Hook]
        void OnNetMessageReceived(ref HookContext ctx, ref HookArgs.ReceiveNetMessage args)
        {
            if (Terraria.Main.ServerSideCharacter)
            {
                switch ((Packet)args.PacketId)
                {
                    case Packet.INVENTORY_DATA:
                        if (!AllowSSCGuestInfo && !ctx.Player.IsAuthenticated)
                            ctx.SetResult(HookResult.IGNORE);
                        break;

                    case Packet.PLAYER_MANA_UPDATE:
                        if (!AllowSSCGuestInfo && !ctx.Player.IsAuthenticated)
                            ctx.SetResult(HookResult.IGNORE);
                        break;

                    case Packet.PLAYER_HEALTH_UPDATE:
                        if (!AllowSSCGuestInfo && !ctx.Player.IsAuthenticated)
                            ctx.SetResult(HookResult.IGNORE);
                        break;
                }
            }
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:24,代码来源:Entry.cs

示例3: OnGreetPlayer

        void OnGreetPlayer(ref HookContext ctx, ref HookArgs.PlayerPreGreeting args)
        {
            ctx.SetResult(HookResult.IGNORE);
            var lines = args.Motd.Split(new string[]{ "\\0" }, StringSplitOptions.None);
            foreach (var line in lines)
                ctx.Player.SendMessage(line, 255, 0, 0, 255);

            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;
                }
            }

            ctx.Player.SendMessage("Current players: " + list + ".", 255, 255, 240, 20);
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:21,代码来源:Entry.cs

示例4: OnChat

        void OnChat(ref HookContext ctx, ref HookArgs.PlayerChat args)
        {
            if (args.Message.Length > 0 && args.Message.Substring(0, 1).Equals("/"))
            {
                ProgramLog.Log(ctx.Player.Name + " sent command: " + args.Message);
                ctx.SetResult(HookResult.IGNORE);

                UserInput.CommandParser.ParsePlayerCommand(ctx.Player, args.Message);
            }
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:10,代码来源:Entry.cs

示例5: OnDefaultServerStart

        void OnDefaultServerStart(ref HookContext ctx, ref HookArgs.StartDefaultServer args)
        {
            if (RunServerCore)
            {
                ProgramLog.Log("Starting TDSM's slot server...");
                ctx.SetResult(HookResult.IGNORE);

                ServerCore.Server.StartServer();
            } else
                ProgramLog.Log("Vanilla only specified, continuing on with Re-Logic code...");
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:11,代码来源:Entry.cs

示例6: OnStartCommandProcessing

        void OnStartCommandProcessing(ref HookContext ctx, ref HookArgs.StartCommandProcessing args)
        {
            ctx.SetResult(HookResult.IGNORE);

            (new TDSM.API.Misc.ProgramThread("Command", ListenForCommands)).Start();
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:6,代码来源:Entry.cs

示例7: OnServerStateChange

        void OnServerStateChange(ref HookContext ctx, ref HookArgs.ServerStateChange args)
        {
            ProgramLog.Log("Server state changed to: " + args.ServerChangeState.ToString());

            if (args.ServerChangeState == ServerState.Initialising)
            {
                if (!String.IsNullOrEmpty(RConBindAddress))
                {
                    ProgramLog.Log("Starting RCON Server");
                    RemoteConsole.RConServer.Start(Path.Combine(Globals.DataPath, "rcon_logins.properties"));
                }

                if (Terraria.Main.ServerSideCharacter)
                {
                    CharacterManager.Init();
                }
            }
            if (args.ServerChangeState == ServerState.Stopping)
            {
                RemoteConsole.RConServer.Stop();
            }
            if (args.ServerChangeState == ServerState.Starting)
            {
                Heartbeat.Begin(CoreBuild);
            }

            //if (args.ServerChangeState == ServerState.Initialising)
            #if TDSMServer
            if (!Server.IsInitialised)
            {
                Server.Init();

                if (!String.IsNullOrEmpty(RConBindAddress))
                {
                    ProgramLog.Log("Starting RCON Server");
                    RemoteConsole.RConServer.Start(Path.Combine(Globals.DataPath, "rcon_logins.properties"));
                }

                if (!String.IsNullOrEmpty(_webServerAddress))
                {
                    ProgramLog.Log("Starting Web Server");
                    WebInterface.WebServer.Begin(_webServerAddress, _webServerProvider);

                    AddCommand("webauth")
                        .WithAccessLevel(AccessLevel.OP)
                        .Calls(WebInterface.WebServer.WebAuthCommand);
                }
            }

            if (args.ServerChangeState == ServerState.Stopping)
            {
                RemoteConsole.RConServer.Stop();
                WebInterface.WebServer.End();
                //if (properties != null && File.Exists(properties.PIDFile.Trim()))
                //File.Delete(properties.PIDFile.Trim());
            }

            ctx.SetResult(HookResult.IGNORE); //Don't continue on with vanilla code
            #endif
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:60,代码来源:Entry.cs

示例8: OnNPCSpawned

 void OnNPCSpawned(ref HookContext ctx, ref HookArgs.NPCSpawn args)
 {
     if (StopNPCSpawning)
         ctx.SetResult(HookResult.IGNORE);
 }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:5,代码来源:Entry.cs

示例9: OnNetMessageSend

        void OnNetMessageSend(ref HookContext ctx, ref HookArgs.SendNetMessage args)
        {
            if (Terraria.Main.ServerSideCharacter)
            {
                switch ((Packet)args.MsgType)
                {
                    case Packet.WORLD_DATA:
                        ctx.SetResult(HookResult.IGNORE);

                        var writer = NetMessage.buffer[args.BufferId].writer;

                        writer.Write((int)Main.time);

                        byte value;

                        value = 0;
                        if (Main.dayTime) value += 1;
                        if (Main.bloodMoon) value += 2;
                        if (Main.bloodMoon) value += 4;
                        writer.Write(value);

                        writer.Write((byte)Main.moonPhase);
                        writer.Write((short)Main.maxTilesX);
                        writer.Write((short)Main.maxTilesY);
                        writer.Write((short)Main.spawnTileX);
                        writer.Write((short)Main.spawnTileY);
                        writer.Write((short)Main.worldSurface);
                        writer.Write((short)Main.rockLayer);
                        writer.Write(Main.worldID);
                        writer.Write(Main.worldName);
                        writer.Write((byte)Main.moonType);
                        writer.Write((byte)WorldGen.treeBG);
                        writer.Write((byte)WorldGen.corruptBG);
                        writer.Write((byte)WorldGen.jungleBG);
                        writer.Write((byte)WorldGen.snowBG);
                        writer.Write((byte)WorldGen.hallowBG);
                        writer.Write((byte)WorldGen.crimsonBG);
                        writer.Write((byte)WorldGen.desertBG);
                        writer.Write((byte)WorldGen.oceanBG);
                        writer.Write((byte)Main.iceBackStyle);
                        writer.Write((byte)Main.jungleBackStyle);
                        writer.Write((byte)Main.hellBackStyle);
                        writer.Write(Main.windSpeedSet);
                        writer.Write((byte)Main.numClouds);

                        for (int k = 0; k < 3; k++) writer.Write(Main.treeX[k]);
                        for (int l = 0; l < 4; l++) writer.Write((byte)Main.treeStyle[l]);
                        for (int m = 0; m < 3; m++) writer.Write(Main.caveBackX[m]);
                        for (int n = 0; n < 4; n++) writer.Write((byte)Main.caveBackStyle[n]);

                        if (!Main.raining) Main.maxRaining = 0;
                        writer.Write(Main.maxRaining);

                        value = 0;
                        if (WorldGen.shadowOrbSmashed) value += 1;
                        if (NPC.downedBoss1) value += 2;
                        if (NPC.downedBoss2) value += 4;
                        if (NPC.downedBoss3) value += 8;
                        if (Main.hardMode) value += 16;
                        if (NPC.downedClown) value += 32;
                        if (Main.ServerSideCharacter) value += 64;
                        if (NPC.downedPlantBoss) value += 128;
                        writer.Write(value);

                        value = 0;
                        if (NPC.downedMechBoss1) value += 1;
                        if (NPC.downedMechBoss2) value += 2;
                        if (NPC.downedMechBoss3) value += 4;
                        if (NPC.downedMechBossAny) value += 8;
                        if (Main.cloudBGActive >= 1) value += 16;
                        if (WorldGen.crimson) value += 32;
                        if (Main.pumpkinMoon) value += 64;
                        if (Main.snowMoon) value += 128;
                        writer.Write(value);

                        value = 0;
                        if (Main.expertMode) value += 1;
                        if (Main.fastForwardTime) value += 2;
                        if (Main.slimeRain) value += 4;
                        if (NPC.downedSlimeKing) value += 8;
                        if (NPC.downedQueenBee) value += 16;
                        if (NPC.downedFishron) value += 32;
                        if (NPC.downedMartians) value += 64;
                        if (NPC.downedAncientCultist) value += 128;
                        writer.Write(value);

                        value = 0;
                        if (NPC.downedMoonlord) value += 1;
                        if (NPC.downedHalloweenKing) value += 2;
                        if (NPC.downedHalloweenTree) value += 4;
                        if (NPC.downedChristmasIceQueen) value += 8;
                        if (NPC.downedChristmasSantank) value += 16;
                        if (NPC.downedChristmasTree) value += 32;
                        if (NPC.downedGolemBoss) value += 64;
                        writer.Write(value);

                        writer.Write((sbyte)Main.invasionType);

                        if (SocialAPI.Network != null)
                            writer.Write(SocialAPI.Network.GetLobbyId());
//.........这里部分代码省略.........
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:101,代码来源:Entry.cs

示例10: OnPlayerEntering

        public static void OnPlayerEntering(Player player)
        {
            #if Full_API
            var ctx = new HookContext
            {
                Player = player,
                Sender = player
            };

            var args = new HookArgs.PlayerEnteringGame
            {
                Slot = player.whoAmI
            };

            ctx.SetResult(HookResult.DEFAULT, false);
            HookPoints.PlayerEnteringGame.Invoke(ref ctx, ref args);
            if (!ctx.CheckForKick())
            {
                NetMessage.SendData(4, -1, player.whoAmI, player.name, player.whoAmI, 0f, 0f, 0f, 0, 0, 0);
            }
            #endif
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:22,代码来源:VanillaHooks.cs

示例11: OnPlayerLeave

        public static void OnPlayerLeave(Player player)
        {
            #if Full_API
            var ctx = new HookContext
            {
                Player = player,
                Sender = player
            };

            var args = new HookArgs.PlayerLeftGame
            {
                Slot = player.whoAmI
            };

            ctx.SetResult(HookResult.DEFAULT, false);
            HookPoints.PlayerLeftGame.Invoke(ref ctx, ref args);
            #endif
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:18,代码来源:VanillaHooks.cs

示例12: OnInvasionWarning

        void OnInvasionWarning(ref HookContext ctx, ref HookArgs.InvasionWarning args)
        {
            if (Main.invasionType == _assignedInvasionType && _invasion != null)
            {
                if (Main.invasionSize > 0)
                {
                    string message = null;
                    if (Main.invasionX < (double)Main.spawnTileX)
                    {
                        //West
                        if (!_notfInbound)
                        {
                            _notfInbound = true;
                            message = "An invasion is approaching from the west!";
                        }
                    }
                    else if (Main.invasionX > (double)Main.spawnTileX)
                    {
                        //East
                        if (!_notfInbound)
                        {
                            _notfInbound = true;
                            message = "An invasion is approaching from the east!";
                        }
                    }
                    else
                    {
                        //Arrived
                        message = "The invasion has arrived!";
                    }

                    if (null != message)
                        NetMessage.SendData(25, -1, -1, message, 255, 175f, 75f, 255f);
                }

                ctx.SetResult(HookResult.IGNORE);
            }
        }
开发者ID:Narkun,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:38,代码来源:Invasion.cs


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