public static bool OnInvasionWarning() { var ctx = new HookContext(); var args = new HookArgs.InvasionWarning(); HookPoints.InvasionWarning.Invoke(ref ctx, ref args); return(ctx.Result == HookResult.DEFAULT); //Continue on }
void OnInvasionWarning(ref HookContext ctx, ref HookArgs.InvasionWarning args) { if (Main.invasionType == Core._assignedInvasionType && Core._invasion != null) { if (Main.invasionSize > 0) { string message = null; if (Main.invasionX < (double)Main.spawnTileX) { //West if (!Core._notfInbound) { Core._notfInbound = true; message = "An invasion is approaching from the west!"; } } else if (Main.invasionX > (double)Main.spawnTileX) { //East if (!Core._notfInbound) { Core._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); } }
/// <summary> /// The call from Terraria.Main.InvasionWarning /// </summary> public static bool OnInvasionWarning() { var ctx = new HookContext(); var args = new HookArgs.InvasionWarning(); HookPoints.InvasionWarning.Invoke(ref ctx, ref args); return ctx.Result == HookResult.DEFAULT; //Continue on }