-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMachData.cs
More file actions
222 lines (200 loc) · 7.05 KB
/
MachData.cs
File metadata and controls
222 lines (200 loc) · 7.05 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
using Microsoft.Xna.Framework;
using Newtonsoft.Json;
using Terraria;
using TShockAPI;
using static FishMach.Plugin;
namespace FishMach;
#region 机器数据
// 动画请求
public enum AnimType { Move, Sparkle, Transfer }
public class AnimReq
{
public AnimType Type;
public Item item; // 需要转移的物品
public Vector2 from; // 动画起点
public Point toPos; // 目标箱子坐标(用于动画和定位)
public int chestIdx; // 目标箱子索引
public bool skipFake; // 是否跳过假鱼
public MachData data;
}
public class CustomState
{
[JsonProperty("名称")]
public string ItemName { get; set; } = string.Empty;
[JsonProperty("槽位")]
public int Slot { get; set; }
[JsonProperty("时间")]
public DateTime Expiry { get; set; }
[JsonProperty("加成")]
public int Bonus { get; set; }
public CustomState(int slot, DateTime expiry, int bonus,string name)
{
Slot = slot;
Expiry = expiry;
Bonus = bonus;
ItemName = name;
}
}
public class MachData
{
[JsonProperty("世界ID")]
public string WorldId { get; set; } = "";
[JsonProperty("所有者")]
public string Owner { get; set; } = "";
[JsonProperty("区域名")]
public string RegName { get; set; } = "";
[JsonProperty("坐标")]
public Point Pos { get; set; } = new Point();
[JsonProperty("箱子索引")]
public int ChestIndex { get; set; } = -1;
[JsonProperty("输出列表")]
public List<int> OutChests { get; set; } = new();
[JsonProperty("钓任务鱼")]
public bool QuestFish { get; set; } = true;
[JsonProperty("允许钓怪")]
public bool CustomNPC { get; set; } = true;
[JsonProperty("禁钓已有怪物")]
public bool SoloMonster { get; set; } = true;
[JsonProperty("禁钓模式")]
public bool SoloMode { get; set; } = false; // true只钓一个 / false相同不钓
[JsonProperty("怪物防护")]
public bool Safe { get; set; } = false;
[JsonProperty("防护模式")]
public bool Repel { get; set; } = true; // true=排斥,false=清除
[JsonProperty("击退力度")]
public float Power { get; set; } = 5f;
[JsonProperty("影响友军")]
public bool Friendly { get; set; } = false; // 是否影响友好NPC
[JsonProperty("影响雕像")]
public bool Statue { get; set; } = false; // 是否影响雕像生成的NPC
[JsonProperty("高度等级")]
public int HeightLevel { get; set; }
[JsonProperty("颠倒海洋")]
public bool RolledRemixOcean { get; set; }
[JsonProperty("钓鱼药水时间")]
public DateTime FishingPotionTime { get; set; } = DateTime.MinValue;
[JsonProperty("宝匣药水时间")]
public DateTime CratePotionTime { get; set; } = DateTime.MinValue;
[JsonProperty("鱼饵桶时间")]
public DateTime ChumBucketTime { get; set; } = DateTime.MinValue;
[JsonProperty("鱼池名称")]
public string LiqName { get; set; }
[JsonProperty("鱼池格数")]
public int MaxLiq { get; set; }
// 液体数量
[JsonProperty("水格数")]
public int WaterCount { get; set; }
[JsonProperty("岩浆格数")]
public int LavaCount { get; set; }
[JsonProperty("蜂蜜格数")]
public int HoneyCount { get; set; }
[JsonProperty("液体坐标")]
public Point LiqPos { get; set; } = new Point(-1, -1);
[JsonProperty("幸运值")]
public float luck { get; set; }
[JsonProperty("额外渔力")]
public int ExtraPower { get; set; }
[JsonProperty("可钓岩浆")]
public bool CanFishInLava { get; set; }
[JsonProperty("钓具箱")]
public bool HasTackle { get; set; }
[JsonProperty("自定义消耗品")]
public Dictionary<int, CustomState> Custom { get; set; } = new();
[JsonProperty("区域增益")]
public Dictionary<int, DateTime> ActiveZoneBuffs { get; set; } = new();
[JsonProperty("排除物品")]
public HashSet<int> Exclude { get; set; } = new();
// 以下仅用于运行时计算,不保存
// 液体播报标识
[JsonIgnore]
public bool LiquidText = false;
// 熔岩钓鱼播报标识
[JsonIgnore]
public bool LavaText = false;
// 鱼竿槽位与播报标识
[JsonIgnore]
public int RodSlot { get; set; } = -1;
[JsonIgnore]
public bool RodText = false;
// 鱼饵槽位与播报标识
[JsonIgnore]
public int BaitSlot { get; set; } = -1;
[JsonIgnore]
public bool BaitText = false;
// 宝匣药水槽位
[JsonIgnore]
public int CratePotionSlot { get; set; } = -1;
// 大气因子
[JsonIgnore]
public float atmo { get; set; }
// 钓鱼药水槽位与消耗时间
[JsonIgnore]
public int FishingPotionSlot { get; set; } = -1;
// 鱼饵桶
[JsonIgnore]
public int ChumBucketSlot { get; set; } = -1;
// 区域玩家表
[JsonIgnore]
public HashSet<TSPlayer> Players { get; set; } = new();
// 初始化标志
[JsonIgnore]
public bool IntMach { get; set; } = true;
// 分帧执行(避免同1帧触发多台钓鱼机)
[JsonIgnore]
public long nextFrame { get; set; } = 0;
[JsonIgnore]
public AutoFishing Engine { get; set; }
// 液体不足停止检测
[JsonIgnore]
public bool LiqDead { get; set; } = false;
[JsonIgnore]
public int LiqType { get; set; } = -1;
[JsonIgnore]
public bool[] Visited { get; set; } // BFS 访问标记
[JsonIgnore]
public Queue<(int x, int y)> LiqQueue { get; set; } = new(); // BFS 队列
// 动画队列和计时
[JsonIgnore]
public Queue<AnimReq> AnimQueue { get; set; } = new();
[JsonIgnore]
public long AnimFrame { get; set; } = 0;
[JsonIgnore]
public int AnimOutIdx { get; set; } = 0; // 当前动画指向的传输箱索引
// 清理动画队列方法
public void ClearAnim()
{
AnimQueue.Clear();
Plugin.ActiveAnim.Remove(this);
AnimFrame = 0;
}
// 缓存非转移物品
[JsonIgnore]
public HashSet<int> SafeTypes { get; set; } = new();
// 是否需要转移积压物品
[JsonIgnore]
public bool NeedPut { get; set; } = false;
// 上次转移的帧数(用于冷却)
[JsonIgnore]
public long LastPutFrame { get; set; } = 0;
// 缓存NPC
[JsonIgnore]
public Dictionary<int, int> Monsters { get; set; } = new(); // 怪物类型 -> 数量
// 最后一次电路触发的帧数
[JsonIgnore]
public long WiringFrame { get; set; } = 0;
// 上次激活状态(用于打开箱子时检测)
[JsonIgnore]
public bool Wiring
{
get
{
if (WiringFrame == 0) return false;
return (Plugin.Timer - WiringFrame) < 120;
}
}
// 传输箱表辅助属性
[JsonIgnore]
public bool HasOut => OutChests.Count > 0;
public MachData() { }
}
#endregion