Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded End Game Summary #205

Open
wants to merge 2 commits into
base: mainline
Choose a base branch
from

Conversation

VirusTLNR
Copy link

changes are as follows:-
1:- player data is updated when the hud is updated (pretty much all through the game)
2:- history of roles is now tracked
3:- made the text smaller for the original game summary rows so they dont spill behind the victory/defeat picture
4:- made the role history clearly different from the main summary row
5:- all winners are sorted to be at the top, losers at the bottom (random sort order still applies.

example pictures (right one is slightly bugged but the bug is related to phantom, not this PR.
image

changes are as follows:-
1:- player data is updated when the hud is updated (pretty much all through the game)
2:- history of roles is now tracked
3:- made the text smaller for the original game summary rows so they dont spill behind the victory/defeat picture
4:- made the role history clearly different from the main summary row
5:- all winners are sorted to be at the top, losers at the bottom (random sort order still applies.
[HarmonyPriority(Priority.Last)]
public static void Postfix(HudManager __instance)
{
if (EndGameSummary.AdditionalTempData.updateFlag)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using the boolean flag, can we get this from the game status somehow?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will have a look at this when i get the chance as im not a big fan of using a "flag" variable either.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have tried this by replacing that if statement with the following one which works..

if(AmongUsClient.Instance.GameState == InnerNet.InnerNetClient.GameStates.Started)

but it leads to this error being spammed in the chat log, the flag method was put in to avoid this being spammed into the logs, so any suggestions on how to avoid this would be handy.

[Error : Detour] System.NullReferenceException: Object reference not set to an instance of an object
at TownOfUs.Patches.EndGameSummary.UpdatePlayerInfo () [0x00067] in :0
at TownOfUs.Patches.EndGameSummary.Postfix (HudManager __instance) [0x00013] in :0
at (wrapper dynamic-method) HudManager.DMDHudManager::Update(HudManager)
at (wrapper dynamic-method) MonoMod.Utils.DynamicMethodDefinition.(il2cpp -> managed) Update(intptr,UnhollowerBaseLib.Runtime.Il2CppMethodInfo*)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also.. the "start" RPC is where i put the flag change... so im kind of using the change of game state already.

foreach (var player in PlayerControl.AllPlayerControls)
{
var role = Role.GetRole(player);
if (role != null && (AdditionalTempData.roleHistory.FindAll(x => x.Key == player.PlayerId).Count==0 ||AdditionalTempData.roleHistory.Last(x => x.Key == player.PlayerId).Value != role))
Copy link
Owner

@Anusien Anusien Mar 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This find is a bit cumbersome/inefficient; I wonder if instead of List<KeyValuePair<byte, Role>>, something like Map<byte, List<Role>> might work better? And could we store that in PlayerInfo?

Also hanging onto the actual Role class is unnecessary, maybe we should just hold onto the RoleEnum?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fiddled around a lot with RoleEnum vs Role, i can have another fiddle at another time, but my time for coding atm is really limited, it works as is.

regarding storing the role history inside player info, its a lot harder to access rolehistory within playerinfo, i tried to integrate it in and found it much simpler to keep it seperate.

regarding Map<byte,List>, i am not aware of "Map" or what it does, the aim of the list of KeyValuePair's is to then have a list of player IDs to cycle through, to which you can pull the roles in order of addition to the list, there maybe a better way of doing it, but i was not aware at the time of writing it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C# might call it a Dictionary instead of a Map (well, a Map is a kind of associative type and a Dictionary is a Map implemented with a hashtable). Constant time accesses instead of linear.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I get time to look at this I will look into changing it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, had a look at it, and the reason why they are seperate is because the game information is collected from scratch every time it runs, it ignores the previous information, and re-aquires it.

so to change this i would have to change how it all works, so instead of it always adding new data, it replaces old data, this will take some time

Part 1.. more complex changes to hopefully follow.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants