Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
tugaru1975 authored Apr 17, 2022
1 parent a23647d commit 685ef96
Show file tree
Hide file tree
Showing 20 changed files with 408 additions and 291 deletions.
17 changes: 0 additions & 17 deletions TownOfPlus/CustomHats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,21 +416,4 @@ public static CustomHats.HatExtension getHatExtension(this HatData hat) {
return ret;
}
}

[HarmonyPatch(typeof(PoolablePlayer), nameof(PoolablePlayer.UpdateFromPlayerOutfit))]
public static class PoolablePlayerPatch
{
public static void Postfix(PoolablePlayer __instance)
{
if (__instance.VisorSlot?.transform == null || __instance.HatSlot?.transform == null) return;

// fixes a bug in the original where the visor will show up beneath the hat,
// instead of on top where it's supposed to be
__instance.VisorSlot.transform.localPosition = new Vector3(
__instance.VisorSlot.transform.localPosition.x,
__instance.VisorSlot.transform.localPosition.y,
__instance.HatSlot.transform.localPosition.z - 1
);
}
}
}
9 changes: 8 additions & 1 deletion TownOfPlus/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,14 @@ public static Color GetPlayerColor(PlayerControl p)
}
public static string GetColorHEX(InnerNet.ClientData Client)
{
return ColorToHex(Palette.PlayerColors[Client.ColorId]);
try
{
return ColorToHex(Palette.PlayerColors[Client.ColorId]);
}
catch
{
return "";
}
}
public static string ColorToHex(Color32 color)
{
Expand Down
85 changes: 85 additions & 0 deletions TownOfPlus/ModSetting/AddLobbySetting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using BepInEx;
using BepInEx.Configuration;
using BepInEx.IL2CPP;
using System;
using System.Linq;
using HarmonyLib;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnhollowerBaseLib;
using Hazel;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Linq;
using System.Threading;
using System.Threading.Tasks;

namespace TownOfPlus
{
[HarmonyPatch(typeof(GameSettingMenu), nameof(GameSettingMenu.InitializeOptions))]
public static class GameSettingMenuPatch
{
public static void Prefix(GameSettingMenu __instance)
{
if (!main.RoomOption.Value) return;
// オンラインモードで部屋を立て直さなくてもマップを変更できるように変更
__instance.HideForOnline = new Il2CppReferenceArray<Transform>(0);
}
}

[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.Start))]
[HarmonyPriority(Priority.First)]
public static class GameOptionsMenuPatch
{
public static void Postfix(GameOptionsMenu __instance)
{
if (!main.RoomOption.Value) return;
foreach (var ob in __instance.Children)
{
switch (ob.Title)
{
case StringNames.GameShortTasks:
case StringNames.GameLongTasks:
case StringNames.GameCommonTasks:
ob.Cast<NumberOption>().ValidRange = new FloatRange(0, 99);
break;
case StringNames.GameKillCooldown:
ob.Cast<NumberOption>().ValidRange = new FloatRange(0, 180);
break;
case StringNames.GameRecommendedSettings:
ob.enabled = false;
ob.gameObject.SetActive(false);
break;
default:
break;
}
}
}
}
[HarmonyPatch(typeof(GameStartManager), nameof(GameStartManager.Update))]
public static class KillCoolDown
{
public static bool flag = false;
public static void Prefix(GameStartManager __instance)
{
if (AmongUsClient.Instance.AmHost)
{
if (main.NokillCool.Value)
{
PlayerControl.GameOptions.KillCooldown = 0.00001f;
flag = true;
Helpers.SyncSettings();
}
else
{
if (flag)
{
PlayerControl.GameOptions.KillCooldown = 0f;
Helpers.SyncSettings();
flag = false;
}
}
}
}
}
}
117 changes: 117 additions & 0 deletions TownOfPlus/ModSetting/CPS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
using BepInEx;
using BepInEx.Configuration;
using BepInEx.IL2CPP;
using System;
using System.Linq;
using HarmonyLib;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnhollowerBaseLib;
using Hazel;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Linq;
using Il2CppSystem;
using System.Threading;
using System.Threading.Tasks;
using System.Collections;
using System.Text;
using System.Text.RegularExpressions;
using UnityEngine.UI;

