Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. using System.IO;
  2. using System.Collections.Generic;
  3. using Terraria;
  4. using Terraria.ID;
  5. using Terraria.ModLoader;
  6. using Terraria.World.Generation;
  7. using Microsoft.Xna.Framework;
  8. using Terraria.GameContent.Generation;
  9. using Terraria.Localization;
  10. using System;
  11. using Turrets;
  12. using System.Timers;
  13.  
  14. namespace Turrets
  15. {
  16. public class TurretWorld : ModWorld
  17. {
  18. private static Timer aTimer;
  19. public Mod m;
  20. public override void PostUpdate()
  21. {
  22. aTimer = new System.Timers.Timer();
  23. aTimer.Interval = 2000;
  24. aTimer.Elapsed += OnTimedEvent;
  25. aTimer.AutoReset = true;
  26. aTimer.Enabled = true;
  27. if (Main.time == 1 && Main.dayTime)
  28. {
  29. if (Main.netMode == 2)
  30. {
  31. NetMessage.BroadcastChatMessage(NetworkText.FromLiteral("Reloading all turrets.") , Color.Red);
  32. }
  33. else if (Main.netMode == 0)
  34. {
  35. Main.NewText("Reloading all turrets.", Color.Blue);
  36. }
  37. for (int chestIndex = 0; chestIndex < 1000; chestIndex++)
  38. {
  39. Chest chest = Main.chest[chestIndex];
  40. if (chest != null && Main.tile[chest.x, chest.y].type == mod.TileType("Turrettile"))
  41. {
  42. if (chest.item[0].type == ItemID.MusketBall)
  43. {
  44. chest.item[0].stack+=100;
  45. } else {
  46. chest.item[0].SetDefaults(ItemID.MusketBall);
  47. chest.item[0].stack+=100;
  48. }
  49. }
  50. }
  51. }
  52. }
  53. private void OnTimedEvent(Object source, System.Timers.ElapsedEventArgs e)
  54. {
  55. for (int chestIndex = 0; chestIndex < 1000; chestIndex++)
  56. {
  57. Chest chest = Main.chest[chestIndex];
  58. if (chest != null && Main.tile[chest.x, chest.y].type == mod.TileType("Turrettile"))
  59. {
  60. Projectile.NewProjectile(chest.x, chest.y, 5, 5, mod.ProjectileType("Bullet"), 5, 5);
  61. chest.item[0].stack-=1;
  62. }
  63. }
  64. }
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement