void OnInvasionNPCSpawn(ref HookContext ctx, ref HookArgs.InvasionNPCSpawn args) { if (Main.rand == null) { Main.rand = new Random(); } if (Main.invasionType == _assignedInvasionType && _invasion != null) { lock (_invasion) { if (_invasion.Count > 0) { var npc = _invasion.Random(); if (npc.Key != 0 && Main.rand.Next(Main.rand.Next(9)) == 0) { var id = NPC.NewNPC(args.X, args.Y, npc.Key); if (npc.Value < 0) { Terraria.Main.npc[id].netDefaults(npc.Value); } } } } // ctx.SetResult(HookResult.ERASE); } }
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); }
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); // return ctx.Result == HookResult.DEFAULT; }
void OnInvasionNPCSpawn(ref HookContext ctx, ref HookArgs.InvasionNPCSpawn args) { if (Main.invasionType == _assignedInvasionType && _invasion != null) { int npcId = 0; lock (_invasion) { if (_invasion.Count > 0) { var ix = Main.rand.Next(0, _invasion.Count - 1); npcId = _invasion[ix]; } } if (npcId != 0 && Main.rand.Next(Main.rand.Next(9)) == 0) { NPC.NewNPC(args.X, args.Y, npcId); } } }