namespace TownOfPlus
{
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))]
public static class CPS
{
private static SpriteRenderer CPSUnderlay;
private static TMPro.TextMeshPro CPStext;
private static int count = 0;

public static void Postfix(HudManager __instance)
{
if (!initializeOverlays()) return;

HudManager hudManager = DestroyableSingleton<HudManager>.Instance;
if (PlayerControl.LocalPlayer == null || hudManager == null)
return;

Transform parent;
parent = hudManager.transform;

CPStext.transform.parent = parent;
CPSUnderlay.transform.parent = parent;
CPSUnderlay.color = new Color(0.1f, 0.1f, 0.1f, 0.88f);
CPSUnderlay.transform.localScale = new Vector3(1f, 0.25f, 0.5f);
CPSUnderlay.transform.localPosition = new Vector3(main.CPSpositionX.Value, main.CPSpositionY.Value, -900f);

CPStext.transform.localPosition = new Vector3(main.CPSpositionX.Value, main.CPSpositionY.Value, -900f);
CPStext.text = count.ToString() + " CPS";
if (main.CPS.Value)
{
if (Input.GetKeyDown(KeyCode.Mouse0))
{
count += 1;
new Timer(() =>
{
count -= 1;
},1f);
}
if (main.SettingCPS)
{
if (Input.GetKey(KeyCode.RightArrow))
{
main.CPSpositionX.Value += 0.05f;
}
if (Input.GetKey(KeyCode.LeftArrow))
{
main.CPSpositionX.Value -= 0.05f;
}
if (Input.GetKey(KeyCode.DownArrow))
{
main.CPSpositionY.Value -= 0.05f;
}
if (Input.GetKey(KeyCode.UpArrow))
{
main.CPSpositionY.Value += 0.05f;
}
}
CPStext.enabled = true;
CPSUnderlay.enabled = true;

}
else
{
count = 0;
CPSUnderlay.enabled = false;
CPStext.enabled = false;
}
}
public static bool initializeOverlays()
{
HudManager hudManager = DestroyableSingleton<HudManager>.Instance;
if (hudManager == null) return false;
if (CPSUnderlay == null)
{
CPSUnderlay = UnityEngine.Object.Instantiate(hudManager.FullScreen, hudManager.transform);
CPSUnderlay.transform.localPosition = new Vector3(main.CPSpositionX.Value, main.CPSpositionY.Value, -900f);
CPSUnderlay.gameObject.SetActive(true);
CPSUnderlay.enabled = false;
}
if (CPStext == null)
{
CPStext = UnityEngine.Object.Instantiate(hudManager.TaskText, hudManager.transform);
CPStext.fontSize = CPStext.fontSizeMin = CPStext.fontSizeMax = 1.15f;
CPStext.autoSizeTextContainer = false;
CPStext.enableWordWrapping = false;
CPStext.alignment = TMPro.TextAlignmentOptions.Center;
CPStext.transform.localPosition = new Vector3(main.CPSpositionX.Value, main.CPSpositionY.Value, -900f);
CPStext.transform.localScale = Vector3.one * 1.5f;
CPStext.color = Palette.White;
CPStext.enabled = false;
}
return true;
}
}

}
1 change: 1 addition & 0 deletions TownOfPlus/ModSetting/ChangeName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ChangeName
public static void Postfix(HudManager __instance)
{
var p = PlayerControl.LocalPlayer;
if (p == null) return;
Color color = Helpers.GetPlayerColor(p);
if (main.NameOutline.Value) color = Palette.Black;
if (main.RainbowName.Value || main.TranslucentName.Value)
Expand Down
Loading

0 comments on commit 685ef96

Please # to comment.