Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.IO;
- using System.Collections.Generic;
- using Terraria;
- using Terraria.ID;
- using Terraria.ModLoader;
- using Terraria.World.Generation;
- using Microsoft.Xna.Framework;
- using Terraria.GameContent.Generation;
- using Terraria.Localization;
- using System;
- using Turrets;
- using System.Timers;
- namespace Turrets
- {
- public class TurretWorld : ModWorld
- {
- private static Timer aTimer;
- public Mod m;
- public override void PostUpdate()
- {
- aTimer = new System.Timers.Timer();
- aTimer.Interval = 2000;
- aTimer.Elapsed += OnTimedEvent;
- aTimer.AutoReset = true;
- aTimer.Enabled = true;
- if (Main.time == 1 && Main.dayTime)
- {
- if (Main.netMode == 2)
- {
- NetMessage.BroadcastChatMessage(NetworkText.FromLiteral("Reloading all turrets.") , Color.Red);
- }
- else if (Main.netMode == 0)
- {
- Main.NewText("Reloading all turrets.", Color.Blue);
- }
- for (int chestIndex = 0; chestIndex < 1000; chestIndex++)
- {
- Chest chest = Main.chest[chestIndex];
- if (chest != null && Main.tile[chest.x, chest.y].type == mod.TileType("Turrettile"))
- {
- if (chest.item[0].type == ItemID.MusketBall)
- {
- chest.item[0].stack+=100;
- } else {
- chest.item[0].SetDefaults(ItemID.MusketBall);
- chest.item[0].stack+=100;
- }
- }
- }
- }
- }
- private void OnTimedEvent(Object source, System.Timers.ElapsedEventArgs e)
- {
- for (int chestIndex = 0; chestIndex < 1000; chestIndex++)
- {
- Chest chest = Main.chest[chestIndex];
- if (chest != null && Main.tile[chest.x, chest.y].type == mod.TileType("Turrettile"))
- {
- Projectile.NewProjectile(chest.x, chest.y, 5, 5, mod.ProjectileType("Bullet"), 5, 5);
- chest.item[0].stack-=1;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement