Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Final commit for 1.0 :)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImaMapleTree committed Jun 16, 2023
1 parent 6435303 commit b003c7b
Show file tree
Hide file tree
Showing 99 changed files with 293 additions and 87 deletions.
3 changes: 3 additions & 0 deletions ProjectLotus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using VentLib.Networking.RPC;
using VentLib.Options.Game;
using VentLib.Utilities;
using VentLib.Utilities.Debug.Profiling;
using VentLib.Utilities.Optionals;
using VentLib.Version;
using VentLib.Version.Git;
Expand Down Expand Up @@ -78,6 +79,8 @@ public ProjectLotus()
ModUpdater = ModUpdater.Default();
ModUpdater.EstablishConnection();
ModUpdater.RegisterReleaseCallback(BeginUpdate, true);

Profilers.Global.SetActive(false);
}

private void BeginUpdate(Release release)
Expand Down
Binary file added assets/CircleButtonBack.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 assets/Content/Results_Icon.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 assets/HighRes/Crewmate_HighRes2.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 assets/HighRes/HideAndSeek_HighRes.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 assets/HighRes/TabIcon_ColorWras.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 assets/HighRes/TabIcon_FreeForAll.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 assets/HintButton.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 assets/HistoryMenu/ResultsIcon.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 assets/LotusBanner.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 assets/LotusBanner1.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 assets/Lotus_Icon.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 assets/Settings/AddonBlank.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 assets/Settings/AddonButton.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 assets/Settings/AddonSettings.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 assets/Settings/ExitBlank.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 assets/Settings/ExitButton.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 assets/Settings/ExitIcon.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 assets/Settings/GeneralBlank.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 assets/Settings/GeneralButton.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 assets/Settings/GeneralSettings.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 assets/Settings/GraphicBlank.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 assets/Settings/GraphicSettings.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 assets/Settings/GraphicsButton.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 assets/Settings/MenuBackground.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 assets/Settings/ProgressBarFill.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 assets/Settings/ProgressBarMask.png
Binary file added assets/Settings/ReturnBlank.png
Binary file added assets/Settings/ReturnButton.png
Binary file added assets/Settings/ReturnIcon.png
Binary file added assets/Settings/SelectButton.png
Binary file added assets/Settings/SoundBlank.png
Binary file added assets/Settings/SoundButton.png
Binary file added assets/Settings/SoundSettings.png
Binary file added assets/Settings/UnselectButton.png
Binary file added assets/Settings/UpdateMenuBackground.png
Binary file added assets/Settings/VentButton.png
Binary file added assets/Settings/VentLibBlank.png
Binary file added assets/Settings/VentLibSettings.png
Binary file added assets/TOHTORBackground.png
Binary file added assets/TabIcons/ColorWarsIcon.png
Binary file added assets/TabIcons/CrewmatesIcon.png
Binary file added assets/TabIcons/GeneralIcon.png
Binary file added assets/TabIcons/HideAndSeekIcon.png
Binary file added assets/TabIcons/ImpostorsIcon.png
Binary file added assets/TabIcons/ImpostorsIcon1.png
Binary file added assets/TabIcons/ImpostorsIcon2.png
Binary file added assets/TabIcons/MiscIcon.png
Binary file added assets/TabIcons/NeutralsIcon.png
Binary file added assets/Tabs/HideAndSeek_HighRes.png
Binary file added assets/Tabs/among-us-6008615_1280.webp
Binary file not shown.
5 changes: 5 additions & 0 deletions assets/Tabs/primether5348.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type:sforce
code:primether#5348
color:#FF0000
toptext:<color=#FF0000>YouTuber</color>
name:<color=#D7F2FF>An</color><color=#B8DEFC>on</color><color=#94C4F9>W</color><color=#73AEF6>or</color><color=#5096F2>ks</color>
Binary file added assets/arlrdbd.ttf
Binary file not shown.
Binary file added assets/main_menu/AnnouncementIconRedone.png
Binary file added assets/main_menu/InventoryIconRedone.png
Binary file added assets/main_menu/LittleDudeIcon.png
Binary file added assets/main_menu/ShopIconRedone.png
Binary file added assets/main_menu/discord_button_icon.png
4 changes: 2 additions & 2 deletions src/API/Odyssey/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static IEnumerable<PlayerControl> FindAlivePlayersWithRole(params CustomR
public static void TriggerForAll(RoleActionType action, ref ActionHandle handle, params object[] parameters)
{
List<PlayerControl> players = Players.GetPlayers().ToList();
VentLogger.Debug($"TriggerForAll - Players => {players.Select(p => p.name).Fuse()}");
/*VentLogger.Debug($"TriggerForAll - Players => {players.Select(p => p.name).Fuse()}");*/
players.Trigger(action, ref handle, parameters);
}

Expand All @@ -87,7 +87,7 @@ public static void Trigger(this IEnumerable<PlayerControl> players, RoleActionTy
parameters = parameters.AddToArray(handle);
List<(RoleAction, AbstractBaseRole)> actionList = allPlayers.SelectMany(p => p.GetCustomRole().GetActions(action)).ToList();
actionList.AddRange(allPlayers.SelectMany(p => p.GetSubroles().SelectMany(r => r.GetActions(action))));
VentLogger.Debug($"All Actions: {actionList.Select(a => a.Item1.ToString()).Fuse()}");
/*VentLogger.Debug($"All Actions: {actionList.Select(a => a.Item1.ToString()).Fuse()}");*/
foreach ((RoleAction roleAction, AbstractBaseRole role) in actionList.OrderBy(a1 => a1.Item1.Priority))
{
if (role.MyPlayer == null || !role.MyPlayer.IsAlive() && !roleAction.TriggerWhenDead) return;
Expand Down
19 changes: 15 additions & 4 deletions src/API/Odyssey/MatchData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
using System.Collections.Generic;
using System.Linq;
using Lotus.API.Player;
using Lotus.API.Reactive;
using Lotus.API.Reactive.HookEvents;
using Lotus.Extensions;
using Lotus.Managers;
using Lotus.Managers.History;
using Lotus.Roles;
using Lotus.Roles.Overrides;
using Lotus.RPC;
using Lotus.Statuses;
using MonoMod.RuntimeDetour;
using VentLib.Networking.RPC.Attributes;
using VentLib.Utilities.Collections;
using VentLib.Utilities.Extensions;
Expand All @@ -29,8 +32,6 @@ public class MatchData
public int MeetingsCalled;
public int EmergencyButtonsUsed;

public Dictionary<byte, RemoteList<IStatus>> Statuses = new();


public RoleData Roles = new();

Expand Down Expand Up @@ -91,8 +92,18 @@ public static void AssignSubrole(PlayerControl player, CustomRole role, bool sen
if (sendToClient) role.Assign();
}

public static RemoteList<IStatus> GetStatuses(PlayerControl player)
public static RemoteList<IStatus>? GetStatuses(PlayerControl player)
{
return player == null ? new RemoteList<IStatus>() : Game.MatchData.Statuses.GetOrCompute(player.PlayerId, () => new RemoteList<IStatus>());
return Game.MatchData.FrozenPlayers.GetOptional(player.GetGameID()).Map(fp => fp.Statuses).OrElse(null!);
}

public static Remote<IStatus>? AddStatus(PlayerControl player, IStatus status, PlayerControl? infector = null)
{
return Game.MatchData.FrozenPlayers.GetOptional(player.GetGameID()).Map(fp => fp.Statuses).Transform(statuses =>
{
Remote<IStatus> remote = statuses.Add(status);
Hooks.ModHooks.StatusReceivedHook.Propagate(new PlayerStatusReceivedHook(player, status, infector));
return remote;
}, () => null!);
}
}
3 changes: 2 additions & 1 deletion src/API/Player/FrozenPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Lotus.Roles;
using Lotus.Statuses;
using Lotus.Utilities;
using VentLib.Utilities.Collections;
using VentLib.Utilities.Extensions;
using static GameData;

Expand All @@ -19,7 +20,7 @@ public class FrozenPlayer
public string ColorName;
public CustomRole Role;
public List<CustomRole> Subroles;
public List<IStatus> Statuses;
public RemoteList<IStatus> Statuses = new RemoteList<IStatus>();
public uint Level;
public PlayerOutfit Outfit;
public ulong GameID;
Expand Down
4 changes: 2 additions & 2 deletions src/API/Reactive/HookEvents/PlayerStatusReceivedHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ namespace Lotus.API.Reactive.HookEvents;

public class PlayerStatusReceivedHook: PlayerHookEvent
{
public PlayerControl Infector;
public PlayerControl? Infector;
public IStatus Status;

public PlayerStatusReceivedHook(PlayerControl target, PlayerControl infector, IStatus status) : base(target)
public PlayerStatusReceivedHook(PlayerControl target, IStatus status, PlayerControl? infector = null) : base(target)
{
Infector = infector;
Status = status;
Expand Down
1 change: 1 addition & 0 deletions src/API/Reactive/Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static class ResultHooks
{
public static readonly Hook<WinnersHookEvent> WinnersHook = new SimpleHook<WinnersHookEvent>();
public static readonly Hook<LosersHookEvent> LosersHook = new SimpleHook<LosersHookEvent>();
public static readonly Hook<EmptyHookEvent> ForceEndGameHook = new SimpleHook<EmptyHookEvent>();
}

public static class NetworkHooks
Expand Down
9 changes: 4 additions & 5 deletions src/Chat/ChatHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public static void Send(PlayerControl? player, string message, string? title = n

title ??= _defaultTitle;

DevLogger.Log($"Player: {player} || NUll: {player == null}");
if (player == null) MassSend(sender, message, title, leftAligned);
else if (player.IsHost()) SendToHost(sender, message, title, leftAligned);
else if (title.Length < _maxMessagePacketSize) InternalSendLM(sender, player, message, title, name);
Expand Down Expand Up @@ -156,7 +155,7 @@ private static void InternalSendLM(PlayerControl sender, PlayerControl recipient

RpcV3.Mass()
.Start(sender.NetId, RpcCalls.SetName)
.Write(title)
.Write(title.Replace("@n", "\n"))
.End()
.Start(sender.NetId, RpcCalls.SendChat)
.Write(recipient.IsModded() ? subMessage : subMessage.RemoveHtmlTags())
Expand All @@ -171,7 +170,7 @@ private static void InternalSendLM(PlayerControl sender, PlayerControl recipient

RpcV3.Mass()
.Start(sender.NetId, RpcCalls.SetName)
.Write(title)
.Write(title.Replace("@n", "\n"))
.End()
.Start(sender.NetId, RpcCalls.SendChat)
.Write(recipient.IsModded() ? message : message.RemoveHtmlTags())
Expand Down Expand Up @@ -201,7 +200,7 @@ private static void InternalSendLT(PlayerControl sender, PlayerControl recipient
.Write(subTitle)
.End()
.Start(sender.NetId, RpcCalls.SendChat)
.Write(recipient.IsModded() ? message : message.RemoveHtmlTags())
.Write(recipient.IsModded() ? message.Replace("@n", "\n") : message.RemoveHtmlTags().Replace("@n", "\n"))
.End()
.Start(sender.NetId, RpcCalls.SetName)
.Write(originalName)
Expand All @@ -216,7 +215,7 @@ private static void InternalSendLT(PlayerControl sender, PlayerControl recipient
.Write(title)
.End()
.Start(sender.NetId, RpcCalls.SendChat)
.Write(recipient.IsModded() ? message : message.RemoveHtmlTags())
.Write(recipient.IsModded() ? message.Replace("@n", "\n") : message.RemoveHtmlTags().Replace("@n", "\n"))
.End()
.Start(sender.NetId, RpcCalls.SetName)
.Write(originalName)
Expand Down
2 changes: 1 addition & 1 deletion src/Chat/Commands/BasicCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static void ListWinners(PlayerControl source)
if (Game.MatchData.GameHistory.LastWinners == null!) new ChatHandler()
.Title(t => t.Text(CommandError).Color(ModConstants.Palette.KillingColor).Build())
.LeftAlign()
.Message(LastResultCommand.LRTranslations.NoPreviousGameText)
.Message(NoPreviousGameText)
.Send(source);
else
{
Expand Down
2 changes: 2 additions & 0 deletions src/Chat/Commands/CommandTranslations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class CommandTranslations
[Localized(nameof(PlayerNotFoundText))] protected static string PlayerNotFoundText = "Player \"{0}\" not found.";
[Localized(nameof(CommandError))] protected static string CommandError = "⚠ Command Error ⚠";

[Localized(nameof(NoPreviousGameText))] public static string NoPreviousGameText = "No game played yet!";

[Localized("HostOptions")]
protected static class HostOptionTranslations
{
Expand Down
8 changes: 7 additions & 1 deletion src/Chat/Commands/DeathCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Lotus.API.Odyssey;
using System.Linq;
using Lotus.API.Odyssey;
using Lotus.API.Player;
using Lotus.Extensions;
using Lotus.Managers.History.Events;
Expand All @@ -17,6 +18,11 @@ public class DeathCommand: CommandTranslations, ICommandReceiver
{
public void Receive(PlayerControl source, CommandContext context)
{
if (!Game.MatchData.FrozenPlayers.Any())
{
ChatHandlers.InvalidCmdUsage(NoPreviousGameText).Send(source);
return;
}
if (source.IsAlive() && Game.State is not GameState.InLobby)
{
ChatHandlers.InvalidCmdUsage().LeftAlign().Message(Translations.CannotViewDeathWhileAlive).Send(source);
Expand Down
5 changes: 1 addition & 4 deletions src/Chat/Commands/LastResultCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static LastResultCommand()
[Command(CommandFlag.LobbyOnly, "last", "l", "lastresult")]
public static void LastGame(PlayerControl source, CommandContext context)
{
if (PlayerHistories == null) ErrorHandler(source).Message(LRTranslations.NoPreviousGameText).Send();
if (PlayerHistories == null) ErrorHandler(source).Message(NoPreviousGameText).Send();
else if (context.Args.Length == 0) GeneralResults(source);
else PlayerResults(source, context.Join());
}
Expand Down Expand Up @@ -161,9 +161,6 @@ private static Color StatusColor(PlayerStatus status)
[Localized("LastResults")]
public static class LRTranslations
{
[Localized(nameof(NoPreviousGameText))]
public static string NoPreviousGameText = "No game played yet!";

[Localized(nameof(RoleText))]
public static string RoleText = "<b>Role:</b> {0}";

Expand Down
5 changes: 4 additions & 1 deletion src/Chat/Commands/StatusCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public class StatusCommand: CommandTranslations
[Command("status")]
public static void StatusEntry(PlayerControl source, CommandContext context)
{
if (context.Args.Length == 0) DisplayPlayerStatus(source, Game.MatchData.FrozenPlayers[source.GetGameID()]);
if (!Game.MatchData.FrozenPlayers.Any()) ErrorHandler(source).Message(NoPreviousGameText).Send();
else if (context.Args.Length == 0) DisplayPlayerStatus(source, Game.MatchData.FrozenPlayers[source.GetGameID()]);
else
{
if (int.TryParse(context.Join(), out int id)) DisplayStatusFromID(source, id);
Expand Down Expand Up @@ -45,6 +46,8 @@ private static void DisplayStatusFromID(PlayerControl source, int id)
.Handle(fp => DisplayPlayerStatus(source, fp), () => CHandler(PlayerNotFoundText.Formatted(id)).Send(source));
}

private static ChatHandler ErrorHandler(PlayerControl source) => new ChatHandler().Title(t => t.Text(CommandError).Color(ModConstants.Palette.KillingColor).Build()).Player(source).LeftAlign();

private static ChatHandler CHandler(string message)
{
return ChatHandler.Of(message, new Color(0.71f, 1f, 0.44f).Colorize(Translations.StatusTitle)).LeftAlign();
Expand Down
8 changes: 5 additions & 3 deletions src/Managers/CustomRoleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using VentLib.Utilities.Attributes;
using VentLib.Utilities.Extensions;
using Medium = Lotus.Roles.RoleGroups.Crew.Medium;
using Pirate = Lotus.Roles.RoleGroups.Neutral.Pirate;

namespace Lotus.Managers;

Expand Down Expand Up @@ -153,7 +154,7 @@ public class StaticRoles
public Creeper Creeper = new Creeper();
public Disperser Disperser = new Disperser();
public Escapist Escapist = new Escapist();
public FireWorks FireWorks = new FireWorks();
/*public FireWorks FireWorks = new FireWorks();*/
public Freezer Freezer = new Freezer();
public Grenadier Grenadier = new Grenadier();
public IdentityThief IdentityThief = new IdentityThief();
Expand Down Expand Up @@ -252,14 +253,15 @@ public class StaticRoles
private CustomRole NEUTRAL_PASSIVE_TITLE = new EnforceFunctionOrderingRole(() => new GameOptionTitleBuilder().Title("<size=2.3>❀ Neutral Passive ❀</size>").Color(ModConstants.Palette.PassiveColor).Tab(DefaultTabs.NeutralTab).Build());

public Amnesiac Amnesiac = new Amnesiac();
public Archangel Archangel = new Archangel();
/*public Archangel Archangel = new Archangel();*/
public Copycat Copycat = new Copycat();
public Executioner Executioner = new Executioner();
public GuardianAngel GuardianAngel = new GuardianAngel();
/*public GuardianAngel GuardianAngel = new GuardianAngel();*/
public Hacker Hacker = new Hacker();
public Jester Jester = new Jester();
public Opportunist Opportunist = new Opportunist();
public Phantom Phantom = new Phantom();
public Pirate Pirate = new Pirate();
public Postman Postman = new Postman();
public SchrodingersCat SchrodingersCat = new SchrodingersCat();
public Survivor Survivor = new Survivor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class InlineConditionEvaluator
private const string MCH = "[Matches]";
private const string DMCH = "[!Matches]";

private static Regex _regex = new($@"(.*?)\s*({CEQ}|{CNE}|{EQ}|{NE}|{GT}|{LT}|{LTE}|{GTE}|\{CTN}|\{DCTN}|\{DMCH}|\{MCH})\s*(.*)");
private static Regex _regex = new($@"(.*?)\s*({CEQ}|{CNE}|{EQ}|{NE}|{GTE}|{LTE}|{LT}|{GT}|\{CTN}|\{DCTN}|\{DMCH}|\{MCH})\s*(.*)");


public static bool Evaluate(string inlineCondition, object? obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public bool VerifyPlayerFlags(PlayerControl player)
switch (flag)
{
case PlayerFlag.HasModifier:
if (player.GetSubroles().IsEmpty()) return false;
if (!player.GetSubroles().IsEmpty()) return true;
break;
case PlayerFlag.HasNoModifier:
if (!player.GetSubroles().IsEmpty()) return false;
if (player.GetSubroles().IsEmpty()) return true;
break;
default:
VentLogger.Warn($"PlayerFlag {flag} is not properly setup and will not result in a proper conditional validation.", "VerifyPlayerFlags");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using Lotus.API.Odyssey;
using Lotus.Extensions;
using Lotus.Roles;
using Lotus.Statuses;
using VentLib.Utilities.Collections;
using VentLib.Utilities.Extensions;

namespace Lotus.Managers.Templates.Models.Units.Impl;

Expand All @@ -26,6 +21,6 @@ public bool VerifyStatus(PlayerControl? player)
{
if (player == null) return true;
statusesLower ??= Values.Select(r => r.ToLower()).ToHashSet();
return statusesLower.Any(status => Game.MatchData.Statuses.GetOrCompute(player.PlayerId, () => new RemoteList<IStatus>()).Any(st => st.Name.ToLower().Equals(status.ToLower())));
return statusesLower.Any(status => MatchData.GetStatuses(player)?.Any(st => st.Name.ToLower().Equals(status.ToLower())) ?? false);
}
}
11 changes: 4 additions & 7 deletions src/Managers/Templates/Models/Units/TemplateUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Lotus.Factions.Interfaces;
using Lotus.Managers.Templates.Models.Backing;
using Lotus.Roles;
using Lotus.Roles.Interfaces;
using Lotus.Roles.Subroles;
using VentLib.Options;
using VentLib.Utilities;
Expand Down Expand Up @@ -112,13 +113,9 @@ public static string FormatStatic(string text, object? obj = null)
{ "Mods", ShowModifiers },
{ "ModsDescriptive", ModifierText },
{ "MyRole", player => MyRoleCommand.GenerateMyRoleText(((PlayerControl)player).GetCustomRole()) },
{ "TasksComplete", QW(p => p.Data.Tasks.ToArray().Count(t => t.Complete).ToString() )},
{ "TotalTasks", QW(p => p.Data.Tasks.Count.ToString() )},
{ "TasksRemaining", QW(p =>
{
GameData.TaskInfo[] tasks = p.Data.Tasks.ToArray();
return (tasks.Count(t => t.Complete) - tasks.Count(t => !t.Complete)).ToString();
})},
{ "TasksComplete", QW(p => (p.GetCustomRole() is ITaskHolderRole tr ? tr.CompleteTasks : -1).ToString() )},
{ "TotalTasks", QW(p => (p.GetCustomRole() is ITaskHolderRole tr ? tr.TotalTasks : -1).ToString() )},
{ "TasksRemaining", QW(p => (p.GetCustomRole() is ITaskHolderRole tr ? tr.TotalTasks - tr.CompleteTasks : -1).ToString())},

{ "Role_Name", role => ((CustomRole) role).RoleName },
{ "Role_Description", role => ((CustomRole) role).Description },
Expand Down
13 changes: 10 additions & 3 deletions src/Managers/Templates/TemplateTriggers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public class TemplateTriggers
public static Dictionary<string, TriggerBinder> TriggerHooks = new()
{
{ "PlayerDeath", (key, action) => Hooks.PlayerHooks.PlayerDeathHook.Bind(key, action, true) },
{ "PlayerExiled", (key, action) => Hooks.PlayerHooks.PlayerExiledHook.Bind(key, action, true) },
{ "PlayerDisconnect", (key, action) => Hooks.PlayerHooks.PlayerDisconnectHook.Bind(key, action, true) },
{ "PlayerChat", (key, action) => Hooks.PlayerHooks.PlayerMessageHook.Bind(key, action, true) },
{ "StatusReceived", (key, action) => Hooks.PlayerHooks.PlayerMessageHook.Bind(key, action, true) },
{ "StatusReceived", (key, action) => Hooks.ModHooks.StatusReceivedHook.Bind(key, action, true) },
{ "TaskComplete", (key, action) => Hooks.PlayerHooks.PlayerTaskCompleteHook.Bind(key, action, true) },
{ "ForceEndGame", (key, action) => Hooks.ResultHooks.ForceEndGameHook.Bind(key, action, true) },
};

public static Dictionary<Type, Func<IHookEvent, ResolvedTrigger>> TriggerResolvers = new()
Expand All @@ -30,10 +30,17 @@ public class TemplateTriggers

{ typeof(PlayerTaskHookEvent), he => ResultFromPlayerTaskHook((PlayerTaskHookEvent)he) },

{ typeof(PlayerDeathHookEvent), he => ResultFromPlayerHook((PlayerHookEvent)he) },
{ typeof(PlayerMurderHookEvent), he => ResultFromPlayerHook((PlayerDeathHookEvent)he) },
{ typeof(PlayerDeathHookEvent), he => ResultFromPlayerHook((PlayerDeathHookEvent)he) },
{ typeof(PlayerHookEvent), he => ResultFromPlayerHook((PlayerHookEvent)he) },
{ typeof(EmptyHookEvent), he => ResultFromEmptyHook((EmptyHookEvent)he) },
};

public static ResolvedTrigger ResultFromEmptyHook(EmptyHookEvent _)
{
return new ResolvedTrigger { Player = PlayerControl.LocalPlayer, Data = PlayerControl.LocalPlayer.name };
}

public static ResolvedTrigger ResultFromPlayerStatusHook(PlayerStatusReceivedHook playerHookEvent)
{
return new ResolvedTrigger { Player = playerHookEvent.Player, Data = playerHookEvent.Status.Name };
Expand Down
2 changes: 1 addition & 1 deletion src/Options/General/AdminOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private class AdminOptionTranslations
[Localized("HostGM")]
public static string HostGmText = "Host GM";

[Localized("AutoKick", ForceOverride = true)]
[Localized("AutoKick")]
public static string AutoKickText = "Chat Auto Kick";

[Localized("AutoKickNoFriendcode")]
Expand Down
1 change: 1 addition & 0 deletions src/Patches/Network/PlayerLeavePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static void Postfix(AmongUsClient __instance, [HarmonyArgument(0)] Client
if (Game.State is GameState.InLobby)
{
PlayerJoinPatch.CheckAutostart();
Hooks.PlayerHooks.PlayerDisconnectHook.Propagate(new PlayerHookEvent(data.Character));
return;
}

Expand Down
Loading

0 comments on commit b003c7b

Please sign in to comment.