Skip to content

New Feature: Support Convert to another type. - #2294

Open
frg2089 wants to merge 18 commits into
Phobos-developers:developfrom
ShimakazeProject:develop
Open

New Feature: Support Convert to another type.#2294
frg2089 wants to merge 18 commits into
Phobos-developers:developfrom
ShimakazeProject:develop

Conversation

@frg2089

@frg2089 frg2089 commented Jul 18, 2026

Copy link
Copy Markdown

Summary

Refactored the underlying type conversion system (ConvertToType / ConvertToTypeEx) to support cross-type conversion between all TechnoType classes except AircraftType. Added UndeploysInto.ConvertTo as a new conversion trigger on BuildingType.

Changes

Core: rewritten conversion logic

  • ConvertToType and new ConvertToTypeEx now handle cross-type conversion via creating a new object + destroying the old one, supporting InfantryType, UnitType, and BuildingType.
  • AircraftType is only supported for same-type conversion (in-place type pointer update).
  • Deferred conversion via PendingConvertTechnoType processed in OnEarlyUpdate — used when the source unit needs to finish its current animation frame before being destroyed.

This improvement applies to all existing conversion paths (Convert.Deploy, Convert.Undeploy, Convert.HumanToComputer, Convert.ComputerToHuman, etc.).

New feature: UndeploysInto.ConvertTo

  • BuildingType tag UndeploysInto.ConvertTo specifies a target TechnoType.
  • After UndeploysInto creates the vehicle, it is converted to the target type on the next frame.
  • The resulting unit inherits the vehicle's move order, destination, and selection state.
  • Mind control, shields, invulnerability, and attached effects are transferred.

Refactor

  • Moved TransferMindControlOnDeploy from Hooks.DeploysInto.cpp into TechnoExt as a reusable static method.

Selection preservation

  • Both deploy (infantry → building) and undeploy convert (vehicle → other) now preserve the original unit's selection state on the new unit.

Documentation

Updated New-or-Enhanced-Logics.md with documentation for UndeploysInto.ConvertTo, the expanded type support in Convert.Deploy / Convert.Undeploy, and a warning that cross-type conversion creates a new object and destroys the old one.

Files Changed

File Change
src/Ext/Techno/Body.cpp ConvertToTypeEx cross-type conversion, ConvertToType same-type fallback, property transfer
src/Ext/Techno/Body.h PendingConvertTechnoType, static method declarations
src/Ext/Techno/Body.Update.cpp Deferred conversion processing
src/Ext/Unit/Hooks.DeploysInto.cpp Delegate to TechnoExt, add UndeploysInto.ConvertTo hook
src/Ext/BuildingType/Body.h/.cpp UndeploysInto.ConvertTo tag
docs/New-or-Enhanced-Logics.md Documentation

@frg2089 frg2089 changed the title Refactor type conversion logic to support cross-type conversion and add UndeploysInto.ConvertTo trigger New Feature: Support Convert to another type. Jul 18, 2026
Comment thread src/Ext/Techno/Body.cpp
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Techno/Body.cpp Outdated
Comment thread src/Ext/Unit/Hooks.DeploysInto.cpp Outdated
Comment thread src/Ext/Techno/Body.Update.cpp Outdated
Comment thread docs/New-or-Enhanced-Logics.md Outdated
@frg2089
frg2089 marked this pull request as draft July 18, 2026 17:38
@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@frg2089
frg2089 marked this pull request as ready for review July 19, 2026 02:21
Comment thread src/Ext/Techno/Body.cpp
frg2089 added 9 commits July 20, 2026 10:55
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
… space

Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
frg2089 added 8 commits July 21, 2026 14:29
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
Signed-off-by: 舰队的偶像-岛风酱! <frg2089@outlook.com>
@frg2089
frg2089 requested a review from TaranDahl July 23, 2026 09:17

@TaranDahl TaranDahl left a comment

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.

I see no other issues.

@TaranDahl TaranDahl added Needs testing ⚙️T1 T1 maintainer review is sufficient labels Jul 23, 2026
@TaranDahl
TaranDahl requested a review from NetsuNegi July 23, 2026 10:27
@frg2089

frg2089 commented Jul 26, 2026

Copy link
Copy Markdown
Author

喵?

@TaranDahl

Copy link
Copy Markdown
Contributor

喵?

Since this is your first PR submission, your code will need reviews from more maintainers before it can be merged. This is the rule of Phobos.

@frg2089

frg2089 commented Jul 26, 2026

Copy link
Copy Markdown
Author

Since this is your first PR submission, your code will need reviews from more maintainers before it can be merged. This is the rule of Phobos.

OK, I will stop resolving the conflict before there are further results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs testing ⚙️T1 T1 maintainer review is sufficient

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants