Skip to content

Commit

Permalink
Merge pull request #1206 from tukasa0001/develop-4.0.0
Browse files Browse the repository at this point in the history
Develop 4.0.0
  • Loading branch information
tanakanira0118 authored Dec 4, 2022
2 parents 75baeeb + ff10d65 commit 6bfc3db
Show file tree
Hide file tree
Showing 87 changed files with 5,269 additions and 3,521 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin/
obj/
bin/
FodyWeavers.xsd
7 changes: 7 additions & 0 deletions FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura>
<IncludeAssemblies>
Csv
</IncludeAssemblies>
</Costura>
</Weavers>
90 changes: 0 additions & 90 deletions Helpers.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Modules/AntiBlackout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static class AntiBlackout
///<summary>
///AntiBlackout内の処理が必要であるかどうか
///</summary>
public static bool IsRequired => Options.NoGameEnd.GetBool() || CustomRoles.Jackal.IsEnable();
public static bool IsRequired => Options.NoGameEnd.GetBool() || Jackal.IsEnable;
///<summary>
///インポスター以外の人数とインポスターの人数の差
///</summary>
Expand Down
85 changes: 85 additions & 0 deletions Modules/BanManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System;
using System.IO;
using System.Text.RegularExpressions;
using static TownOfHost.Translator;
namespace TownOfHost
{
public static class BanManager
{
private static readonly string DENY_NAME_LIST_PATH = @"./TOH_DATA/DenyName.txt";
private static readonly string BAN_LIST_PATH = @"./TOH_DATA/BanList.txt";

public static void Init()
{
Directory.CreateDirectory("TOH_DATA");
if (!File.Exists(DENY_NAME_LIST_PATH)) File.Create(DENY_NAME_LIST_PATH).Close();
if (!File.Exists(BAN_LIST_PATH)) File.Create(BAN_LIST_PATH).Close();
}
public static void AddBanPlayer(InnerNet.ClientData player)
{
if (!AmongUsClient.Instance.AmHost) return;
if (!CheckBanList(player))
{
File.AppendAllText(BAN_LIST_PATH, $"{player.FriendCode},{player.PlayerName}\n");
}
}
public static void CheckDenyNamePlayer(InnerNet.ClientData player)
{
if (!AmongUsClient.Instance.AmHost) return;
try
{
Directory.CreateDirectory("TOH_DATA");
if (!File.Exists(DENY_NAME_LIST_PATH)) File.Create(DENY_NAME_LIST_PATH).Close();
using StreamReader sr = new(DENY_NAME_LIST_PATH);
string line;
while ((line = sr.ReadLine()) != null)
{
if (line == "") continue;
if (Regex.IsMatch(player.PlayerName, line))
{
AmongUsClient.Instance.KickPlayer(player.Id, false);
Logger.SendInGame(string.Format(GetString("Message.KickedByDenyName"), player.PlayerName, line));
Logger.Info($"{player.PlayerName}は名前が「{line}」に一致したためキックされました。", "Kick");
return;
}
}
}
catch (Exception ex)
{
Logger.Exception(ex, "CheckDenyNamePlayer");
}
}
public static void CheckBanPlayer(InnerNet.ClientData player)
{
if (!AmongUsClient.Instance.AmHost) return;
if (CheckBanList(player))
{
AmongUsClient.Instance.KickPlayer(player.Id, true);
Logger.SendInGame(string.Format(GetString("Message.BanedByBanList"), player.PlayerName));
Logger.Info($"{player.PlayerName}は過去にBAN済みのためBANされました。", "BAN");
return;
}
}
public static bool CheckBanList(InnerNet.ClientData player)
{
try
{
Directory.CreateDirectory("TOH_DATA");
if (!File.Exists(BAN_LIST_PATH)) File.Create(BAN_LIST_PATH).Close();
using StreamReader sr = new(BAN_LIST_PATH);
string line;
while ((line = sr.ReadLine()) != null)
{
if (line == "") continue;
if (player.FriendCode == line.Split(",")[0]) return true;
}
}
catch (Exception ex)
{
Logger.Exception(ex, "CheckBanList");
}
return false;
}

}
}
75 changes: 75 additions & 0 deletions Modules/Camouflague.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System.Collections.Generic;
namespace TownOfHost
{
public static class Camouflage
{
public static Dictionary<byte, (int, string, string, string, string)> PlayerSkins = new();
public static void RpcSetSkin(PlayerControl target, bool ForceRevert = false)
{
if (!(AmongUsClient.Instance.AmHost && Options.CommsCamouflage.GetBool())) return;
if (target == null) return;
var id = target.PlayerId;

int colorId = 15; //グレー
string hatId = "";
string skinId = "";
string visorId = "";
string petId = "";
if (Utils.IsActive(SystemTypes.Comms))
{
if (Main.PlayerStates[id].IsDead) return;
}
if (!Utils.IsActive(SystemTypes.Comms) || ForceRevert)
{
var GetValue = Main.CheckShapeshift.TryGetValue(id, out var shapeshifting);
if (!GetValue && Main.CheckShapeshift.ContainsKey(id)) return;

var outfit = target.CurrentOutfit;
var value = PlayerSkins[id];

if (
outfit.ColorId == value.Item1 &&
outfit.HatId == value.Item2 &&
outfit.SkinId == value.Item3 &&
outfit.VisorId == value.Item4 &&
outfit.PetId == value.Item5
) return; //姿が変わっていないなら処理しない

colorId = shapeshifting ? outfit.ColorId : value.Item1;
hatId = shapeshifting ? outfit.HatId : value.Item2;
skinId = shapeshifting ? outfit.SkinId : value.Item3;
visorId = shapeshifting ? outfit.VisorId : value.Item4;
petId = shapeshifting ? outfit.PetId : value.Item5;
}

var sender = CustomRpcSender.Create(name: $"Camouflage.RpcSetSkin({target.Data.PlayerName})");

target.SetColor(colorId);
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetColor)
.Write(colorId)
.EndRpc();

target.SetHat(hatId, colorId);
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetHatStr)
.Write(hatId)
.EndRpc();

target.SetSkin(skinId, colorId);
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetSkinStr)
.Write(skinId)
.EndRpc();

target.SetVisor(visorId, colorId);
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetVisorStr)
.Write(visorId)
.EndRpc();

target.SetPet(petId);
sender.AutoStartRpc(target.NetId, (byte)RpcCalls.SetPetStr)
.Write(petId)
.EndRpc();

sender.SendMessage();
}
}
}
Loading

0 comments on commit 6bfc3db

Please sign in to comment.