#IntercomDisplayInfo

1 messages · Page 1 of 1 (latest)

halcyon smelt
#

Turns the Intercom into a live stats HUD. Displays the round timer, team counts, and Intercom status.

https://github.com/arannnn7808/IntercomDisplayInfo
https://github.com/arannnn7808/IntercomDisplayInfo/releases/tag/v1.0.0

GitHub

Turns the Intercom into a live stats HUD. Displays the round timer, team counts, and Intercom status. - arannnn7808/IntercomDisplayInfo

GitHub

This is the first release of IntercomDisplayInfo!

regal plank
royal basin
#

that very unoptimised

frozen crest
#

it doesnt work lol

halcyon smelt
halcyon smelt
halcyon smelt
#

and you have errors on console?

#

you use another plugin that change intercom text? Facility Managment?

royal basin
#

uhmm i have Round.LastClassList in Exiled as the best way

but LabAPI don't have it you could in the best way doing a foreach and count each team in a single loop instead of using .Count that make a loop for each time you use it @halcyon smelt

halcyon smelt
#

i change it later

scarlet sun
# halcyon smelt i change it later

There's a lot of ways to go about it
There are a couple that I like

byte classD = 0;
byte fforces = 0;
byte scientist = 0;
byte chaos = 0;
byte scps = 0;
foreach (var player in Player.ReadyList)
  _ = player.Team switch
  {
    Team.ClassD => classD++,
    Team.FoundationForces => fforces++,
    Team.Scientists => scientist++,
    Team.ChaosInsurgency => chaos++,
    Team.SCPs => scps++,
  };
var teamCounts = Player.ReadyList.GroupBy(p => p.Team).ToDictionary(g => g.Key, g => (byte)g.Count());
byte classD = teamCounts.GetValueOrDefault(Team.ClassD);
byte fforces = teamCounts.GetValueOrDefault(Team.FoundationForces);
byte scientist = teamCounts.GetValueOrDefault(Team.Scientists);
byte chaos = teamCounts.GetValueOrDefault(Team.ChaosInsurgency);
byte scps = teamCounts.GetValueOrDefault(Team.SCPs);
#

Personally, I'd recommend porting your plugin to use the
var teamCounts = Player.ReadyList.GroupBy(p => p.Team).ToDictionary(g => g.Key, g => (byte)g.Count());
And instead of using the individual variables, use their references in the teamCounts dictionary

#

Numeric types in C# default to 0 which is exactly what you want here (and is why I used .GetValueOrDefault)

#

Both things I posted you can just drag and drop to replace in your plugin

scarlet sun
#

I dropped a pull request implementing this + 2 other things I noticed from the IntercomPatch code
Feel free to use it if you'd like
I haven't tested it, but the changes should be good, so feel free to test it yourself if you're unsure

halcyon smelt
scarlet sun
# halcyon smelt New version! https://github.com/arannnn7808/IntercomDisplayInfo/releases/tag/v1....

I encourage you to consider merging my pull request
I ported the individual variables to the dictionary (like I mentioned earlier), fixed your rounding with the timer (I made it use ceiling instead of rounding), removed the subsequent unnecessary variable, removed the unnecessary brackets, and removed the unnecessary static function you introduced in the middle of the method
I mention it primarily because of the optimization
You optimized your code somewhat, but it's still not fully optimized like I did in the PR
You still use var for your counts, which will auto-type to int, and use up more memory
You still store the individual counts in memory as separate variables instead of as a dictionary (which would more sense for this purpose)

#

Don't mean to be pushy about it but I'm trying to offer a hand here in cleaning up the code a bit considering you're opening it to the public

halcyon smelt
royal basin
scarlet sun
#

I mean even if it's less optimized, it's still easier to read and manage, and is more scalable for other teams

royal basin
scarlet sun
#

I <3 linq

#

I also love Intellisense

#

I have a gif someone made for me when I talked about it that I saved and now I need one for linq too

worthy lark
#

🔥