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

Entity.SourceData and SourceId, provide way to efficiently search by EntityData name #879

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

JaThePlayer
Copy link
Member

@JaThePlayer JaThePlayer commented Feb 8, 2025

Second take on the TypeHelper PR, considering the previous one is dead.

  • Added Entity.SourceData, Entity.SourceId
  • Added Scene.FindEntitiesWithSid(string sid), which filters by entity data name, while still using the tracker.
  • Added Tracker.Get[Entities/Components]TrackIfNeeded, which add the type to the tracker if needed, used by the FindEntitiesWithSid method, but is useful in general.
  • Added a new Celste.Mod.Registry.EntityRegistry static class, with functions allowing for checking relations between c# types and EntityData names.
    These relations are generated as follows:
    • Vanilla entities are hardcoded
    • [CustomEntity] pointing to a ctor get registered automatically on mod load.
    • Dynamically as they occur, which guarantees they work even with the legacy Everest.Events.Level.LoadEntity event. This does mean that the sets returned by them are not guaranteed to be exhaustive - there could be relations that haven't occurred this session. However, that is fine realistically, because the main point of these APIs is to use them together with the tracker, in which case you don't care about searching for entity types that have never been instantiated anyway.
  • It seems like the PR which added Tracker.Refresh/AddTypeToTracker wasn't properly tested? In my testing, the function never did anything, and forcing a refresh caused a missing dictionary key crash for triggers. This PR fixes those bugs as well because these functions are crucial for FindEntitiesWithSid

image
image

@JaThePlayer
Copy link
Member Author

Tracker bugfix got moved to #883, which should be merged before this PR

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.

1 participant