示例#1
0
 internal static void DropLootEnd
 (
     Vector2 pos,
     int width,
     int height,
     int type,
     int stack,
     bool noBroadcast,
     int prefixGiven,
     bool noGrabDelay,
     bool reverseLookup,
     global::Terraria.NPC npc
 ) => Hooks.Npc.PostDropLoot?.Invoke
 (
     npc,
     (int)pos.X,
     (int)pos.Y,
     width,
     height,
     type,
     stack,
     noBroadcast,
     prefixGiven,
     noGrabDelay,
     reverseLookup
 );
示例#2
0
 /// <summary>
 /// This method injected into the DropBossBags call, replacing the server NewItem calls.
 /// We check the result for -1 to cancel the function.
 /// </summary>
 internal static int BossBagItem
 (
     global::Terraria.NPC npc,
     int X,
     int Y,
     int Width,
     int Height,
     int Type,
     int Stack,
     bool noBroadcast,
     int pfix,
     bool noGrabDelay,
     bool reverseLookup
 )
 {
     //Allow altering of our local variables so the item can be changed etc
     if (Hooks.Npc.BossBagItem?.Invoke
         (
             npc,
             ref X,
             ref Y,
             ref Width,
             ref Height,
             ref Type,
             ref Stack,
             ref noBroadcast,
             ref pfix,
             ref noGrabDelay,
             ref reverseLookup
         ) == HookResult.Cancel)
     {
         return(-1);                    //This will be checked for in the patcher using a custom if block.
     }
     return(global::Terraria.Item.NewItem(X, Y, Width, Height, Type, Stack, noBroadcast, pfix, noGrabDelay, reverseLookup));
 }
示例#3
0
 internal static void DropLootEnd
 (
     int x,
     int y,
     int width,
     int height,
     int type,
     int stack,
     bool noBroadcast,
     int pfix,
     bool noGrabDelay,
     bool reverseLookup,
     global::Terraria.NPC npc
 ) => Hooks.Npc.PostDropLoot?.Invoke
 (
     npc,
     x,
     y,
     width,
     height,
     type,
     stack,
     noBroadcast,
     pfix,
     noGrabDelay,
     reverseLookup
 );
示例#4
0
        /// <summary>
        /// This method is injected into the start of the SetDefaults(string) method.
        /// The return value will dictate if normal vanilla code should continue to run.
        /// </summary>
        /// <returns>True to continue on to vanilla code, otherwise false</returns>
        internal static bool SetDefaultsByNameBegin(global::Terraria.NPC npc, ref string name)
        {
            var res = Hooks.Npc.PreSetDefaultsByName?.Invoke(npc, ref name);

            if (res.HasValue)
            {
                return(res.Value == HookResult.Continue);
            }
            return(true);
        }
示例#5
0
        /// <summary>
        /// This method is injected into the start of the SetDefaults(int,bool) method.
        /// The return value will dictate if normal vanilla code should continue to run.
        /// </summary>
        /// <returns>True to continue on to vanilla code, otherwise false</returns>
        internal static bool SetDefaultsByIdBegin(global::Terraria.NPC npc, ref int type, ref float scaleOverride)
        {
            var res = Hooks.Npc.PreSetDefaultsById?.Invoke(npc, ref type, ref scaleOverride);

            if (res.HasValue)
            {
                return(res.Value == HookResult.Continue);
            }
            return(true);
        }
示例#6
0
        /// <summary>
        /// This method is injected into the start of the NetDefaults method.
        /// The return value will dictate if normal vanilla code should continue to run.
        /// </summary>
        /// <returns>True to continue on to vanilla code, otherwise false</returns>
        internal static bool NetDefaultsBegin(global::Terraria.NPC npc, ref int type)
        {
            var res = Hooks.Npc.PreNetDefaults?.Invoke(npc, ref type);

            if (res.HasValue)
            {
                return(res.Value == HookResult.Continue);
            }
            return(true);
        }
示例#7
0
        /// <summary>
        /// This method is injected into the start of the AI() method.
        /// The return value will dictate if normal vanilla code should continue to run.
        /// </summary>
        /// <returns>True to continue on to vanilla code, otherwise false</returns>
        internal static bool AIBegin(global::Terraria.NPC npc)
        {
            var res = Hooks.Npc.PreAI?.Invoke(npc);

            if (res.HasValue)
            {
                return(res.Value == HookResult.Continue);
            }
            return(true);
        }
        /// <summary>
        /// This method is injected into the start of the SetDefaults(int,bool) method.
        /// The return value will dictate if normal vanilla code should continue to run.
        /// </summary>
        /// <returns>True to continue on to vanilla code, otherwise false</returns>
        internal static bool SetDefaultsByIdBegin(global::Terraria.NPC npc, ref int type, ref NPCSpawnParams spawnparams)
        {
            var res = Hooks.Npc.PreSetDefaultsById?.Invoke(npc, ref type, ref spawnparams);

            if (res.HasValue)
            {
                return(res.Value == HookResult.Continue);
            }
            return(true);
        }
示例#9
0
        internal static bool UpdateBegin(global::Terraria.NPC npc, ref int i)
        {
            var res = Hooks.Npc.PreUpdate?.Invoke(npc, ref i);

            if (res.HasValue)
            {
                return(res.Value == HookResult.Continue);
            }
            return(true);
        }
示例#10
0
        internal static bool PreTransform(global::Terraria.NPC npc, ref int newType)
        {
            var result = Hooks.Npc.PreTransform?.Invoke(npc, ref newType);

            if (result == HookResult.Cancel)
            {
                return(false);
            }

            return(true);
        }
示例#11
0
        public static bool DropLootBegin
        (
            ref int itemId,
            ref Vector2 pos,
            ref Vector2 randomBox,
            ref int Type,
            ref int Stack,
            ref bool noBroadcast,
            ref int prefixGiven,
            ref bool noGrabDelay,
            ref bool reverseLookup,
            global::Terraria.NPC npc
        )
        {
            int x      = (int)pos.X;
            int y      = (int)pos.Y;
            int width  = (int)randomBox.X;
            int height = (int)randomBox.Y;

            var result = DropLootBegin
                         (
                ref itemId,
                ref x,
                ref y,
                ref width,
                ref height,
                ref Type,
                ref Stack,
                ref noBroadcast,
                ref prefixGiven,
                ref noGrabDelay,
                ref reverseLookup,
                npc
                         );

            pos.X       = x;
            pos.Y       = y;
            randomBox.X = width;
            randomBox.Y = height;

            return(result);
        }
示例#12
0
        /// <summary>
        /// This method is injected into the StrikeNPC method along with an additional variable [cancelResult] which is returned
        /// if this method returns false.
        /// </summary>
        internal static bool Strike
        (
            global::Terraria.NPC npc,
            ref int cancelResult,
            ref int Damage,
            ref float knockBack,
            ref int hitDirection,
            ref bool crit,
            ref bool noEffect,
            ref bool fromNet
        )
        {
            var res = Hooks.Npc.Strike?.Invoke(npc, ref cancelResult, ref Damage, ref knockBack, ref hitDirection, ref crit, ref noEffect, ref fromNet);

            if (res.HasValue)
            {
                return(res.Value == HookResult.Continue);
            }
            return(true);
        }
示例#13
0
        internal static global::Terraria.NPC Create
        (
            ref int index,
            ref int x,
            ref int y,
            ref int type,
            ref int start,
            ref float ai0,
            ref float ai1,
            ref float ai2,
            ref float ai3,
            ref int target
        )
        {
            var npc = Hooks.Npc.Create?.Invoke
            (
                ref index,
                ref x,
                ref y,
                ref type,
                ref start,
                ref ai0,
                ref ai1,
                ref ai2,
                ref ai3,
                ref target
            );

            //This hook requires a return value or it will crash.
            if (npc == null)
            {
                System.Diagnostics.Debug.WriteLine($"Index: {index}");
                npc = new global::Terraria.NPC();

                global::Terraria.Main.npc[index] = npc;
                global::Terraria.Main.npc[index].SetDefaults(type, -1f);
            }

            return npc;
        }
示例#14
0
        internal static global::Terraria.NPC Create
        (
            ref int index,
            ref int x,
            ref int y,
            ref int type,
            ref int start,
            ref float ai0,
            ref float ai1,
            ref float ai2,
            ref float ai3,
            ref int target
        )
        {
            var npc = Hooks.Npc.Create?.Invoke
                      (
                ref index,
                ref x,
                ref y,
                ref type,
                ref start,
                ref ai0,
                ref ai1,
                ref ai2,
                ref ai3,
                ref target
                      );

            //This hook requires a return value or it will crash.
            if (npc == null)
            {
                System.Diagnostics.Debug.WriteLine($"Index: {index}");
                npc = new global::Terraria.NPC();

                global::Terraria.Main.npc[index] = npc;
                global::Terraria.Main.npc[index].SetDefaults(type, default);
            }

            return(npc);
        }
示例#15
0
        internal static bool DropLootBegin
        (
            ref int itemId,
            ref int x,
            ref int y,
            ref int width,
            ref int height,
            ref int type,
            ref int stack,
            ref bool noBroadcast,
            ref int pfix,
            ref bool noGrabDelay,
            ref bool reverseLookup,
            global::Terraria.NPC npc
        )
        {
            var res = Hooks.Npc.PreDropLoot?.Invoke
                      (
                npc,
                ref itemId,
                ref x,
                ref y,
                ref width,
                ref height,
                ref type,
                ref stack,
                ref noBroadcast,
                ref pfix,
                ref noGrabDelay,
                ref reverseLookup
                      );

            if (res.HasValue)
            {
                return(res.Value == HookResult.Continue);
            }
            return(true);
        }
示例#16
0
 internal static void DropLootEnd
 (
     Rectangle rectangle,
     int type,
     int stack,
     bool noBroadcast,
     int pfix,
     bool noGrabDelay,
     bool reverseLookup,
     global::Terraria.NPC npc
 ) => Hooks.Npc.PostDropLoot?.Invoke
 (
     npc,
     rectangle.X,
     rectangle.Y,
     rectangle.Width,
     rectangle.Height,
     type,
     stack,
     noBroadcast,
     pfix,
     noGrabDelay,
     reverseLookup
 );
示例#17
0
 internal static void DropLootEnd
 (
     Vector2 position,
     int type,
     int stack,
     bool noBroadcast,
     int pfix,
     bool noGrabDelay,
     bool reverseLookup,
     global::Terraria.NPC npc
 ) => Hooks.Npc.PostDropLoot?.Invoke
 (
     npc,
     (int)position.X,
     (int)position.Y,
     0,
     0,
     type,
     stack,
     noBroadcast,
     pfix,
     noGrabDelay,
     reverseLookup
 );
示例#18
0
 internal static void UpdateEnd(global::Terraria.NPC npc, int i) => Hooks.Npc.PostUpdate?.Invoke(npc, i);
示例#19
0
 /// <summary>
 /// This method is injected into the end of the SetDefaults(int,bool) method.
 /// </summary>
 internal static void SetDefaultsByIdEnd(global::Terraria.NPC npc, int type, NPCSpawnParams spawnparams) =>
 Hooks.Npc.PostSetDefaultsById?.Invoke(npc, type, spawnparams);
示例#20
0
 /// <summary>
 /// This method is injected into the end of the AI() method.
 /// </summary>
 internal static void AIEnd(global::Terraria.NPC npc) => Hooks.Npc.PostAI?.Invoke(npc);
示例#21
0
 /// <summary>
 /// This method is injected into the end of the NetDefaults method.
 /// </summary>
 internal static void NetDefaultsEnd(global::Terraria.NPC npc, ref int type, ref NPCSpawnParams spawnparams) =>
 Hooks.Npc.PostNetDefaults?.Invoke(npc, ref type, ref spawnparams);
示例#22
0
 /// <summary>
 /// This method is injected into the end of the NetDefaults method.
 /// </summary>
 internal static void NetDefaultsEnd(global::Terraria.NPC npc, ref int type) =>
 Hooks.Npc.PostNetDefaults?.Invoke(npc, ref type);
示例#23
0
 /// <summary>
 /// Called from Terraria.NPC.checkDead when an NPC has been killed
 /// </summary>
 /// <param name="npc"></param>
 internal static void Killed(global::Terraria.NPC npc) => Hooks.Npc.Killed?.Invoke(npc);
示例#24
0
 /// <summary>
 /// This method is injected into the end of the SetDefaults(int,bool) method.
 /// </summary>
 internal static void SetDefaultsByIdEnd(global::Terraria.NPC npc, int type, float scaleOverride) =>
 Hooks.Npc.PostSetDefaultsById?.Invoke(npc, type, scaleOverride);
示例#25
0
 /// <summary>
 /// This method is injected into the end of the SetDefaults(string) method.
 /// </summary>
 internal static void SetDefaultsByNameEnd(global::Terraria.NPC npc, ref string name) =>
 Hooks.Npc.PostSetDefaultsByName?.Invoke(npc, ref name);
示例#26
0
 internal static void PostTransform(global::Terraria.NPC npc) => Hooks.Npc.PostTransform?.Invoke(npc);