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


C# Plugin.HookContext类代码示例

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


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

示例1: OnStateChange

 void OnStateChange(ref HookContext ctx, ref HookArgs.ServerStateChange args)
 {
     if (args.ServerChangeState == ServerState.Initialising)
     {
         ProgramLog.Plugin.Log("MSSQL connector is: " + (_connector == null ? "disabled" : "enabled"));
     }
 }
开发者ID:DeathCradle,项目名称:tdsm-mssql-connector,代码行数:7,代码来源:SqlPermissions.cs

示例2: OnDropBossBagBegin

        public static bool OnDropBossBagBegin(ref int itemId, int x, int y, int width, int height, int type, int stack = 1, bool noBroadcast = false, int prefix = 0, bool noGrabDelay = false, bool reverseLookup = false)
        {
            itemId = 0;

            var ctx = new HookContext();
            var args = new HookArgs.NpcDropBossBag()
            {
                State = MethodState.Begin,

                X = x,
                Y = y,
                Width = width,
                Height = height,
                Type = type,
                Stack = stack,
                NoBroadcast = noBroadcast,
                Prefix = prefix,
                NoGrabDelay = noGrabDelay,
                ReverseLookup = reverseLookup
            };

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

            if (ctx.ResultParam != null && ctx.ResultParam is int)
                itemId = (int)ctx.ResultParam;
            else if (ctx.Result == HookResult.IGNORE)
                itemId = -1;

            return ctx.Result == HookResult.DEFAULT; //If default then continue on to vanillacode
        }
开发者ID:hastinbe,项目名称:Open-Terraria-API,代码行数:30,代码来源:NPCCallback.cs

示例3: OnPlayerHurt

        //Death message
        //Player killed
        //Teleport
        /// <summary>
        /// Callde via vanilla code when a player has been hurt
        /// </summary>
        /// <param name="player">Player.</param>
        /// <param name="damage">Damage.</param>
        /// <param name="hitDirection">Hit direction.</param>
        /// <param name="pvp">If set to <c>true</c> pvp.</param>
        /// <param name="quiet">If set to <c>true</c> quiet.</param>
        /// <param name="deathText">Death text.</param>
        /// <param name="crit">If set to <c>true</c> crit.</param>
        /// <param name="cooldownCounter">Cooldown counter.</param>
        public static bool OnPlayerHurt(Terraria.Player player, int damage, int hitDirection, bool pvp = false, bool quiet = false, string deathText = " was slain...", bool crit = false, int cooldownCounter = -1)
        {
            var ctx = new HookContext()
            {
            //                Sender = player, This
            //                Player = player
            };
            var args = new HookArgs.PlayerHurt()
            {
                Victim = player,
                Damage = damage,
                HitDirection = hitDirection,
                Pvp = pvp,
                Quiet = quiet,
                Obituary = deathText,
                Critical = crit,
                CooldownCounter = cooldownCounter
            };

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

            if (ctx.CheckForKick()) return false;

            return ctx.Result == HookResult.DEFAULT;
        }
开发者ID:tylerjwatson,项目名称:Open-Terraria-API,代码行数:39,代码来源:PlayerCallback.cs

示例4: OnPlayerKilled

        /// <summary>
        /// Raised by vanilla code when a player has been killed
        /// </summary>
        /// <param name="player">Player.</param>
        /// <param name="dmg">Dmg.</param>
        /// <param name="hitDirection">Hit direction.</param>
        /// <param name="pvp">Pvp.</param>
        /// <param name="deathText">Death text.</param>
        public static bool OnPlayerKilled(Terraria.Player player, ref double dmg, ref int hitDirection, ref bool pvp, ref string deathText)
        {
            var ctx = new HookContext()
            {
                Sender = player,
                Player = player
            };
            var args = new HookArgs.PlayerKilled()
            {
                Damage = dmg,
                HitDirection = hitDirection,
                PvP = pvp,
                DeathText = deathText
            };

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

            if (ctx.CheckForKick()) return false;

            if (ctx.Result == HookResult.DEFAULT)
            {
                deathText = player.name + deathText;
                return true;
            }

            dmg = args.Damage;
            hitDirection = args.HitDirection;
            pvp = args.PvP;
            deathText = args.DeathText;
            return ctx.Result != HookResult.IGNORE;
        }
