Skip to content

Commit

Permalink
merge:develop
Browse files Browse the repository at this point in the history
  • Loading branch information
yukieiji committed Dec 15, 2024
2 parents d285a8e + bd0838f commit 3ddb4a1
Show file tree
Hide file tree
Showing 79 changed files with 4,472 additions and 185 deletions.
16 changes: 16 additions & 0 deletions ExtremeRoles.Test/Asset/FakerAssetLoadRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using ExtremeRoles.Resources;
using ExtremeRoles.Roles;

namespace ExtremeRoles.Test.Asset;

internal sealed class FakerAssetLoadRunner
: AssetLoadRunner
{
public override void Run()
{
Log.LogInfo($"----- Unit:FakerAsset Test -----");

LoadFromExR(ExtremeRoleId.Faker, ObjectPath.FakerDummyPlayer);
LoadFromExR(ExtremeRoleId.Faker, ObjectPath.FakerDummyDeadBody);
}
}
14 changes: 14 additions & 0 deletions ExtremeRoles.Test/Asset/GlitchAssetLoadRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using ExtremeRoles.Roles;

namespace ExtremeRoles.Test.Asset;

internal sealed class GlitchAssetLoadRunner
: AssetLoadRunner
{
public override void Run()
{
Log.LogInfo($"----- Unit:GlitchAsset Test -----");

LoadFromExR(ExtremeRoleId.Glitch);
}
}
14 changes: 14 additions & 0 deletions ExtremeRoles.Test/Asset/HijackerAssetLoadRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using ExtremeRoles.Roles;

namespace ExtremeRoles.Test.Asset;

internal sealed class HijackerAssetLoadRunner
: AssetLoadRunner
{
public override void Run()
{
Log.LogInfo($"----- Unit:HijackerAsset Test -----");

LoadFromExR(ExtremeRoleId.Hijacker);
}
}
14 changes: 14 additions & 0 deletions ExtremeRoles.Test/Asset/RaiderAssetLoadRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using ExtremeRoles.Roles;

namespace ExtremeRoles.Test.Asset;

internal sealed class RaiderAssetLoadRunner
: AssetLoadRunner
{
public override void Run()
{
Log.LogInfo($"----- Unit:RaiderAsset Test -----");

LoadFromExR(ExtremeRoleId.Raider);
}
}
14 changes: 14 additions & 0 deletions ExtremeRoles.Test/Asset/TimeBreakerAssetLoadRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using ExtremeRoles.Roles;

namespace ExtremeRoles.Test.Asset;

internal sealed class TimeBreakerAssetLoadRunner
: AssetLoadRunner
{
public override void Run()
{
Log.LogInfo($"----- Unit:TimeBreakerAsset Test -----");

LoadFromExR(ExtremeRoleId.TimeBreaker);
}
}
5 changes: 5 additions & 0 deletions ExtremeRoles.Test/AssetLoadRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ public override void Run()
Run<JailerAssetLoadRunner>();
Run<SummonerAssetLoadRunner>();

Run<FakerAssetLoadRunner>();
Run<MeryAssetLoadRunner>();
Run<HypnotistAssetLoadRunner>();
Run<ThiefAssetLoadRunner>();
Run<TeroAssetLoadRunner>();
Run<ZombieAssetLoadRunner>();
Run<GlitchAssetLoadRunner>();
Run<TimeBreakerAssetLoadRunner>();
Run<RaiderAssetLoadRunner>();
Run<HijackerAssetLoadRunner>();

Run<TuckerAssetLoadRunner>();
Run<YokoAssetLoadRunner>();
Expand Down
10 changes: 5 additions & 5 deletions ExtremeRoles.Test/TranslationTestRunner.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExtremeRoles.Test;

Expand All @@ -13,9 +11,11 @@ public override void Run()
var allTrans = TranslationController.Instance.currentLanguage.AllStrings;
var valKeys = new Dictionary<string, HashSet<string>>(allTrans.Count);


foreach (var (key, val) in allTrans)
foreach (var item in allTrans)
{
string key = item.Key;
string val = item.Value;

if (valKeys.TryGetValue(val, out var set) &&
set is not null)
{
Expand Down
21 changes: 21 additions & 0 deletions ExtremeRoles/Extension/LinqExtend.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;

#nullable enable

Expand All @@ -12,6 +13,26 @@ public static T GetRandomItem<T>(this IReadOnlyList<T> self)
int index = RandomGenerator.Instance.Next(size);
return self[index];
}

public static IEnumerable<T> GetRandomItem<T>(this IReadOnlyList<T> self, int num)
{
if (self.Count >= num)
{
return self.OrderBy(x => RandomGenerator.Instance.Next()).Take(num);

}

return sizedRandom(self, num);
}

private static IEnumerable<T> sizedRandom<T>(IReadOnlyList<T> self, int num)
{
for (int i = 0; i < num; ++i)
{
yield return self.GetRandomItem();
}
}

public static T GetRandomItem<T>(this T[] self)
{
int size = self.Length;
Expand Down
6 changes: 6 additions & 0 deletions ExtremeRoles/Extension/PlayerControlExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ public static void MurderPlayer(this PlayerControl source, PlayerControl target)
{
source.MurderPlayer(target, MurderResultFlags.Succeeded | MurderResultFlags.DecisionByHost);
}
public static bool IsValid(this PlayerControl @this)
=>
@this != null &&
@this.Data != null &&
!@this.Data.IsDead && !@this.Data.Disconnected;

}
6 changes: 3 additions & 3 deletions ExtremeRoles/ExtremeRoles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<WarningLevel>7</WarningLevel>
<Version>12.0.2.4</Version>
<!--<VersionPrefix>12.0.2</VersionPrefix>-->
<VersionSuffix>Invitation-AmongUsV2024813</VersionSuffix>
<!--<Version>12.1.0.0</Version>-->
<VersionPrefix>12.1.0</VersionPrefix>
<VersionSuffix>3rdAnniversary</VersionSuffix>
<Description>Extreme Roles for Advanced user</Description>
<Authors>yukieiji</Authors>
<Configurations>Debug;Release</Configurations>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

using ExtremeRoles.GhostRoles;
using ExtremeRoles.Roles;
using ExtremeRoles.Roles.API;


namespace ExtremeRoles.GameMode.RoleSelector;

Expand Down Expand Up @@ -126,6 +124,10 @@ private static ExtremeRoleId[] getUseNormalRoleId() =>
ExtremeRoleId.Thief,
ExtremeRoleId.Crewshroom,
ExtremeRoleId.Terorist,
ExtremeRoleId.Raider,
ExtremeRoleId.Glitch,
ExtremeRoleId.Hijacker,
ExtremeRoleId.TimeBreaker,

ExtremeRoleId.Alice,
ExtremeRoleId.Jackal,
Expand All @@ -143,6 +145,7 @@ private static ExtremeRoleId[] getUseNormalRoleId() =>
ExtremeRoleId.Hatter,
ExtremeRoleId.Artist,
ExtremeRoleId.Tucker,
ExtremeRoleId.IronMate,
];

private CombinationRoleType[] getUseCombRoleType() =>
Expand Down Expand Up @@ -175,8 +178,9 @@ private ExtremeGhostRoleId[] getUseGhostRoleId() =>
ExtremeGhostRoleId.Ventgeist,
ExtremeGhostRoleId.SaboEvil,
ExtremeGhostRoleId.Igniter,
ExtremeGhostRoleId.Doppelganger,

ExtremeGhostRoleId.Foras,
ExtremeGhostRoleId.Foras,
];
}

Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ private static ExtremeRoleId[] getUseNormalId() =>
ExtremeRoleId.Hypnotist,
ExtremeRoleId.Slime,
ExtremeRoleId.Terorist,
];
ExtremeRoleId.Raider,
ExtremeRoleId.Hijacker,
ExtremeRoleId.TimeBreaker,
];
private CombinationRoleType[] getUseCombRoleType() =>
[
CombinationRoleType.Accelerator,
Expand Down
43 changes: 37 additions & 6 deletions ExtremeRoles/GhostRoles/API/GhostRoleBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using ExtremeRoles.Roles.API.Interface;

using OptionFactory = ExtremeRoles.Module.CustomOption.Factory.AutoParentSetOptionCategoryFactory;
using ExtremeRoles.Performance;

namespace ExtremeRoles.GhostRoles.API;

Expand Down Expand Up @@ -222,7 +223,7 @@ protected void ButtonInit()
this.Button.OnMeetingEnd();
}

protected bool isReportAbility() => this.Loader.GetValue<GhostRoleOption, bool>(GhostRoleOption.IsReportAbility);
protected bool IsReportAbility() => this.Loader.GetValue<GhostRoleOption, bool>(GhostRoleOption.IsReportAbility);

