Skip to content

feat(scoreboard): add objectives, display slots and teams - #158

Open
xRookieFight wants to merge 1 commit into
devfrom
feat/scoreboard-teams
Open

feat(scoreboard): add objectives, display slots and teams#158
xRookieFight wants to merge 1 commit into
devfrom
feat/scoreboard-teams

Conversation

@xRookieFight

Copy link
Copy Markdown
Contributor

Description

The scoreboard was a per-player sidebar of fake-player lines and nothing else: no objective anyone else could see, no other display slot, and no concept of a team.

  • Objectives, scores and teams live in one server-wide registry. Objectives are dummy ones whose scores the server sets, which is what every criterion other than the vanilla automatic ones amounts to.
  • All three display slots work - sidebar, list and belowname - each with its own objective, so showing one does not disturb another. A score change redraws whatever slot is showing it.
  • Teams carry a colour, prefix, suffix, friendly fire and name tag visibility. Bedrock has no team packet of its own, so a team does its work through the server: a member's name tag is decorated when it is sent, and two players on a team with friendly fire off cannot hurt each other.
  • /scoreboard objectives|players|teams covers add, remove, list, setdisplay, set, add, reset, join, leave and option. Its messages are the vanilla ones.

Related issue

Part of #143

Name tag visibility is stored and settable but not yet enforced per viewer: hiding a name from other teams means sending different metadata to different players, which the broadcast path does not do today.

Checklist

  • v -check . is clean
  • v test server/player, server/cmd/default, and the session combat/scoreboard/broadcast/entity-view/login tests are green
  • Follows the conventions in AGENTS.md (OOP, pub/capitalized exports, no import cycles, minimal comments)
  • Cross-session gameplay state is only mutated on its owning world's actor thread (via world_call/wr.submit/WorldTx), never through a global Hub actor
  • No unrelated changes bundled in

@nepinhum nepinhum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

plus:

  • scoreboard refresh itself is hilariously heavy (rebuilds every display slot by removing & recreating the objective and resending all scores to the entire server)

@@ -0,0 +1,50 @@
module scoreboard

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not convinced Team belongs in the core scoreboard implementation. And this PR turns scoreboard state into a server wide gameplay framework: membership now affects combat, name tags, formatting and potentially per viewer visibility.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bedrock-v/devs what do you think?

mut entries := proto.ScorePacketEntries{}
mut id := i64(1)
for entry, value in scores {
entries << proto.ScoreEntryChangeFakePlayer{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

All entries are emitted as ScoreEntryChangeFakePlayer including list and belowname. Those slots need scores associated with actual player/entity identities and the protocol already has ScoreEntryChangePlayer / ScoreEntryChangeEntity for that. Won't belowname in particular fail to attach the score to the player model?


// refresh_name_tags resends the name of every listed player, so a team's
// colour and prefix appear without them having to reconnect.
fn (mut h Hub) refresh_name_tags(names []string) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

refresh_name_tags() broadcasts SetActorDataPacket through the whole Hub. Shouldn't actor metadata updates follow the same visibility/world scoped path as other entity updates? Sessions in unrelated worlds may not even have this actor spawned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants