Skip to content

[API] Faction Context API#886

Open
Sakura-TA wants to merge 2 commits intorwmt:devfrom
Sakura-TA:faction-context-api
Open

[API] Faction Context API#886
Sakura-TA wants to merge 2 commits intorwmt:devfrom
Sakura-TA:faction-context-api

Conversation

@Sakura-TA
Copy link
Copy Markdown
Contributor

@Sakura-TA Sakura-TA commented Apr 18, 2026

paired with rwmt/MultiplayerAPI#13
Hope it works correctly

if (Multiplayer.Client == null || ignore) return true;

var spectatorId = Multiplayer.WorldComp.spectatorFaction.loadID;
var spectatorId = Multiplayer.WorldComp.spectatorFaction?.loadID;
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.

Can null spectatorFaction ever happen? Seems to be forcefully installed even when there is none during MultiplayerWorldComp.ExposeData, it's not tested for null anywhere else either.

Copy link
Copy Markdown
Contributor Author

@Sakura-TA Sakura-TA Apr 19, 2026

Choose a reason for hiding this comment

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

Met one time with VAE...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If I remember correctly, read it at MapComponent.FinalizeInit can cause issue, I was using new API patching this
https://github.com/Vanilla-Expanded/VanillaAspirationsExpanded/blob/abb0c64efc7861cc04a0f1909eeaa5a4f589aed0/1.5/Source/VAspirE/World%20and%20Map%20Components/WorldComponent_PawnList.cs#L22

Likely when MapComponent.FinalizeInit and WorldComponent.FinalizeInit is calling?


public void PopFaction(Map map = null) => FactionExtensions.PopFaction(map);

public void RepeatForWorldFactions(Action action)
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.

Wouldn't it be better to share a readonly faction list?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You mean like we implement a IFacionData to expose factionDatas and ask modders to iter through it themselves?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm struggling with this idea exposing factionData, cuz push/popfaction is serving situations that we set faction data of distinct faction and RepeatFaction serves the iterator through all player-factions so I think all the usages are covered?
Still not a big problem if modders using it wisely though.

@notfood notfood added enhancement New feature or request. 1.6 Fixes or bugs relating to 1.6 (Not Odyssey). labels Apr 18, 2026
@notfood notfood moved this to In review in 1.6 and Odyssey Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.6 Fixes or bugs relating to 1.6 (Not Odyssey). enhancement New feature or request.

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

2 participants