Skip to content

Commit b23d35d

Browse files
authored
Merge pull request #7 from tugaru1975/v1.8.1
V1.8.1
2 parents 4db0c95 + 9cb1619 commit b23d35d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1017
-1504
lines changed

CustomSkin/CustomHats.cs

+10-11
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@ namespace TownOfPlus
1414
[HarmonyPatch]
1515
public class CustomHats
1616
{
17-
private static bool isadded = false;
1817
public static Material hatShader;
1918

2019
public static Dictionary<string, HatExtension> CustomHatRegistry = new();
21-
public static HatExtension TestExt = null;
2220

2321
public class HatExtension
2422
{
25-
public string author { get; set; }
26-
public string condition { get; set; }
2723
public Sprite FlipImage { get; set; }
2824
public Sprite BackFlipImage { get; set; }
2925
}
@@ -161,13 +157,15 @@ private static HatData CreateHatBehaviour(CustomHat chd)
161157
return CreateHatData(chd);
162158
}
163159

160+
private static bool RUNNING = false;
161+
private static bool isadded = false;
164162
[HarmonyPatch(typeof(HatManager), nameof(HatManager.GetHatById))]
165163
private static class HatManagerPatch
166164
{
167165
static void Prefix(HatManager __instance)
168166
{
169-
if (isadded) return;
170-
isadded = true;
167+
if (RUNNING || isadded) return;
168+
RUNNING = true;
171169
try
172170
{
173171
try
@@ -189,12 +187,17 @@ static void Prefix(HatManager __instance)
189187

190188
while (CustomHatLoader.hatdetails.Count > 0)
191189
{
190+
isadded = true;
192191
__instance.allHats.Add(CreateHatBehaviour(CustomHatLoader.hatdetails[0]));
193192
CustomHatLoader.hatdetails.RemoveAt(0);
194193
}
195194
}
196195
catch { }
197196
}
197+
static void Postfix(HatManager __instance)
198+
{
199+
RUNNING = false;
200+
}
198201
}
199202

200203
[HarmonyPatch(typeof(PlayerPhysics), nameof(PlayerPhysics.HandleAnimation))]
@@ -256,7 +259,7 @@ private static async Task LaunchHatFetcherAsync()
256259
{
257260
HttpStatusCode status = await FetchHats(repo.log("チェック開始"));
258261
if (status != HttpStatusCode.OK) repo.log("URLが見つかりませんでした", LogType.Error);
259-
else repo.log("チェック終了");
262+
else repo.log("チェック終了").gamelog("ハットダウンロード終了");
260263
}
261264
catch { }
262265
}
@@ -365,10 +368,6 @@ public static class CustomHatExtensions
365368
{
366369
public static CustomHats.HatExtension getHatExtension(this HatData hat)
367370
{
368-
if (CustomHats.TestExt != null && CustomHats.TestExt.condition.Equals(hat.name))
369-
{
370-
return CustomHats.TestExt;
371-
}
372371
CustomHats.CustomHatRegistry.TryGetValue(hat.name, out var ret);
373372
return ret;
374373
}

CustomSkin/CustomNamePlates.cs

+11-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private static async Task LaunchNamePlateFetcherAsync()
3232
{
3333
HttpStatusCode status = await FetchNamePlates(repo.log("チェック開始"));
3434
if (status != HttpStatusCode.OK) repo.log("URLが見つかりませんでした", LogType.Error);
35-
else repo.log("チェック終了");
35+
else repo.log("チェック終了").gamelog("ネームプレートダウンロード終了");
3636
}
3737
catch { }
3838
}
@@ -130,15 +130,15 @@ public class CustomNamePlate
130130
public string resource { get; set; }
131131
}
132132

133-
public static bool isAdded = false;
134-
133+
private static bool RUNNING = false;
134+
private static bool isadded = false;
135135
[HarmonyPatch(typeof(HatManager), nameof(HatManager.GetNamePlateById))]
136136
class UnlockedNamePlatePatch
137137
{
138138
public static void Prefix(HatManager __instance)
139139
{
140-
if (isAdded) return;
141-
isAdded = true;
140+
if (RUNNING || isadded) return;
141+
RUNNING = true;
142142
try
143143
{
144144
try
@@ -155,16 +155,21 @@ public static void Prefix(HatManager __instance)
155155
}
156156
}
157157
}
158-
catch (System.Exception e) { e.log(); }
158+
catch { }
159159

160160
while (CustomNamePlateLoader.NamePlatedetails.Count > 0)
161161
{
162+
isadded = true;
162163
__instance.allNamePlates.Add(CreateNamePlateBehaviour(CustomNamePlateLoader.NamePlatedetails[0]));
163164
CustomNamePlateLoader.NamePlatedetails.RemoveAt(0);
164165
}
165166
}
166167
catch { }
167168
}
169+
static void Postfix(HatManager __instance)
170+
{
171+
RUNNING = false;
172+
}
168173
}
169174

170175
private static NamePlateData CreateNamePlateBehaviour(CustomNamePlate cvd)

CustomSkin/CustomVisors.cs

+10-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private static async Task LaunchVisorFetcherAsync()
3232
{
3333
HttpStatusCode status = await FetchVisors(repo.log("チェック開始"));
3434
if (status != HttpStatusCode.OK) repo.log("URLが見つかりませんでした", LogType.Error);
35-
else repo.log("チェック終了");
35+
else repo.log("チェック終了").gamelog("バイザーダウンロード終了");
3636
}
3737
catch { }
3838
}
@@ -135,14 +135,15 @@ public class CustomVisor
135135
public string flipresource { get; set; }
136136
}
137137

138-
public static bool isAdded = false;
138+
private static bool RUNNING = false;
139+
private static bool isadded = false;
139140
[HarmonyPatch(typeof(HatManager), nameof(HatManager.GetVisorById))]
140141
class UnlockedVisorPatch
141142
{
142143
public static void Prefix(HatManager __instance)
143144
{
144-
if (isAdded) return;
145-
isAdded = true;
145+
if (RUNNING || isadded) return;
146+
RUNNING = true;
146147
try
147148
{
148149
try
@@ -163,12 +164,17 @@ public static void Prefix(HatManager __instance)
163164

164165
while (CustomVisorLoader.Visordetails.Count > 0)
165166
{
167+
isadded = true;
166168
__instance.allVisors.Add(CreateVisorBehaviour(CustomVisorLoader.Visordetails[0]));
167169
CustomVisorLoader.Visordetails.RemoveAt(0);
168170
}
169171
}
170172
catch { }
171173
}
174+
static void Postfix(HatManager __instance)
175+
{
176+
RUNNING = false;
177+
}
172178
}
173179

174180
private static VisorData CreateVisorBehaviour(CustomVisor cvd)

Helpers.cs

+78-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using BepInEx.Configuration;
12
using BepInEx.IL2CPP;
23
using HarmonyLib;
34
using Hazel;
@@ -83,7 +84,7 @@ public static bool TryGetClient(this byte id, out ClientData client)
8384
if (client == null) return false;
8485
return true;
8586
}
86-
87+
8788

8889
public static bool TryNamePlayer(string name, out string playername, out PlayerControl pc)
8990
{
@@ -124,7 +125,7 @@ public static bool TryGetPlayerName(int colorid, out string color)
124125

125126
public static string GetClientColor(ClientData client) =>
126127
TryGetPlayerColor(client.ColorId, out var color) ? ColorToHex(color) : null;
127-
128+
128129

129130
public static string ColorToHex(Color32 color) =>
130131
color.r.ToString("X2") + color.g.ToString("X2") + color.b.ToString("X2") + color.a.ToString("X2");
@@ -139,7 +140,7 @@ public static void DMChat(ClientData client, string title, string text)
139140

140141
public static void StartRpc(string value, uint targetid, RpcCalls rpccalls, int targetClientid = -1)
141142
{
142-
var msg = AmongUsClient.Instance.StartRpcImmediately(targetid, (byte)rpccalls, SendOption.None, targetClientid);
143+
var msg = AmongUsClient.Instance.StartRpcImmediately(targetid, (byte)rpccalls, SendOption.Reliable, targetClientid);
143144
msg.Write(value);
144145
AmongUsClient.Instance.FinishRpcImmediately(msg);
145146
}
@@ -196,9 +197,16 @@ public static KeyCode GetKey()
196197
return KeyCode.None;
197198
}
198199

199-
public static void Destroy(this GameObject ob)
200+
public static GameObject Destroy(this GameObject ob, float f = 0)
201+
{
202+
UnityEngine.Object.Destroy(ob, f);
203+
return ob;
204+
}
205+
206+
public static GameObject DontDestroyOnLoad(this GameObject ob)
200207
{
201-
UnityEngine.Object.Destroy(ob);
208+
UnityEngine.Object.DontDestroyOnLoad(ob);
209+
return ob;
202210
}
203211

204212
public static bool Contains(this IEnumerable<string> list, string value, StringComparison stringcomparison)
@@ -323,7 +331,7 @@ public static class TextPlus
323331

324332
public static string SetColor(ref string text, string color) => text = text.SetColor(color);
325333

326-
public static string SetColor(this string text, string color) => $"<color=#{color}>" + text + "</color>";
334+
public static string SetColor(this string text, string color) => $"<color=#{color.TrimStart('#')}>" + text + "</color>";
327335

