[PATCH] Packing and unpacking units into structure and vice versa
|Reported by:||Doménique||Owned by:|
|Priority:||Nice to Have||Milestone:||Alpha 21|
|Component:||UI & Simulation||Keywords:||patch|
Description (last modified by )
The attached patch allows units not just to unpack into another unit entity but also into a structure entity. This enables the use of mobile civ centres and other movable structures for future nomadic tribes.
With the current civilisations of 0 A.D. this patch may not be directly useful, so while I assigned it to Alpha 14 it may be better suited for a later point. I implemented it for a mini civ I made some time ago which you can find here for testing purposes: https://github.com/dvangennip/amazones-0AD
The core changes of this patch involve enabling pack/unpack commands for structure entities, plus the transfer of any garrisoned units and production queues from the old entity to the new. So if the old entity can garrison cavalry and infantry units, but packing up into a mobile cart entity which cannot garrison cavalry, the cavalry will ungarrison while infantry may remain garrisoned. A similar eligibility check applies for any production batches. If the new entity also allows a certain batch to be produced, it will transfer, otherwise it will reset (and funds restored, as per the default behaviour).
This patch would thus also allow transforming one building into another, which might be useful if someone wants to implement building upgrades on phase change (or any other cue). For this reason I feel that the Pack component could be renamed to Transform to better capture its usefulness and perhaps unified with unit Promotion (there is similar code in both components), although that is beyond this patch.