This repository was archived by the owner on Nov 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GitHub is dumb and doesn't include folders when uploading with the file picker :l
- Loading branch information
Showing
100 changed files
with
24,940 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using HarmonyLib; | ||
using UnityEngine; | ||
using System.Collections.Generic; | ||
|
||
namespace TownOfHost | ||
{ | ||
public static class AmongUsExtensions | ||
{ | ||
public static bool IsNullOrDestroyed(this System.Object obj) | ||
{ | ||
|
||
if (object.ReferenceEquals(obj, null)) return true; | ||
|
||
if (obj is UnityEngine.Object) return (obj as UnityEngine.Object) == null; | ||
|
||
return false; | ||
} | ||
// Utils.SendMessage("Hide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHide\nHid Guess Message"); | ||
|
||
|
||
public static TMPro.TextMeshPro nameText(this PlayerControl p) => p.cosmetics.nameText; | ||
|
||
public static TMPro.TextMeshPro NameText(this PoolablePlayer p) => p.cosmetics.nameText; | ||
|
||
public static UnityEngine.SpriteRenderer myRend(this PlayerControl p) => p.cosmetics.currentBodySprite.BodySprite; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Collections.Generic; | ||
using Hazel; | ||
|
||
namespace TownOfHost | ||
{ | ||
public static class AntiBlackout | ||
{ | ||
///<summary> | ||
///追放処理を上書きするかどうか | ||
///</summary> | ||
public static bool OverrideExiledPlayer => IsRequired && (IsSingleImpostor || Diff_CrewImp == 1); | ||
///<summary> | ||
///インポスターが一人しか存在しない設定かどうか | ||
///</summary> | ||
public static bool IsSingleImpostor => Main.RealOptionsData != null ? Main.RealOptionsData.NumImpostors == 1 : PlayerControl.GameOptions.NumImpostors == 1; | ||
///<summary> | ||
///AntiBlackout内の処理が必要であるかどうか | ||
///</summary> | ||
public static bool IsRequired => Options.NoGameEnd.GetBool() || CustomRoles.Arsonist.IsEnable() || CustomRoles.Marksman.IsEnable() || CustomRoles.TheGlitch.IsEnable() || CustomRoles.Werewolf.IsEnable() || CustomRoles.Jackal.IsEnable() || CustomRoles.PlagueBearer.IsEnable() || CustomRoles.Pestilence.IsEnable() || CustomRoles.Juggernaut.IsEnable() || CustomRoles.Coven.IsEnable() || CustomRoles.BloodKnight.IsEnable(); | ||
///<summary> | ||
///インポスター以外の人数とインポスターの人数の差 | ||
///</summary> | ||
public static int Diff_CrewImp | ||
{ | ||
get | ||
{ | ||
int numImpostors = 0; | ||
int numCrewmates = 0; | ||
foreach (var pc in PlayerControl.AllPlayerControls) | ||
{ | ||
if (pc.Data.Role.IsImpostor) numImpostors++; | ||
else numCrewmates++; | ||
} | ||
return numCrewmates - numImpostors; | ||
} | ||
} | ||
public static bool IsCached { get; private set; } = false; | ||
private static Dictionary<byte, bool> isDeadCache = new(); | ||
|
||
public static void SetIsDead(bool doSend = true, [CallerMemberName] string callerMethodName = "") | ||
{ | ||
Logger.Info($"SetIsDead is called from {callerMethodName}", "AntiBlackout"); | ||
if (IsCached) | ||
{ | ||
Logger.Info("再度SetIsDeadを実行する前に、RestoreIsDeadを実行してください。", "AntiBlackout.Error"); | ||
return; | ||
} | ||
isDeadCache.Clear(); | ||
foreach (var info in GameData.Instance.AllPlayers) | ||
{ | ||
if (info == null) continue; | ||
isDeadCache[info.PlayerId] = info.IsDead; | ||
info.IsDead = false; | ||
} | ||
IsCached = true; | ||
if (doSend) SendGameData(); | ||
} | ||
public static void RestoreIsDead(bool doSend = true, [CallerMemberName] string callerMethodName = "") | ||
{ | ||
Logger.Info($"RestoreIsDead is called from {callerMethodName}", "AntiBlackout"); | ||
foreach (var info in GameData.Instance.AllPlayers) | ||
{ | ||
if (info == null) continue; | ||
if (isDeadCache.TryGetValue(info.PlayerId, out bool val)) info.IsDead = val; | ||
} | ||
isDeadCache.Clear(); | ||
IsCached = false; | ||
if (doSend) SendGameData(); | ||
} | ||
|
||
public static void SendGameData([CallerMemberName] string callerMethodName = "") | ||
{ | ||
Logger.Info($"SendGameData is called from {callerMethodName}", "AntiBlackout"); | ||
MessageWriter writer = MessageWriter.Get(SendOption.Reliable); | ||
// 書き込み {}は読みやすさのためです。 | ||
writer.StartMessage(5); //0x05 GameData | ||
{ | ||
writer.Write(AmongUsClient.Instance.GameId); | ||
writer.StartMessage(1); //0x01 Data | ||
{ | ||
writer.WritePacked(GameData.Instance.NetId); | ||
GameData.Instance.Serialize(writer, true); | ||
|
||
} | ||
writer.EndMessage(); | ||
} | ||
writer.EndMessage(); | ||
|
||
AmongUsClient.Instance.SendOrDisconnect(writer); | ||
writer.Recycle(); | ||
} | ||
|
||
///<summary> | ||
///一時的にIsDeadを本来のものに戻した状態でコードを実行します | ||
///<param name="action">実行内容</param> | ||
///</summary> | ||
public static void TempRestore(Action action) | ||
{ | ||
Logger.Info("==Temp Restore==", "AntiBlackout"); | ||
//IsDeadが上書きされた状態でTempRestoreが実行されたかどうか | ||
bool before_IsCached = IsCached; | ||
try | ||
{ | ||
if (before_IsCached) RestoreIsDead(doSend: false); | ||
action(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Logger.Warn("AntiBlackout.TempRestore内で例外が発生しました", "AntiBlackout"); | ||
Logger.Error(ex.ToString(), "AntiBlackout.TempRestore"); | ||
} | ||
finally | ||
{ | ||
if (before_IsCached) SetIsDead(doSend: false); | ||
Logger.Info("==/Temp Restore==", "AntiBlackout"); | ||
} | ||
} | ||
|
||
public static void Reset() | ||
{ | ||
Logger.Info("==Reset==", "AntiBlackout"); | ||
if (isDeadCache == null) isDeadCache = new(); | ||
isDeadCache.Clear(); | ||
IsCached = false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace TownOfHost | ||
{ | ||
public static class Camouflague | ||
{ | ||
public static bool IsActive = false; | ||
public static bool InMeeting = false; | ||
public static bool did = false; | ||
public static void Grenade(bool shapeshifting) | ||
{ | ||
switch (shapeshifting) | ||
{ | ||
case false: | ||
if (Utils.IsActive(SystemTypes.Electrical) || Utils.IsActive(SystemTypes.Comms) || | ||
Utils.IsActive(SystemTypes.LifeSupp) || Utils.IsActive(SystemTypes.Reactor)) break; | ||
Main.Grenaiding = false; | ||
new LateTask(() => | ||
{ | ||
Main.ResetVision = true; | ||
Utils.CustomSyncAllSettings(); | ||
new LateTask(() => | ||
{ | ||
Main.ResetVision = false; | ||
Utils.CustomSyncAllSettings(); | ||
}, 1, "Reset Vision 2"); | ||
}, 5, "Reset Vision"); | ||
Utils.NotifyRoles(); | ||
break; | ||
case true: | ||
if (Utils.IsActive(SystemTypes.Electrical) || Utils.IsActive(SystemTypes.Comms) || | ||
Utils.IsActive(SystemTypes.LifeSupp) || Utils.IsActive(SystemTypes.Reactor)) break; | ||
Main.ResetVision = false; | ||
Main.Grenaiding = true; | ||
Utils.CustomSyncAllSettings(); | ||
new LateTask(() => | ||
{ | ||
Utils.NotifyRoles(NoCache: true); | ||
}, | ||
1.2f, "ShapeShiftNotify"); | ||
break; | ||
} | ||
} | ||
public static void Cause() | ||
{ | ||
foreach (var player in PlayerControl.AllPlayerControls) | ||
{ | ||
player.RpcSetCamouflague(); | ||
} | ||
|
||
IsActive = true; | ||
RpcToggleCamouflague(IsActive); | ||
Utils.NotifyRoles(); | ||
} | ||
public static void Revert() | ||
{ | ||
foreach (var player in PlayerControl.AllPlayerControls) | ||
{ | ||
player.RpcRevertSkins(); | ||
} | ||
|
||
IsActive = false; | ||
RpcToggleCamouflague(IsActive); | ||
|
||
Utils.NotifyRoles(); | ||
} | ||
public static void MeetingCause() | ||
{ | ||
foreach (var player in PlayerControl.AllPlayerControls) | ||
{ | ||
player.RpcSetCamouflague(); | ||
} | ||
|
||
///IsActive = true; | ||
//RpcToggleCamouflague(IsActive); | ||
Utils.NotifyRoles(); | ||
} | ||
public static void MeetingRevert() | ||
{ | ||
foreach (var player in PlayerControl.AllPlayerControls) | ||
{ | ||
player.RpcRevertSkins(); | ||
} | ||
|
||
//MeetingRpcToggleCamouflague(); | ||
IsActive = true; | ||
Utils.NotifyRoles(); | ||
} | ||
public static void RpcSetCamouflague(this PlayerControl player) | ||
{ | ||
if (!AmongUsClient.Instance.AmHost) return; | ||
|
||
int colorId = Main.AllPlayerSkin[player.PlayerId].Item1; | ||
|
||
|
||
var sender = CustomRpcSender.Create(name: "RpcSetCamouflague"); | ||
|
||
player.SetName(""); | ||
player.SetColor(15); //グレー | ||
/*sender.AutoStartRpc(player.NetId, (byte)RpcCalls.SetColor) | ||
.Write(15) | ||
.EndRpc();*/ | ||
|
||
player.SetHat("", colorId); | ||
/*sender.AutoStartRpc(player.NetId, (byte)RpcCalls.SetHatStr) | ||
.Write("") | ||
.EndRpc();*/ | ||
|
||
player.SetSkin("", colorId); | ||
/*sender.AutoStartRpc(player.NetId, (byte)RpcCalls.SetSkinStr) | ||
.Write("") | ||
.EndRpc();*/ | ||
|
||
player.SetVisor("", colorId); | ||
/*sender.AutoStartRpc(player.NetId, (byte)RpcCalls.SetVisorStr) | ||
.Write("") | ||
.EndRpc();*/ | ||
|
||
player.SetPet(""); | ||
/*sender.AutoStartRpc(player.NetId, (byte)RpcCalls.SetPetStr) | ||
.Write("") | ||
.EndRpc();*/ | ||
|
||
player.Shapeshift(PlayerControl.LocalPlayer, false); | ||
|
||
sender.AutoStartRpc(player.NetId, (byte)RpcCalls.Shapeshift) | ||
.Write(PlayerControl.LocalPlayer) | ||
.Write(false) | ||
.EndRpc(); | ||
|
||
sender.SendMessage(); | ||
} | ||
|
||
public static void RpcRevertSkins(this PlayerControl player) | ||
{ | ||
if (!AmongUsClient.Instance.AmHost) return; | ||
|
||
int colorId = Main.AllPlayerSkin[player.PlayerId].Item1; | ||
string hatId = Main.AllPlayerSkin[player.PlayerId].Item2; | ||
string skinId = Main.AllPlayerSkin[player.PlayerId].Item3; | ||
string visorId = Main.AllPlayerSkin[player.PlayerId].Item4; | ||
string petId = Main.AllPlayerSkin[player.PlayerId].Item5; | ||
string name = Main.AllPlayerSkin[player.PlayerId].Item6; | ||
|
||
var sender = CustomRpcSender.Create(name: "RpcRevertSkins"); | ||
|
||
player.SetName(name); | ||
|
||
player.SetColor(colorId); //グレー | ||
/*sender.AutoStartRpc(player.NetId, (byte)RpcCalls.SetColor) | ||
.Write(colorId) | ||
.EndRpc();*/ | ||
|
||
player.SetHat(hatId, colorId); | ||
/*sender.AutoStartRpc(player.NetId, (byte)RpcCalls.SetHatStr) | ||
.Write(hatId) | ||
.EndRpc();*/ | ||
|
||
player.SetSkin(skinId, colorId); | ||
/*sender.AutoStartRpc(player.NetId, (byte)RpcCalls.SetSkinStr) | ||
.Write(skinId) | ||
.EndRpc();*/ | ||
|
||
player.SetVisor(visorId, colorId); | ||
/*sender.AutoStartRpc(player.NetId, (byte)RpcCalls.SetVisorStr) | ||
.Write(visorId) | ||
.EndRpc();*/ | ||
|
||
player.SetPet(petId); | ||
/*sender.AutoStartRpc(player.NetId, (byte)RpcCalls.SetPetStr) | ||
.Write(petId) | ||
.EndRpc();*/ | ||
|
||
player.RpcShapeshift(player, false); | ||
sender.AutoStartRpc(player.NetId, (byte)RpcCalls.Shapeshift) | ||
.Write(player) | ||
.Write(false) | ||
.EndRpc(); | ||
|
||
sender.SendMessage(); | ||
} | ||
public static void RpcToggleCamouflague(bool IsActive) | ||
{ | ||
var sender = CustomRpcSender.Create("Set Camouflague IsActive"); | ||
|
||
sender.AutoStartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ToggleCamouflagueActive) | ||
.Write(IsActive) | ||
.EndRpc(); | ||
sender.SendMessage(); | ||
} | ||
|
||
public static void MeetingRpcToggleCamouflague() | ||
{ | ||
var sender = CustomRpcSender.Create("Set Camouflague IsActive"); | ||
|
||
sender.AutoStartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ToggleCamouflagueActive) | ||
.Write(true) | ||
.EndRpc(); | ||
sender.SendMessage(); | ||
} | ||
} | ||
} |
Oops, something went wrong.