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

Add LocalizedDatasetPrototype #28310

Merged
merged 5 commits into from
May 28, 2024

Conversation

Tayrtahn
Copy link
Member

@Tayrtahn Tayrtahn commented May 27, 2024

About the PR

Adds a variant of DatasetPrototype specifically for cases where a dataset of sequentially-numbered LocId strings is desired (like tips, word lists, advertisements, etc).

Why / Balance

This saves you from having to make a dumb boilerplate YAML file that just lists all the LocIds like:

- type: dataset
  id: Test
  values:
  - test-string-1
  - test-string-2
  - test-string-3
  - test-string-4
   ...
  - test-string-128
  - test-string-129

and instead lets you just do:

- type: localizedDataset
  id: Test
  values:
    prefix: test-string-
    count: 129

Technical details

On the C# side, LocalizedDatasetPrototype can be used just like a regular DatasetPrototype - Values implements IReadOnlyList, so you can index it, iterate through it, or (the most likely case) pass it to RobustRandom.Pick to get a random entry.

Behind the scenes though, any operations on Values will actually just construct the LocId strings from the prefix and index number. This should also cut down on the memory usage of localized datasets, since they won't need to actually store all the LocIds and can just construct them as needed.

Also includes a unit test to demonstrate that it works.

Media

Code.

  • I have added screenshots/videos to this PR showcasing its changes ingame, or this PR does not require an ingame showcase

Breaking changes

Changelog

Nah.

@mirrorcult
Copy link
Contributor

very nice

@Tayrtahn Tayrtahn mentioned this pull request May 27, 2024
@TheShuEd
Copy link
Member

Woah, very cool

@TheShuEd
Copy link
Member

LocId datasets from random books are worth translating to this system as well

Copy link
Member

@EmoGarbage404 EmoGarbage404 left a comment

Choose a reason for hiding this comment

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

can you add a evenly-weighted random pick method for parity with normal datasets?

@Tayrtahn
Copy link
Member Author

can you add a evenly-weighted random pick method for parity with normal datasets?

In SharedRandomExtensions? Sure.

@Tayrtahn Tayrtahn requested a review from EmoGarbage404 May 28, 2024 00:19
@github-actions github-actions bot added the S: Needs Review Status: Requires additional reviews before being fully accepted label May 28, 2024
@AJCM-git AJCM-git merged commit 0bca934 into space-wizards:master May 28, 2024
11 checks passed
@Tayrtahn Tayrtahn deleted the localized-dataset-prototype branch May 28, 2024 18:44
Erisfiregamer1 pushed a commit to The-Arcadis-Team/arc-station-14 that referenced this pull request Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: Needs Review Status: Requires additional reviews before being fully accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants