Skip to content

Add partial prototypes, for defining and modifying prototype data with the same ID in different files - #6923

Open
DrSmugleaf wants to merge 5 commits into
masterfrom
feature/partial-prototypes
Open

Add partial prototypes, for defining and modifying prototype data with the same ID in different files#6923
DrSmugleaf wants to merge 5 commits into
masterfrom
feature/partial-prototypes

Conversation

@DrSmugleaf

@DrSmugleaf DrSmugleaf commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Doc bible attached

For downstreams of downstreams, you can specify the load order:

PartialDirectory(
    new ResPath("/Prototypes/_ForkOne"),
    new ResPath("/Prototypes/_ForkTwo")
);

Or

PartialDirectory(new ResPath("/Prototypes/_ForkOne"));
PartialDirectory(new ResPath("/Prototypes/_ForkTwo"));

Non partial directories are loaded before any partial ones.

Examples:

Add three loadouts and remove one:

- type: loadoutGroup
  id: MailTechnicianJumpsuit
  loadouts:
  - CargoTechnicianJumpsuitAlt
  - CargoTechnicianJumpsuitFormal
  - CargoTechnicianJumpskirtFormal
  - !Remove MailTechnicianJumpsuitSenior

Remove a component and remove a spawned from Butcherable:

- type: entity
  id: BaseMobHuman
  components:
  - type: !Remove LanguageKnowledge
  - type: Butcherable
    spawned: !Remove {}

To make it not add the prototype if the original one does not exist or is later removed:

- type: !PartialOnly entity
  id: BaseMobHuman


public override void LoadDefaultPrototypes(Dictionary<Type, HashSet<string>>? changed = null)
{
PartialDirectory(new ResPath("/Prototypes/_Afterlight/"));

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.

Afterlight string

bool TryGetRandom<T>(IRobustRandom random, [NotNullWhen(true)] out IPrototype? prototype) where T : class, IPrototype;

/// <summary>
/// Like <see cref="PartialDirectory"/>, but only for a single file.

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.

Convention is no indent on xmldoc.

@deltanedas

Copy link
Copy Markdown
Contributor

should have a distinct syntax (probably partialType instead of type) so its easy to rg, as well as always being an error if a non-partial one doesnt exist by default imo. otherwise the lazy way of doing it for 99% of usecases results in broken prototypes that might survive yml linter

@DrSmugleaf

Copy link
Copy Markdown
Contributor Author

should have a distinct syntax (probably partialType instead of type) so its easy to rg, as well as always being an error if a non-partial one doesnt exist by default imo. otherwise the lazy way of doing it for 99% of usecases results in broken prototypes that might survive yml linter

One of the big things this is trying to fix is porting YML between downstreams being mighty annoying, if it always threw an error that would still be almost as annoying
I originally had it throw an error, I could make that configurable if that's wanted, but without it it makes it easier to lint away if you wanted to, if it threw an exception you would need to catch that in the linter, or a test

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.

3 participants