328336
public static string SetSize(ref string text, float size) => text = text.SetSize(size);
329337

@@ -366,15 +374,76 @@ public static void RpcSendChat(string text)
366374
{
367375
if (GameState.IsCanSendChat)
368376
{
369-
HudManager.Instance.Chat.TimeSinceLastMessage = 0f;
370377
PlayerControl.LocalPlayer.RpcSendChat(text);
378+
HudManager.Instance.Chat.TimeSinceLastMessage = 0f;
371379
}
372380
}
373381

374382
public static string GetTranslation(this StringNames name) => DestroyableSingleton<TranslationController>.Instance.GetString(name, new Il2CppReferenceArray<Il2CppSystem.Object>(0));
375383

376-
public static char ComWord => main.ChangeComWord.Value ? '.' : '/';
384+
385+
public static char ComWord => main.ChangeComWord?.Getbool() is true ? '/' : '.';
377386
}
387+
388+
public static class Overlay
389+
{
390+
public static SpriteRenderer CreateUnderlay(ConfigEntry<float> x, ConfigEntry<float> y, string name)
391+
{
392+
HudManager hudManager = DestroyableSingleton<HudManager>.Instance;
393+
394+
var underlay = UnityEngine.Object.Instantiate(hudManager.FullScreen, hudManager.transform);
395+
underlay.transform.localPosition = new Vector3(x.Value, y.Value, -900f);
396+
underlay.color = new Color(0.1f, 0.1f, 0.1f, 0.88f);
397+
underlay.name = name + "Underlay";
398+
underlay.gameObject.SetActive(true);
399+
underlay.enabled = true;
400+
return underlay;
401+
}
402+
403+
public static TMPro.TextMeshPro CreateText(ConfigEntry<float> x, ConfigEntry<float> y, string name)
404+
{
405+
HudManager hudManager = DestroyableSingleton<HudManager>.Instance;
406+
407+
var text = UnityEngine.Object.Instantiate(hudManager.TaskText, hudManager.transform);
408+
text.fontSize = text.fontSizeMin = text.fontSizeMax = 1.75f;
409+
text.autoSizeTextContainer = false;
410+
text.enableWordWrapping = false;
411+
text.alignment = TMPro.TextAlignmentOptions.Center;
412+
text.transform.localPosition = new Vector3(x.Value, y.Value, -900f);
413+
text.color = Palette.White;
414+
text.name = name + "text";
415+
text.text = "0";
416+
text.enabled = true;
417+
return text;
418+
}
419+
420+
public static Vector3 SettingPos(ConfigEntry<float> x, ConfigEntry<float> y)
421+
{
422+
if (Input.GetKey(KeyCode.RightArrow))
423+
{
424+
x.Value += 0.05f;
425+
}
426+
if (Input.GetKey(KeyCode.LeftArrow))
427+
{
428+
x.Value -= 0.05f;
429+
}
430+
if (Input.GetKey(KeyCode.DownArrow))
431+
{
432+
y.Value -= 0.05f;
433+
}
434+
if (Input.GetKey(KeyCode.UpArrow))
435+
{
436+
y.Value += 0.05f;
437+
}
438+
if (Input.GetMouseButton(1))
439+
{
440+
x.Value = Helpers.ScreenToMousePositon.x;
441+
y.Value = Helpers.ScreenToMousePositon.y;
442+
}
443+
return new Vector3(x.Value, y.Value, -900f);
444+
}
445+
}
446+
378447
public static class GameState
379448
{
380449
public static bool IsLobby => AmongUsClient.Instance?.GameState is InnerNetClient.GameStates.Joined && !IsFreePlay;
@@ -388,7 +457,7 @@ public static class GameState
388457
public static bool IsChatActive => HudManager.Instance?.Chat?.isActiveAndEnabled is true;
389458
public static bool IsCanSendChat => HudManager.Instance?.Chat?.TimeSinceLastMessage >= 3f;
390459
public static bool IsFocusChatArea => HudManager.Instance?.Chat?.TextArea?.hasFocus is true;
391-
public static bool IsCanKeyCommand => IsFocusChatArea && main.KeyCommand.Value;
460+
public static bool IsCanKeyCommand => IsFocusChatArea && main.KeyCommand.Getbool();
392461
public static bool IsCanMove => PlayerControl.LocalPlayer?.CanMove is true;
393462
public static bool IsCountDown => GameStartManager.Instance?.startState is GameStartManager.StartingStates.Countdown;
394463
public static bool IsDead => PlayerControl.LocalPlayer?.Data?.IsDead is true;

0 commit comments

Comments
 (0)