开发者ID:tylerjwatson,项目名称:Open-Terraria-API,代码行数:39,代码来源:PlayerCallback.cs

示例5: 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:tylerjwatson,项目名称:Open-Terraria-API,代码行数:26,代码来源:ClientConnection.cs

示例6: SetAuthentication

        /// <summary>
        /// Sets the authentication of this user
        /// </summary>
        /// <param name="auth">Auth.</param>
        /// <param name="by">By.</param>
        public static void SetAuthentication(this BasePlayer player, string auth, string by)
        {
            var ctx = new HookContext()
            {
                Player = (Terraria.Player)player,
                Connection = player.Connection.Socket
            };
            var changing = new TDSMHookArgs.PlayerAuthenticationChanging()
            {
                AuthenticatedAs = auth,
                AuthenticatedBy = by
            };
            TDSMHookPoints.PlayerAuthenticationChanging.Invoke(ref ctx, ref changing);
            if (ctx.Result != HookResult.DEFAULT)
                return;

            player.SetAuthenticatedAs(auth);
            player.SetAuthenticatedBy(by);

            ctx = new HookContext()
            {
                Player = (Terraria.Player)player,
                Connection = player.Connection.Socket
            };
            var changed = new TDSMHookArgs.PlayerAuthenticationChanged()
            {
                AuthenticatedAs = auth,
                AuthenticatedBy = by
            };

            TDSMHookPoints.PlayerAuthenticationChanged.Invoke(ref ctx, ref changed);
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:37,代码来源:BasePlayer.cs

示例7: CheckState

 /// <summary>
 /// Handles the connection state when receiving a packet
 /// </summary>
 public static void CheckState(ref HookContext ctx, ref HookArgs.CheckBufferState args)
 {
     if (Terraria.Netplay.Clients[args.BufferId].State == (int)ConnectionState.AwaitingUserPassword)
     {
         //Since this is a custom state, we accept it [true to kick the connection, false to accept]
         ctx.SetResult(HookResult.RECTIFY, true, false /* TODO validate packets */);
     }
 }
开发者ID:carriercomm,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:11,代码来源:PacketProcessor.cs

示例8: Read

        public bool Read(int bufferId, int start, int length)
        {
            var buffer = NetMessage.buffer[bufferId];
            byte kind = buffer.reader.ReadByte();
            int x = (int)buffer.reader.ReadInt16();
            int y = (int)buffer.reader.ReadInt16();
            if (!WorldGen.InWorld(x, y, 3)) return true;
            int direction = (buffer.reader.ReadByte() == 0) ? -1 : 1;

            var args = new TDSMHookArgs.BarrierStateChange()
            {
                X = x,
                Y = y,
                Direction = direction,
                Kind = kind
            };
            var ctx = new HookContext()
            {
                Sender = Main.player[bufferId],
                Player = Main.player[bufferId]
            };

            TDSMHookPoints.BarrierStateChange.Invoke(ref ctx, ref args);

            if (ctx.Result == HookResult.DEFAULT)
            {
                if (kind == 0) WorldGen.OpenDoor(x, y, direction);
                else if (kind == 1) WorldGen.CloseDoor(x, y, true);
                else if (kind == 2) WorldGen.ShiftTrapdoor(x, y, direction == 1, 1);
                else if (kind == 3) WorldGen.ShiftTrapdoor(x, y, direction == 1, 0);
                else if (kind == 4) WorldGen.ShiftTallGate(x, y, false);
                else if (kind == 5) WorldGen.ShiftTallGate(x, y, true);

                if (Main.netMode == 2)
                    NetMessage.SendData((int)Packet.BARRIER_STATE_CHANGE, -1, bufferId, "", (int)kind, (float)x, (float)y, (float)((direction == 1) ? 1 : 0));
            }
            else if (ctx.Result == HookResult.RECTIFY)
            {
                if (Main.netMode == 2)
                {
                    //Teleport
                    ctx.Player.Teleport(args.Position);

                    //I would think to send the real door state
                    if (kind == 0) kind = 1;
                    else if (kind == 1) kind = 0;
                    else if (kind == 2) kind = 3;
                    else if (kind == 3) kind = 2;
                    else if (kind == 4) kind = 5;
                    else if (kind == 5) kind = 4;

                    if (Main.netMode == 2)
                        NetMessage.SendData((int)Packet.BARRIER_STATE_CHANGE, -1, bufferId, "", (int)kind, (float)x, (float)y, (float)((direction == 1) ? 1 : 0));
                }
            }

            return true;
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:58,代码来源:BarrierStateChange.cs

示例9: Read

        public bool Read(int bufferId, int start, int length)
        {
            var buffer = NetMessage.buffer[bufferId];
            var player = Main.player[bufferId];

            if (Main.netMode != 2)
                return true;

            int x = (int)buffer.reader.ReadInt16();
            int y = (int)buffer.reader.ReadInt16();

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

            int chestIndex = Chest.FindChest(x, y);
            if (chestIndex <= -1 || Chest.UsingChest(chestIndex) != -1)
                return true;

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

            var args = new TDSMHookArgs.ChestOpenReceived
            {
                X = x,
                Y = y,
                ChestIndex = chestIndex
            };

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

            if (ctx.CheckForKick())
                return true;

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

            if (ctx.Result == HookResult.DEFAULT && chestIndex > -1)
            {
                for (int i = 0; i < 40; i++)
                {
                    NetMessage.SendData(32, bufferId, -1, "", chestIndex, (float)i, 0, 0, 0, 0, 0);
                }
                NetMessage.SendData(33, bufferId, -1, "", chestIndex, 0, 0, 0, 0, 0, 0);
                Main.player[bufferId].chest = chestIndex;
                if (Main.myPlayer == bufferId)
                {
                    Main.recBigList = false;
                }

                NetMessage.SendData(80, -1, bufferId, "", bufferId, (float)chestIndex, 0, 0, 0, 0, 0);
            }

            return true;
        }
开发者ID:DeathCradle,项目名称:Terraria-s-Dedicated-Server-Mod,代码行数:58,代码来源:ChestOpen.cs

示例10: OnStartHardMode

        public static bool OnStartHardMode()
        {
            var ctx = new HookContext();
            var args = new HookArgs.StartHardMode();

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

            return ctx.Result == HookResult.DEFAULT;
        }
开发者ID:hastinbe,项目名称:Open-Terraria-API,代码行数:9,代码来源:WorldGenCallback.cs

示例11: OnChat

        void OnChat(ref HookContext ctx, ref TDSMHookArgs.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);

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

示例12: OnAddBanEnd

        public static void OnAddBanEnd(int player)
        {
            var ctx = new HookContext();
            var args = new HookArgs.AddBan()
            {
                State = MethodState.End,
                Slot = player
            };

            HookPoints.AddBan.Invoke(ref ctx, ref args);
        }
开发者ID:hastinbe,项目名称:Open-Terraria-API,代码行数:11,代码来源:NetplayCallback.cs

示例13: OnAIEnd

        public static void OnAIEnd(Terraria.Projectile projectle)
        {
            var ctx = new HookContext();
            var args = new HookArgs.ProjectileAI()
            {
                Projectile = projectle,

                State = MethodState.End
            };
            HookPoints.ProjectileAI.Invoke(ref ctx, ref args);
        }
开发者ID:hastinbe,项目名称:Open-Terraria-API,代码行数:11,代码来源:ProjectileCallback.cs

示例14: OnWorldClearEnd

        public static void OnWorldClearEnd()
        {
            GC.Collect();

            var ctx = new HookContext();
            var args = new HookArgs.WorldClear()
            {
                State = MethodState.End
            };

            HookPoints.WorldClear.Invoke(ref ctx, ref args);
        }
开发者ID:hastinbe,项目名称:Open-Terraria-API,代码行数:12,代码来源:WorldGenCallback.cs

示例15: OnSetDefaultsEnd

        public static void OnSetDefaultsEnd(Terraria.Projectile projectle, int type)
        {
            var ctx = new HookContext();
            var args = new HookArgs.ProjectileSetDefaults()
            {
                Projectile = projectle,
                Type = type,

                State = MethodState.End
            };
            HookPoints.ProjectileSetDefaults.Invoke(ref ctx, ref args);
        }
开发者ID:hastinbe,项目名称:Open-Terraria-API,代码行数:12,代码来源:ProjectileCallback.cs


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