Skip to content

New Feature: Support Convert to another type.#2294

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

New Feature: Support Convert to another type.#2294
frg2089 wants to merge 9 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

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
Comment on lines +581 to +585
// Carry over the vehicle's move order
pUnit->SetDestination(savedDestination, true);
pUnit->QueueMission(savedMission, false);
pUnit->NextMission();
pUnit->SetTarget(savedTarget);

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.

Not quite sure about the inheritance status section. MissionStatus may also be considered. And whether buildings should skip the inheritance of some attributes.

@TaranDahl TaranDahl Jul 19, 2026

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.

@DeathFishAtEase DeathFishAtEase Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Huh,

  • Q: Should a building that has UndeploysInto inherit the destination?

This kind of issue might need a toggle.

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.

Building has no destination.

@DeathFishAtEase DeathFishAtEase Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

no destination

That is an example of behavior such as a moving vehicle immediately undeploying after conversion and continuing to the target location.

Alternatively: if a unit becomes a building under unload mission, should the building inherit the unload mission to attack the ground directly below... and so on.

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>
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