-
Notifications
You must be signed in to change notification settings - Fork 0
/
Update.cs
66 lines (62 loc) · 1.59 KB
/
Update.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using Terraria;
using Terraria.ModLoader;
using Microsoft.Xna.Framework;
using Terraria.DataStructures;
using Techarria.Content.Items.Materials.Molten;
using Techarria.Content.Entities;
using System.Collections.Generic;
using Techarria.Structures;
using Techarria.Content.Tiles;
using Techarria.Content.Dusts;
namespace Techarria
{
internal class Update : ModSystem
{
int CheckStructuresTimer = 0;
public void DestroyChestsWithMoltenItems() {
bool logged = false;
foreach (Chest chest in Main.chest) {
if (chest != null) {
bool hasMolten = false;
foreach (Item item in chest.item) {
if (item.ModItem is MoltenBlob) {
hasMolten = true;
break;
}
}
if (hasMolten) {
for (int i = 0; i < chest.item.Length; i++) {
Item item = chest.item[i];
if (!logged) {
logged = true;
}
Item.NewItem(new EntitySource_TileBreak(chest.x, chest.y), new Rectangle(chest.x * 16, chest.y * 16, 32, 32), item);
chest.item[i] = null;
}
WorldGen.KillTile(chest.x, chest.y, noItem: true);
}
}
}
}
public void UpdateDrones() {
Drone[] tempDrones = Drone.drones.ToArray();
foreach (Drone drone in tempDrones) {
drone.Update();
}
}
public override void PostUpdateEverything()
{
DestroyChestsWithMoltenItems();
UpdateDrones();
CheckStructuresTimer++;
if (CheckStructuresTimer > 60) {
for (int i = 0; i < Greenhouse.greenhouses.Count;) {
if (Greenhouse.greenhouses[i].CheckStructure()) {
i++;
}
}
CheckStructuresTimer = 0;
}
}
}
}