-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoreLogic.cs
More file actions
98 lines (79 loc) · 3.71 KB
/
CoreLogic.cs
File metadata and controls
98 lines (79 loc) · 3.71 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
using Microsoft.Xna.Framework;
using ProgressLock.Enums;
using System;
using Terraria;
using Terraria.Chat;
using Terraria.GameContent.Events;
using Terraria.ID;
using Terraria.Localization;
using Terraria.ModLoader;
using static ProgressLock.Utils;
namespace ProgressLock
{
// Boss控制
public class ProgressLockGlobalNPC : GlobalNPC
{
public override bool PreAI(NPC npc)
{
var config = ProgressLockConfig.Config;
if (npc == null || !npc.active) return true;
if (config.NpcEntries == null)
return true;
else
{
if (!IsUnlocked(npc, out LockStatus status))
{
StopNPC(npc);
switch (status)
{
case LockStatus.IsManuallyLocked:
ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(GetMentionMsg("NpcManuallyLocked")), Color.IndianRed);
break;
case LockStatus.NotTimeYet:
foreach (var entry in config.NpcEntries)
{
foreach(var def in entry.DefinitionList)
{
if (def.Type == npc.type)
{
DateTime unlockTime = DateTime.Parse(config.FirstTime).AddSeconds(entry.UnlockTimeSec);
string formattedDate = unlockTime.ToString("MMM-d HH:mm:ss");
ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(GetMentionMsg("NpcNotTimeYet", Lang.GetNPCNameValue(npc.type), formattedDate)), Color.IndianRed);
}
}
}
break;
}
}
return false;
}
}
}
// 事件控制
public class ProgressLockWorld : ModSystem
{
public override void PreUpdateWorld()
{
var config = ProgressLockConfig.Config;
if (config.EventEntries == null) return;
foreach (var entry in config.EventEntries)
{
if (!IsUnlocked(out LockStatus status, out var matchedEntry))
{
matchedEntry.Stop();
switch (status)
{
case LockStatus.IsManuallyLocked:
ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(GetMentionMsg("EventManuallyLocked", Language.GetTextValue($"Mods.ProgressLock.Configs.VanillaEvent.{matchedEntry.Name}.Label"))), Color.IndianRed);
break;
case LockStatus.NotTimeYet:
DateTime unlockTime = DateTime.Parse(config.FirstTime).AddSeconds(matchedEntry.UnlockTimeSec);
string formattedDate = unlockTime.ToString("MMM dd HH:mm:ss");
ChatHelper.BroadcastChatMessage(NetworkText.FromLiteral(GetMentionMsg("EventNotTimeYet", Language.GetTextValue($"Mods.ProgressLock.Configs.VanillaEvent.{matchedEntry.Name}.Label"), formattedDate)), Color.IndianRed);
break;
}
}
}
}
}
}