Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
yukieiji committed Feb 17, 2024
2 parents 8af1747 + a844e52 commit 38df098
Show file tree
Hide file tree
Showing 66 changed files with 578 additions and 548 deletions.
2 changes: 1 addition & 1 deletion ExtremeRoles.Beta
2 changes: 1 addition & 1 deletion ExtremeRoles.Test/ExtremeRolesTestPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void Prefix(ChatController __instance)

GameUtility.ChangePresetTo(19);

var runner = new ImgLoadRunner();
var runner = new GameTestRunner();
runner.Run();
}
}
Expand Down
40 changes: 30 additions & 10 deletions ExtremeRoles.Test/GameTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,42 @@ public override void Run()
GameMudderEndTestingBehaviour.Instance.StartCoroutine(
GameMudderEndTestingBehaviour.Instance.Run(
new("Random", 3),
new("NeutralRemove", 5, new ()
{
new("IRoleAbilityRole", 5,
[
ExtremeRoleId.Carpenter,
ExtremeRoleId.BodyGuard,
ExtremeRoleId.SandWorm,
]),
new("IRoleAutoBuildAbilityRole", 5,
[
ExtremeRoleId.Hatter,
ExtremeRoleId.Eater,
ExtremeRoleId.Carrier,
ExtremeRoleId.Thief,
ExtremeRoleId.Traitor,
ExtremeRoleId.Teleporter,
ExtremeRoleId.Supervisor,
ExtremeRoleId.Psychic,
ExtremeRoleId.Mover,
]),
new("NeutralRemove", 5,
[
ExtremeRoleId.Jester, ExtremeRoleId.TaskMaster,
ExtremeRoleId.Neet, ExtremeRoleId.Umbrer,
ExtremeRoleId.Madmate
}),
new("YokoWin", 5, new() { ExtremeRoleId.Yoko },
]),
new("YokoWin", 5, [ ExtremeRoleId.Yoko ],
() =>
{
GameUtility.UpdateExROption(
new((int)GlobalOption.IsSameNeutralSameWin, 1));
}),
new("NeutralWin", 100,
new ()
{
[
ExtremeRoleId.Alice, ExtremeRoleId.Jackal,
ExtremeRoleId.Missionary, ExtremeRoleId.Miner,
ExtremeRoleId.Eater, ExtremeRoleId.Queen
},
],
() =>
{
GameUtility.UpdateExROption(
Expand All @@ -61,7 +78,7 @@ public override void Run()
new RequireOption<Int32OptionNames, int>(
Int32OptionNames.NumImpostors, 0));
}),
new("QueenWin", 100, new () { ExtremeRoleId.Queen },
new("QueenWin", 100, [ ExtremeRoleId.Queen ],
() =>
{
GameUtility.UpdateExROption(
Expand All @@ -70,13 +87,15 @@ public override void Run()
new RequireOption<Int32OptionNames, int>(
Int32OptionNames.NumImpostors, 3));
}),
new("YandereWin", 100, new HashSet<ExtremeRoleId>() { ExtremeRoleId.Yandere })));
new("YandereWin", 100, [ ExtremeRoleId.Yandere ])));
}
}
[Il2CppRegister]
public sealed class GameMudderEndTestingBehaviour : MonoBehaviour
{
public static bool Enable => instance != null;

public static GameMudderEndTestingBehaviour Instance
{
get
Expand Down Expand Up @@ -132,6 +151,7 @@ private IEnumerator runTestCase(GameTestRunner.TestCase testCase)
{
this.Logger.LogInfo("Wait for 30s");
GC.Collect();
Resources.Loader.ResetCache();
yield return UnityResource.UnloadUnusedAssets();
yield return new WaitForSeconds(30.0f);
this.count = 0;
Expand All @@ -142,7 +162,7 @@ private IEnumerator runTestCase(GameTestRunner.TestCase testCase)
while (GameUtility.IsContinue)
{
var player = CachedPlayerControl.AllPlayerControls.OrderBy(x => RandomGenerator.Instance.Next()).First();
if (!player.Data.IsDead || ExtremeRoleManager.GameRole[player.PlayerId].Id != ExtremeRoleId.Assassin)
if (!player.Data.IsDead && ExtremeRoleManager.GameRole[player.PlayerId].Id != ExtremeRoleId.Assassin)
{
Player.RpcUncheckMurderPlayer(player.PlayerId, player.PlayerId, byte.MinValue);
yield return new WaitForSeconds(1.0f);
Expand Down
13 changes: 7 additions & 6 deletions ExtremeRoles.Test/Helper/GameUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ public static void PrepereGameWithRandom(ManualLogSource logger)
opt.UpdateSelection(newIndex);
}

disableXion();

logger.LogInfo("Update Roles and Player....");
enableXion();

for (int playerId = 0; playerId < 15; ++playerId)
for (int playerId = 0; playerId < 14; ++playerId)
{
string playerName = $"TestPlayer_{playerId}";
logger.LogInfo($"spawn : {playerName}");
Expand Down Expand Up @@ -136,10 +137,10 @@ public static void PrepereGameWithRole(ManualLogSource logger, HashSet<ExtremeRo
opt.UpdateSelection(newIndex);
}

enableXion();
disableXion();

logger.LogInfo("Update Player....");
for (int playerId = 0; playerId < 15; ++playerId)
for (int playerId = 0; playerId < 14; ++playerId)
{
string playerName = $"TestPlayer_{playerId}";
logger.LogInfo($"Spawn : {playerName}");
Expand Down Expand Up @@ -177,10 +178,10 @@ public static void UpdateAmongUsOption(in RequireOption<FloatOptionNames, float>
}


private static void enableXion()
private static void disableXion()
{
OptionManager.Instance.GetIOption(
(int)RoleGlobalOption.UseXion).UpdateSelection(1);
(int)RoleGlobalOption.UseXion).UpdateSelection(0);
}

private static void enableRandomNormalRole(ManualLogSource logger)
Expand Down
57 changes: 57 additions & 0 deletions ExtremeRoles.Test/Patch/RoleManagerPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using HarmonyLib;
using AmongUs.GameOptions;

using ExtremeRoles.Module.RoleAssign;

namespace ExtremeRoles.Test.Patches.Manager;


[HarmonyPatch(typeof(RoleManager), nameof(RoleManager.SelectRoles))]
public static class RoleManagerSelectRolesPatch
{

public static void Prefix()
{
if (!GameMudderEndTestingBehaviour.Enable) { return; }

PlayerRoleAssignData assignData = PlayerRoleAssignData.Instance;

// ダミープレイヤーは役職がアサインされてないので無理やりアサインする
var allPlayer = assignData.NeedRoleAssignPlayer;

var gameOption = GameOptionsManager.Instance;
var currentOption = gameOption.CurrentGameOptions;

int adjustedNumImpostors = currentOption.GetAdjustedNumImpostors(allPlayer.Count);

var il2CppListPlayer = new Il2CppSystem.Collections.Generic.List<GameData.PlayerInfo>();

foreach (PlayerControl player in allPlayer)
{
il2CppListPlayer.Add(player.Data);
}

GameManager.Instance.LogicRoleSelection.AssignRolesForTeam(
il2CppListPlayer, currentOption, RoleTeamTypes.Impostor,
adjustedNumImpostors,
new Il2CppSystem.Nullable<RoleTypes>()
{
value = RoleTypes.Impostor,
has_value = true
});
GameManager.Instance.LogicRoleSelection.AssignRolesForTeam(
il2CppListPlayer, currentOption, RoleTeamTypes.Crewmate,
int.MaxValue,
new Il2CppSystem.Nullable<RoleTypes>()
{
value = RoleTypes.Crewmate,
has_value = true
});

// アサイン済みにする
foreach (PlayerControl player in allPlayer)
{
player.roleAssigned = true;
}
}
}
2 changes: 1 addition & 1 deletion ExtremeRoles/ExtremeRoles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<WarningLevel>7</WarningLevel>
<Version>9.2.3.2</Version>
<Version>9.2.3.3</Version>
<!--<VersionPrefix>9.2.3</VersionPrefix>-->
<VersionSuffix>PublicBeta</VersionSuffix>
<Description>Extreme Roles for Advanced user</Description>
Expand Down
7 changes: 6 additions & 1 deletion ExtremeRoles/Module/ExtremeAbilityButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ public void SetLabelToCrewmate()

public void Update()
{
if (!this.isShow || this.button == null) { return; }
if (!this.isShow ||
this.button == null ||
IntroCutscene.Instance != null)
{
return;
}

bool isActive = this.activator.IsActive();

Expand Down
7 changes: 7 additions & 0 deletions ExtremeRoles/Module/SystemType/RaiseHandSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,22 @@ public void Deserialize(MessageReader reader, bool initialState)
}
}

var downHand = new List<byte>(this.raisedHand.Count);
foreach (byte id in this.raisedHand.Keys)
{
if (!newRaiseHand.Remove(id) &&
this.allHand.TryGetValue(id, out var hand) &&
hand != null)
{
downHand.Add(id);
hand.Down();
}
}

foreach (byte id in downHand)
{
this.raisedHand.Remove(id);
}
}

public void Serialize(MessageWriter writer, bool initialState)
Expand Down
9 changes: 9 additions & 0 deletions ExtremeRoles/Resources/Loader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ public static class Path

public static class Loader
{
public static void ResetCache()
{
foreach(var bundle in cachedBundle.Values)
{
bundle.Unload(false);
}
cachedBundle.Clear();
cachedSprite.Clear();
}

private static readonly Dictionary<string, Sprite> cachedSprite = new Dictionary<string, Sprite> ();
private static readonly Dictionary<string, AssetBundle> cachedBundle = new Dictionary<string, AssetBundle>();
Expand Down
Loading

0 comments on commit 38df098

Please sign in to comment.