beyond-all-reason / spring

A powerful free cross-platform RTS game engine
https://beyond-all-reason.github.io/spring/
Other
190 stars 97 forks source link

Bar105 allow unit def waterline #1414

Closed marcushutchings closed 1 month ago

marcushutchings commented 4 months ago

This should be merged AFTER https://github.com/beyond-all-reason/spring/pull/1402 - it depends on the changes from that PR and so the files changed list will look huge until the previously mentioned PR is merged.

MoveDef overrides waterline for alignment of beahviour between movement and pathing systems; however, we've found issues where several units want to use the same MoveDef (to cut down on number of MoveDefs used), but need different waterline values to make them float on water and look correct.

This change allows the MoveDef to be configured to override or not the waterline used by units with the new MoveDef value overrideUnitWaterline. It is enabled by default. Setting it to false, will have units use UnitDef waterline instead for floating on the surface of water, which will impact how the unit is drawn and for collisions with projectiles. It also necessitates the movement and pathing systems to fallback to an older and simple water collision system that was used when only the MoveDef was avaialble (before it had a waterline field.)

This change (when used) means that such units, when floating on water, will only collide with units that are not completely submerged in water. I.e. they will not collide with units considered fully submerged underwater, even if it looks like the underwater part of the floating unit would pass through (i.e. collide) with the top of the underwater unit. This is neccessary to ensure the movement and pathing systems have a consistent understanding and agreement of where a unit can go, so to avoid units getting stuck in water.