stefanhendriks / Dune-II---The-Maker

A remake of the classic Dune 2 - The Building of a Dynasty (by Westwood Studios) with several enhancements. Like: higher screenresolutions, zooming, multiselect, skirmish play, etc.
https://www.dune2themaker.com
301 stars 26 forks source link

Refactor Carry-all logic so that "bringing new unit" and "transferring existing unit" is the same #584

Open stefanhendriks opened 1 year ago

stefanhendriks commented 1 year ago

Atm the code has a distinction for carry-all's bringing a new unit (it will spawn a new unit when it is at the destination) - or when transferring an existing unit (it remembers the ID of the unit being transferred, the unit that is being transferred is in a 'sort of dead' state, which is used to make it disappear on the map and not interact with other units/bullets/etc).

I think a better way would be to have a unit always spawned, then make it being transferred. Meaning, when a 'new' unit has to be brought to the map (ie a Harvester to a refinery), it should already be spawned. This makes the "how many harvesters do I have" logic a lot easier too when not having to deal with the weird "new to be spawned unit type" edge case.

And, even better, we might be even be able to make a carry-all to bring over more than 1 unit. Simply by having a vector of unit ids to bring over instead of 1 id. (used for OG Dune 2 reinforcements).