Skip to content

Update Production's Faction when its owner changes - #21219

Merged
PunkPun merged 1 commit into
OpenRA:bleedfrom
michaeldgg2:Production-Update-Faction
Sep 14, 2024
Merged

PunkPun merged 1 commit into
OpenRA:bleedfrom
michaeldgg2:Production-Update-Faction

Conversation

@michaeldgg2

Copy link
Copy Markdown
Contributor

This PR makes it possible to optionally change Production.Faction (i.e. custom property on Production trait, not faction of Player) when the actor's owner changes. It fixes the discrepancy between faction stored in Production trait and the faction of the actual owner of the actor.

This behavior is however disabled by default to keep backward compatibility. Each mod should decide, which actors are going to get Production trait that behaves like this.

Related to #21162 and #20705.

@abcdefg30 abcdefg30 left a comment

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.

Untested but changes lgtm.

[Desc("e.g. Infantry, Vehicles, Aircraft, Buildings")]
public readonly string[] Produces = Array.Empty<string>();

[Desc("When owner is changed, should the Faction be updated to the new owner's faction?")]

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.

I think this should explain what "faction" really means. Afaik it changes so that the produced units are of your own faction, meaning that if you capture an enemy war factory you'd no longer be able to build an MCV of their faction?

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.

In case of CNC/RA-like mod, yes. If it's another mod, it depends on how other stuff (like tech tree) is implemented. In case of OpenE2140, our prerequisites are mainly research technologies (custom feature), some of which are faction-specific and some are same for both factions. And as such, this allow producing units of the other faction, when production factory of that other faction is captured.

Like I said in the PR comment, it's up to a mod developer to choose what behavior they want. It seems it's likely going to be used in other mods (apart from OpenE2140), since @dnqbob has been requesting this feature/fix as well.

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.

But in base openra the bug is just about the UI no? It's something that should be fixed in TS as well

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.

Again it depends on the mod. For ORA default mods (TS too) I assume the behavior needs to stay the same (i.e. Faction does not change after owner change), hence the switch defaults to false.

Also it's not just UI thing, there are other places, where Production.Faction is used, such as PlaceBuildingOrderGenerator (in VariantWrapper) or *Production classes.

I already had a UI-only solution for this bug (#20705), but that was rejected.

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.

@PunkPun if you capture a Nod war factory in TS you will want to be able to build Nod units.

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.

Hence, this is (Production.UpdateFactionOnOwnerChange) entirely optional and so is the Sticky flag on ProductionQueue. I can rename Sticky flag, but that would require update rule.

@dnqbob dnqbob Dec 15, 2023 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually I hope the bug below can be fixed in this PR, for #21162

This issue (Production UI upgrade) has some very nasty side effect on fixing.

You need a test on owner change before/after disable or enable. There can be some bugs that owner changed facility can still produce on old owner's production UI.

It is not only the problem of faction change, it is the problem of when you losing control of production actor (owner changed) it is still on your production UI and you can produce unit on that actor.

@RoosterDragon RoosterDragon left a comment

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.

LGTM

@PunkPun
PunkPun merged commit 2612e7f into OpenRA:bleed Sep 14, 2024
@PunkPun

PunkPun commented Sep 14, 2024

Copy link
Copy Markdown
Member

changelog

@michaeldgg2
michaeldgg2 deleted the Production-Update-Faction branch September 20, 2024 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants