Skip to content

Add methods for runtime creation and deletion of prototypes without YAML#6609

Open
MACMAN2003 wants to merge 1 commit into
space-wizards:masterfrom
MACMAN2003:prototype-load-remove-api
Open

Add methods for runtime creation and deletion of prototypes without YAML#6609
MACMAN2003 wants to merge 1 commit into
space-wizards:masterfrom
MACMAN2003:prototype-load-remove-api

Conversation

@MACMAN2003

Copy link
Copy Markdown

might fulfill #4814 probably?

Added two methods to IPrototypeManager for dynamically creating a prototype from a filled out MappingDataNode and deleting a prototype using and it's id string.

Concerning the creation method, it is quite makeshift compared to what I would consider ideal but it was the simplest way that I could think of that did not involve insane levels of reflection.
Utilizing the creation method involves having to assemble a MappingDataNode and all of its DataNode children recursively, which is a little painful, but not as much as generating an entire yaml file in the code. It does involve having to use a debugger to see how the prototypes appear in memory.

The deletion method removes the provided id from the kind . It's there as a way to remove prototypes if they are round-dependent OR as a safeguard against the attack of the 90000 rogue prototypes.

Both methods were tested and confirmed to work with Content.Shared.Chemistry.Reagent.ReagentPrototype

Added two methods to IPrototypeManager for dynamically creating a prototype from a filled out MappingDataNode and deleting a prototype.
Comment on lines +421 to +424
/// To properly use this, you will need to make <paramref name="data"/> resemble how other prototypes of its kind appear in
/// _kinds' KindData.Results or KindData.RawResults. <br/>
/// You will need to utilize a debugger and a breakpoint if you want to get a reference of how the prototypes are
/// represented in _kinds.

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.

Uh, what?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I can't think of a way to word it accurately and concisely.

Like if one prototype kind has a "foo" ValueDataNode and a "bar" SequenceDataNode in every instance then the MappingDataNode provided to the method needs to have both "foo" and "bar" nodes in its children.

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.

2 participants