private OptionFactory createOptionFactory()
{
Expand Down Expand Up @@ -259,11 +260,41 @@ private OptionFactory createOptionFactory()

protected abstract void UseAbility(RPCOperator.RpcCaller caller);

protected static bool IsCommonUse() =>
PlayerControl.LocalPlayer != null &&
PlayerControl.LocalPlayer.Data != null &&
PlayerControl.LocalPlayer.Data.IsDead &&
PlayerControl.LocalPlayer.CanMove;
protected static bool IsCommonUse()
{
var localPlayer = PlayerControl.LocalPlayer;

return
localPlayer != null &&
localPlayer.Data != null &&
localPlayer.Data.IsDead &&
localPlayer.CanMove;
}
protected static bool IsCommonUseWithMinigame()
{
var localPlayer = PlayerControl.LocalPlayer;
var hud = FastDestroyableSingleton<HudManager>.Instance;
return
!(
localPlayer == null ||
localPlayer.Data == null ||
!localPlayer.Data.IsDead ||
localPlayer.inVent ||
localPlayer.MyPhysics.DoingCustomAnimation ||
localPlayer.shapeshifting ||
localPlayer.waitingForShapeshiftResponse ||
hud == null ||
hud.Chat.IsOpenOrOpening ||
hud.KillOverlay.IsOpen ||
hud.GameMenu.IsOpen ||
hud.IsIntroDisplayed ||
(MapBehaviour.Instance != null && MapBehaviour.Instance.IsOpenStopped) ||
MeetingHud.Instance != null ||
PlayerCustomizationMenu.Instance != null ||
ExileController.Instance != null ||
IntroCutscene.Instance != null
);
}

protected static void EnumCheck<T>(T isEnum) where T : struct, IConvertible
{
Expand Down
2 changes: 1 addition & 1 deletion ExtremeRoles/GhostRoles/Crewmate/Faunus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override void CreateAbility()
AbilityType.FaunusOpenSaboConsole,
Resources.UnityObjectLoader.LoadSpriteFromResources(
Resources.ObjectPath.MaintainerRepair),
this.isReportAbility(),
this.IsReportAbility(),
this.isPreCheck,
this.isAbilityUse,
this.UseAbility,
Expand Down
2 changes: 1 addition & 1 deletion ExtremeRoles/GhostRoles/Crewmate/Poltergeist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public override void CreateAbility()
AbilityType.PoltergeistMoveDeadbody,
Resources.UnityObjectLoader.LoadSpriteFromResources(
Resources.ObjectPath.CarrierCarry),
this.isReportAbility(),
this.IsReportAbility(),
this.isPreCheck,
this.isAbilityUse,
this.UseAbility,
Expand Down
2 changes: 1 addition & 1 deletion ExtremeRoles/GhostRoles/Crewmate/Shutter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public override void CreateAbility()
AbilityType.ShutterTakePhoto,
Resources.UnityObjectLoader.LoadSpriteFromResources(
Resources.ObjectPath.PhotographerPhotoCamera),
this.isReportAbility(),
this.IsReportAbility(),
() => true,
this.isAbilityUse,
this.UseAbility,
Expand Down
25 changes: 16 additions & 9 deletions ExtremeRoles/GhostRoles/ExtremeGhostRoleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public enum ExtremeGhostRoleId : byte
Ventgeist,
SaboEvil,
Igniter,
Doppelganger,

Foras,
Foras,
}

public enum AbilityType : byte
Expand All @@ -45,13 +46,13 @@ public enum AbilityType : byte
VentgeistVentAnime,
SaboEvilResetSabotageCool,
IgniterSwitchLight,
DoppelgangerDoppel,

ForasShowArrow
ForasShowArrow
}

public static class ExtremeGhostRoleManager
{
private const int ghostRoleOptionId = 25;
public const int IdOffset = 512;

public static Dictionary<byte, GhostRoleBase> GameRole = new Dictionary<byte, GhostRoleBase>();
Expand All @@ -63,11 +64,12 @@ public static readonly Dictionary<
{ ExtremeGhostRoleId.Faunus, new Faunus() },
{ ExtremeGhostRoleId.Shutter, new Shutter() },

{ ExtremeGhostRoleId.Ventgeist, new Ventgeist() },
{ ExtremeGhostRoleId.SaboEvil , new SaboEvil() },
{ ExtremeGhostRoleId.Igniter , new Igniter() },
{ ExtremeGhostRoleId.Ventgeist , new Ventgeist() },
{ ExtremeGhostRoleId.SaboEvil , new SaboEvil() },
{ ExtremeGhostRoleId.Igniter , new Igniter() },
{ ExtremeGhostRoleId.Doppelganger, new Doppelganger() },

{ ExtremeGhostRoleId.Foras , new Foras() },
{ ExtremeGhostRoleId.Foras , new Foras() },
};

private static readonly HashSet<RoleTypes> vanillaGhostRole = new HashSet<RoleTypes>()
Expand Down Expand Up @@ -270,10 +272,15 @@ public static void UseAbility(
case AbilityType.IgniterSwitchLight:
Igniter.SetVison(reader.ReadBoolean());
break;
case AbilityType.ForasShowArrow:
case AbilityType.DoppelgangerDoppel:
byte doppelgangerPlayerId = reader.ReadByte();
byte doppelTargetPlayerId = reader.ReadByte();
Doppelganger.Doppl(doppelgangerPlayerId, doppelTargetPlayerId);
break;
case AbilityType.ForasShowArrow:
Foras.SwitchArrow(ref reader);
break;
default:
default:
break;
}

Expand Down
Loading

0 comments on commit 3ddb4a1

Please sign in to comment.