Skip to content

Commit

Permalink
Merge pull request #40 from Hyz-sui/work/Merge5.1.4
Browse files Browse the repository at this point in the history
5.1.3&&5.1.4マージ
  • Loading branch information
Hyz-sui authored Jan 30, 2024
2 parents cba6623 + a74dcd0 commit af364ed
Show file tree
Hide file tree
Showing 101 changed files with 2,952 additions and 1,733 deletions.
20 changes: 20 additions & 0 deletions Helpers/ColorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,31 @@ public static Color ToMarkingColor(this Color color, bool bright = true)
var markingColor = Color.HSVToRGB(h, MarkerSat, bright ? MarkerVal : v).SetAlpha(MarkerAlpha);
return markingColor;
}
/// <summary>白背景での可読性を保てる色に変換する</summary>
public static Color ToReadableColor(this Color color)
{
Color.RGBToHSV(color, out var h, out var s, out var v);
// 適切な彩度でない場合は彩度を変更
if (s < ReadableSat)
{
s = ReadableSat;
}
// 適切な明度でない場合は明度を変更
if (v > ReadableVal)
{
v = ReadableVal;
}
return Color.HSVToRGB(h, s, v);
}

/// <summary>マーカー色のS値 = 彩度</summary>
private const float MarkerSat = 1f;
/// <summary>マーカー色のV値 = 明度</summary>
private const float MarkerVal = 1f;
/// <summary>マーカー色のアルファ = 不透明度</summary>
private const float MarkerAlpha = 0.2f;
/// <summary>白背景テキスト色の最大S = 彩度</summary>
private const float ReadableSat = 0.8f;
/// <summary>白背景テキスト色の最大V = 明度</summary>
private const float ReadableVal = 0.8f;
}
10 changes: 9 additions & 1 deletion Helpers/CustomRolesHelper.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using AmongUs.GameOptions;

using TownOfHost.Roles.Core;
Expand All @@ -6,7 +7,14 @@ namespace TownOfHost
{
static class CustomRolesHelper
{
public static readonly CustomRoles[] AllRoles = EnumHelper.GetAllValues<CustomRoles>();
/// <summary>すべての役職(属性は含まない)</summary>
public static readonly CustomRoles[] AllRoles = EnumHelper.GetAllValues<CustomRoles>().Where(role => role < CustomRoles.NotAssigned).ToArray();
/// <summary>すべての属性</summary>
public static readonly CustomRoles[] AllAddOns = EnumHelper.GetAllValues<CustomRoles>().Where(role => role > CustomRoles.NotAssigned).ToArray();
/// <summary>スタンダードモードで出現できるすべての役職</summary>
public static readonly CustomRoles[] AllStandardRoles = AllRoles.Where(role => role is not (CustomRoles.HASFox or CustomRoles.HASTroll)).ToArray();
/// <summary>HASモードで出現できるすべての役職</summary>
public static readonly CustomRoles[] AllHASRoles = { CustomRoles.HASFox, CustomRoles.HASTroll };
public static readonly CustomRoleTypes[] AllRoleTypes = EnumHelper.GetAllValues<CustomRoleTypes>();

public static bool IsImpostor(this CustomRoles role)
Expand Down
Binary file added Images/Airship_Random_Map_en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Airship_Random_Map_ja.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Fungle_Random_Map_en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Fungle_Random_Map_ja.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/MIRA_HQ_Random_Map.png
Binary file not shown.
Binary file removed Images/Mira_HQ_Random_Map.png
Binary file not shown.
Binary file added Images/Mirahq_Random_Map_en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Mirahq_Random_Map_ja.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/Polus_Random_Map.png
Binary file not shown.
Binary file added Images/Polus_Random_Map_en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Polus_Random_Map_ja.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Skeld_Random_Map_en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Skeld_Random_Map_ja.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/The_Airship_Random_Map.png
Binary file not shown.
Binary file removed Images/The_Skeld_Random_Map.png
Binary file not shown.
18 changes: 15 additions & 3 deletions Modules/Camouflague.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using HarmonyLib;
using TownOfHost.Attributes;

namespace TownOfHost
Expand Down Expand Up @@ -53,7 +52,16 @@ public static void CheckCamouflage()

if (oldIsCamouflage != IsCamouflage)
{
Main.AllPlayerControls.Do(pc => Camouflage.RpcSetSkin(pc));
foreach (var pc in Main.AllPlayerControls)
{
RpcSetSkin(pc);

// The code is intended to remove pets at dead players to combat a vanilla bug
if (!IsCamouflage && !pc.IsAlive())
{
pc.RpcSetPet("");
}
}
Utils.NotifyRoles(NoCache: true);
}
}
Expand Down Expand Up @@ -86,6 +94,10 @@ public static void RpcSetSkin(PlayerControl target, bool ForceRevert = false, bo

newOutfit = PlayerSkins[id];
}


if (newOutfit.Compare(target.Data.DefaultOutfit)) return;

Logger.Info($"newOutfit={newOutfit.GetString()}", "RpcSetSkin");

var sender = CustomRpcSender.Create(name: $"Camouflage.RpcSetSkin({target.Data.PlayerName})");
Expand Down Expand Up @@ -118,4 +130,4 @@ public static void RpcSetSkin(PlayerControl target, bool ForceRevert = false, bo
sender.SendMessage();
}
}
}
}
1 change: 1 addition & 0 deletions Modules/CustomRpcSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ public static void RpcMurderPlayer(this CustomRpcSender sender, PlayerControl pl
{
sender.AutoStartRpc(player.NetId, (byte)RpcCalls.MurderPlayer, targetClientId)
.WriteNetObject(target)
.Write((int)ExtendedPlayerControl.SucceededFlags)
.EndRpc();
}
}
Expand Down
44 changes: 22 additions & 22 deletions Modules/CustomWinnerHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public static class CustomWinnerHolder
// リザルトの背景色の決定などに使用されます。
// 注: この変数を変更する時、WinnerRoles・WinnerIdsを同時に変更しないと予期せぬ勝者が現れる可能性があります。
public static CustomWinner WinnerTeam;
// 追加勝利するプレイヤーのチームが格納されます
// 追加勝利するプレイヤーの役職が格納されます
// リザルトの表示に使用されます。
public static HashSet<AdditionalWinners> AdditionalWinnerTeams;
public static HashSet<CustomRoles> AdditionalWinnerRoles;
// 勝者の役職が格納され、この変数に格納されている役職のプレイヤーは全員勝利となります。
// チームとなるニュートラルの処理に最適です。
public static HashSet<CustomRoles> WinnerRoles;
Expand All @@ -26,7 +26,7 @@ public static class CustomWinnerHolder
public static void Reset()
{
WinnerTeam = CustomWinner.Default;
AdditionalWinnerTeams = new();
AdditionalWinnerRoles = new();
WinnerRoles = new();
WinnerIds = new();
}
Expand All @@ -35,17 +35,17 @@ public static void ClearWinners()
WinnerRoles.Clear();
WinnerIds.Clear();
}
/// <summary><para>WinnerTeamに値を代入します。</para><para>すでに代入されている場合、AdditionalWinnerTeamsに追加します。</para></summary>
/// <summary><para>WinnerTeamに値を代入します。</para><para>すでに代入されている場合、AdditionalWinnerRolesに追加します。</para></summary>
public static void SetWinnerOrAdditonalWinner(CustomWinner winner)
{
if (WinnerTeam == CustomWinner.Default) WinnerTeam = winner;
else AdditionalWinnerTeams.Add((AdditionalWinners)winner);
else AdditionalWinnerRoles.Add((CustomRoles)winner);
}
/// <summary><para>WinnerTeamに値を代入します。</para><para>すでに代入されている場合、既存の値をAdditionalWinnerTeamsに追加してから代入します。</para></summary>
/// <summary><para>WinnerTeamに値を代入します。</para><para>すでに代入されている場合、既存の値をAdditionalWinnerRolesに追加してから代入します。</para></summary>
public static void ShiftWinnerAndSetWinner(CustomWinner winner)
{
if (WinnerTeam != CustomWinner.Default)
AdditionalWinnerTeams.Add((AdditionalWinners)WinnerTeam);
AdditionalWinnerRoles.Add((CustomRoles)WinnerTeam);
WinnerTeam = winner;
}
/// <summary><para>既存の値をすべて削除してから、WinnerTeamに値を代入します。</para></summary>
Expand All @@ -57,38 +57,38 @@ public static void ResetAndSetWinner(CustomWinner winner)

public static MessageWriter WriteTo(MessageWriter writer)
{
writer.Write((int)WinnerTeam);
writer.WritePacked((int)WinnerTeam);

writer.Write(AdditionalWinnerTeams.Count);
foreach (var wt in AdditionalWinnerTeams)
writer.Write((int)wt);
writer.WritePacked(AdditionalWinnerRoles.Count);
foreach (var wr in AdditionalWinnerRoles)
writer.WritePacked((int)wr);

writer.Write(WinnerRoles.Count);
writer.WritePacked(WinnerRoles.Count);
foreach (var wr in WinnerRoles)
writer.Write((int)wr);
writer.WritePacked((int)wr);

writer.Write(WinnerIds.Count);
writer.WritePacked(WinnerIds.Count);
foreach (var id in WinnerIds)
writer.Write(id);

return writer;
}
public static void ReadFrom(MessageReader reader)
{
WinnerTeam = (CustomWinner)reader.ReadInt32();
WinnerTeam = (CustomWinner)reader.ReadPackedInt32();

AdditionalWinnerTeams = new();
int AdditionalWinnerTeamsCount = reader.ReadInt32();
for (int i = 0; i < AdditionalWinnerTeamsCount; i++)
AdditionalWinnerTeams.Add((AdditionalWinners)reader.ReadInt32());
AdditionalWinnerRoles = new();
int AdditionalWinnerRolesCount = reader.ReadPackedInt32();
for (int i = 0; i < AdditionalWinnerRolesCount; i++)
AdditionalWinnerRoles.Add((CustomRoles)reader.ReadPackedInt32());

WinnerRoles = new();
int WinnerRolesCount = reader.ReadInt32();
int WinnerRolesCount = reader.ReadPackedInt32();
for (int i = 0; i < WinnerRolesCount; i++)
WinnerRoles.Add((CustomRoles)reader.ReadInt32());
WinnerRoles.Add((CustomRoles)reader.ReadPackedInt32());

WinnerIds = new();
int WinnerIdsCount = reader.ReadInt32();
int WinnerIdsCount = reader.ReadPackedInt32();
for (int i = 0; i < WinnerIdsCount; i++)
WinnerIds.Add(reader.ReadByte());
}
Expand Down
22 changes: 4 additions & 18 deletions Modules/DeviceTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public static bool CamerasRanOut
private set => camerasRanOut = value;
}
private static bool camerasRanOut;
private static int NumPlayersWatchingCamera => playersWatchingCamera.Count;
private static HashSet<byte> playersWatchingCamera;
private static int NumPlayersWatchingCamera => ShipStatus.Instance.Systems.TryGetValue(SystemTypes.Security, out var system)
? system.TryCast<SecurityCameraSystemType>(out var securitySystem)
? securitySystem.PlayersUsing.Count : 0
: 0;
private static bool isEnabled;
private static float camerasRemaining;
private static string notifyText;
Expand All @@ -24,7 +26,6 @@ public static bool CamerasRanOut
public static void Init()
{
CamerasRanOut = false;
playersWatchingCamera = new();
isEnabled = Options.CamerasTimer.GetBool();
camerasRemaining = Options.CamerasMaxTimer.GetInt();
UpdateNotifyText();
Expand All @@ -49,24 +50,9 @@ public static void HandleRepairSystem(SystemTypes systemType, PlayerControl play
}
public static void BeginCamera(PlayerControl player)
{
if (!AmongUsClient.Instance.AmHost || !isEnabled)
{
return;
}
playersWatchingCamera.Add(player.PlayerId);
Logger.Info($"Begin: {System.DateTime.Now:HH:mm:ss}", nameof(DeviceTimer));
}
public static void CloseCamera(PlayerControl player)
{
if (!AmongUsClient.Instance.AmHost || !isEnabled)
{
return;
}
if (playersWatchingCamera.Contains(player.PlayerId))
{
playersWatchingCamera.Remove(player.PlayerId);
Logger.Info($"Close: {System.DateTime.Now:HH:mm:ss}", nameof(DeviceTimer));
}
}
public static void ConsumeCamera()
{
Expand Down
24 changes: 19 additions & 5 deletions Modules/DisableDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class DisableDevice
["AirshipCockpitAdmin"] = new(-22.32f, 0.91f),
["AirshipRecordsAdmin"] = new(19.89f, 12.60f),
["AirshipCamera"] = new(8.10f, -9.63f),
["AirshipVital"] = new(25.24f, -7.94f)
["AirshipVital"] = new(25.24f, -7.94f),
["FungleVital"] = new(-2.765f, -9.819f)
};
public static float UsableDistance()
{
Expand All @@ -40,6 +41,7 @@ public static float UsableDistance()
MapNames.Polus => 1.8f,
//MapNames.Dleks => 1.5f,
MapNames.Airship => 1.8f,
MapNames.Fungle => 1.8f,
_ => 0.0f
};
}
Expand Down Expand Up @@ -100,6 +102,12 @@ public static void FixedUpdate()
if (Options.DisableAirshipVital.GetBool())
doComms |= Vector2.Distance(PlayerPos, DevicePos["AirshipVital"]) <= UsableDistance();
break;
case 5:
if (Options.DisableFungleVital.GetBool())
{
doComms |= Vector2.Distance(PlayerPos, DevicePos["FungleVital"]) <= UsableDistance();
}
break;
}
}
doComms &= !ignore;
Expand All @@ -108,15 +116,15 @@ public static void FixedUpdate()
if (!DesyncComms.Contains(pc.PlayerId))
DesyncComms.Add(pc.PlayerId);

pc.RpcDesyncRepairSystem(SystemTypes.Comms, 128);
pc.RpcDesyncUpdateSystem(SystemTypes.Comms, 128);
}
else if (!Utils.IsActive(SystemTypes.Comms) && DesyncComms.Contains(pc.PlayerId))
{
DesyncComms.Remove(pc.PlayerId);
pc.RpcDesyncRepairSystem(SystemTypes.Comms, 16);
pc.RpcDesyncUpdateSystem(SystemTypes.Comms, 16);

if (Main.NormalOptions.MapId == 1)
pc.RpcDesyncRepairSystem(SystemTypes.Comms, 17);
if (Main.NormalOptions.MapId is 1 or 5)
pc.RpcDesyncUpdateSystem(SystemTypes.Comms, 17);
}
}
catch (Exception ex)
Expand Down Expand Up @@ -182,6 +190,12 @@ public static void UpdateDisableDevices()
if (Options.DisableAirshipVital.GetBool())
consoles.DoIf(x => x.name == "panel_vitals", x => x.gameObject.GetComponent<CircleCollider2D>().enabled = ignore);
break;
case 5:
if (Options.DisableFungleVital.GetBool())
{
consoles.DoIf(x => x.name == "VitalsConsole", x => x.GetComponent<Collider2D>().enabled = ignore);
}
break;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions Modules/DoorsReset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public static class DoorsReset
[GameModuleInitializer]
public static void Initialize()
{
// AirshipとPolus以外は非対応
if ((MapNames)Main.NormalOptions.MapId is not (MapNames.Airship or MapNames.Polus))
// AirshipとPolusとFungle以外は非対応
if ((MapNames)Main.NormalOptions.MapId is not (MapNames.Airship or MapNames.Polus or MapNames.Fungle))
{
isEnabled = false;
return;
Expand Down Expand Up @@ -72,7 +72,7 @@ private static void OpenOrCloseAllDoorsRandomly()
/// <summary>ドアの開閉状況を設定する.サボタージュで閉められないドアに対しては何もしない</summary>
/// <param name="door">対象のドア</param>
/// <param name="isOpen">開けるならtrue,閉めるならfalse</param>
private static void SetDoorOpenState(PlainDoor door, bool isOpen)
private static void SetDoorOpenState(OpenableDoor door, bool isOpen)
{
if (IsValidDoor(door))
{
Expand All @@ -81,7 +81,7 @@ private static void SetDoorOpenState(PlainDoor door, bool isOpen)
}
/// <summary>リセット対象のドアかどうか判定する</summary>
/// <returns>リセット対象ならtrue</returns>
private static bool IsValidDoor(PlainDoor door)
private static bool IsValidDoor(OpenableDoor door)
{
// エアシラウンジトイレとPolus除染室のドアは対象外
if (door.Room is SystemTypes.Lounge or SystemTypes.Decontamination)
Expand Down
1 change: 1 addition & 0 deletions Modules/ErrorText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public enum ErrorCode
// ==========
// 001 Main
Main_DictionaryError = 0010003, // 001-000-3 Main Dictionary Error
OptionIDDuplicate = 001_010_3, // 001-010-3 オプションIDが重複している(DEBUGビルド時のみ)
// 002 サポート関連
UnsupportedVersion = 002_000_1, // 002-000-1 AmongUsのバージョンが古い
// ==========
Expand Down
Loading

0 comments on commit af364ed

Please sign in to comment.