forked from RazzSG/ClickerClass
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClickEffect.cs
More file actions
187 lines (165 loc) · 7.25 KB
/
ClickEffect.cs
File metadata and controls
187 lines (165 loc) · 7.25 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
using ClickerClass.Utilities;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace ClickerClass
{
public sealed class ClickEffect : ICloneable
{
public Mod Mod { get; private set; }
public string InternalName { get; private set; }
public string UniqueName => ClickerSystem.UniqueEffectName(Mod, InternalName);
public string DisplayName { get; private set; }
public string Description { get; private set; }
public bool TryUsingTranslation { get; private set; }
public int Amount { get; private set; }
public Color Color { get; private set; }
public Action<Player, Vector2, int, int, float> Action { get; private set; }
public ClickEffect(Mod mod, string internalName, string displayName, string description, int amount, Color color, Action<Player, Vector2, int, int, float> action)
{
Mod = mod ?? throw new Exception("No mod specified");
InternalName = internalName ?? throw new Exception("No internal name specified");
DisplayName = displayName ?? LangHelper.GetText("Common.Unknown");
Description = description ?? LangHelper.GetText("Common.Unknown");
TryUsingTranslation = displayName == null || description == null;
Amount = amount;
Color = color;
Action = action ?? (new Action<Player, Vector2, int, int, float>((a, b, c, d, e) => { }));
}
public object Clone()
{
return new ClickEffect(Mod, InternalName, DisplayName, Description, Amount, Color, (Action<Player, Vector2, int, int, float>)Action.Clone());
}
public TooltipLine ToTooltip(int amount, float alpha, bool showDesc)
{
string color = (Color * alpha).Hex3();
string text;
if (amount > 1)
{
text = LangHelper.GetText("Common.Tooltips.MoreThanOneClick", amount);
}
else
{
text = LangHelper.GetText("Common.Tooltips.OneClick");
}
text += $": [c/" + color + ":" + DisplayName + "]";
if (showDesc && Description != string.Empty)
{
text += $" - {Description}";
}
return new TooltipLine(ClickerClass.mod, $"ClickEffect_{UniqueName}", text);
}
internal void FinalizeLocalization()
{
if (TryUsingTranslation)
{
string keyBase = $"ClickEffect.{InternalName}";
string value = LangHelper.GetTextByMod(Mod, $"{keyBase}.Name");
if (!value.Contains(keyBase))
{
//A valid translation
DisplayName = value;
}
value = LangHelper.GetTextByMod(Mod, $"{keyBase}.Description");
if (!value.Contains(keyBase))
{
//A valid translation
Description = value;
}
}
}
public override string ToString()
{
return $"{DisplayName}: {Description}".Substring(0, 20);
}
public Dictionary<string, object> ToDictionary()
{
return new Dictionary<string, object>
{
["Mod"] = Mod,
["InternalName"] = InternalName,
["UniqueName"] = UniqueName,
["DisplayName"] = DisplayName,
["Description"] = Description,
["Amount"] = Amount,
["Color"] = Color,
["Action"] = Action
};
}
/// <summary>
/// Loads commonly used click effects
/// </summary>
internal static void LoadMiscEffects()
{
ClickEffect.DoubleClick = ClickerSystem.RegisterClickEffect(ClickerClass.mod, "DoubleClick", null, null, 10, Color.White, delegate (Player player, Vector2 position, int type, int damage, float knockBack)
{
DoubleClick(player, position, type, damage, knockBack);
});
ClickEffect.DoubleClick2 = ClickerSystem.RegisterClickEffect(ClickerClass.mod, "DoubleClick2", null, null, 8, Color.White, delegate (Player player, Vector2 position, int type, int damage, float knockBack)
{
DoubleClick(player, position, type, damage, knockBack);
});
void DoubleClick(Player player, Vector2 position, int type, int damage, float knockBack)
{
Main.PlaySound(SoundID.Item, (int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 37);
Projectile.NewProjectile(Main.MouseWorld, Vector2.Zero, type, damage, knockBack, player.whoAmI);
}
}
#region Registered Effects
//Acc
public static string StickyKeychain { get; internal set; } = string.Empty;
public static string ChocolateChip { get; internal set; } = string.Empty;
public static string BigRedButton { get; internal set; } = string.Empty;
//Clicker
public static string TrueStrike { get; internal set; } = string.Empty;
public static string HolyNova { get; internal set; } = string.Empty;
public static string Spiral { get; internal set; } = string.Empty;
public static string Lacerate { get; internal set; } = string.Empty;
public static string Illuminate { get; internal set; } = string.Empty;
public static string Bombard { get; internal set; } = string.Empty;
public static string ToxicRelease { get; internal set; } = string.Empty;
public static string Haste { get; internal set; } = string.Empty;
public static string DoubleClick { get; internal set; } = string.Empty;
public static string DoubleClick2 { get; internal set; } = string.Empty;
public static string CursedEruption { get; internal set; } = string.Empty;
public static string Infest { get; internal set; } = string.Empty;
public static string Dazzle { get; internal set; } = string.Empty;
public static string DarkBurst { get; internal set; } = string.Empty;
public static string DustDevil { get; internal set; } = string.Empty;
public static string Totality { get; internal set; } = string.Empty;
public static string Freeze { get; internal set; } = string.Empty;
public static string Linger { get; internal set; } = string.Empty;
public static string Discharge { get; internal set; } = string.Empty;
public static string StickyHoney { get; internal set; } = string.Empty;
public static string SolarFlare { get; internal set; } = string.Empty;
public static string Flurry { get; internal set; } = string.Empty;
public static string Conqueror { get; internal set; } = string.Empty;
public static string Collision { get; internal set; } = string.Empty;
public static string Embrittle { get; internal set; } = string.Empty;
public static string Spores { get; internal set; } = string.Empty;
public static string PetalStorm { get; internal set; } = string.Empty;
public static string Regenerate { get; internal set; } = string.Empty;
public static string StingingThorn { get; internal set; } = string.Empty;
public static string Inferno { get; internal set; } = string.Empty;
public static string Curse { get; internal set; } = string.Empty;
public static string AutoClick { get; internal set; } = string.Empty;
public static string Siphon { get; internal set; } = string.Empty;
public static string Splash { get; internal set; } = string.Empty;
public static string StarStorm { get; internal set; } = string.Empty;
public static string PhaseReach { get; internal set; } = string.Empty;
public static string TheClick { get; internal set; } = string.Empty;
public static string RazorsEdge { get; internal set; } = string.Empty;
public static string ShadowLash { get; internal set; } = string.Empty;
public static string WebSplash { get; internal set; } = string.Empty;
public static string WildMagic { get; internal set; } = string.Empty;
#endregion
public static void Unload()
{
//Invokes the static constructor to redefine 'Registered Effects'
typeof(ClickEffect).TypeInitializer?.Invoke(null, null);
}
}
}