MovingBlocks / DestinationSol

Official continuation of Destination Sol, the great fun little arcade space shooter from http://sourceforge.net/projects/destinationsol/ Modules live at https://github.com/DestinationSol/
Apache License 2.0
325 stars 122 forks source link

Collision mesh building #625

Open IsaacLic opened 2 years ago

IsaacLic commented 2 years ago

Description

This PR generifies collision mesh creation. Rather than needing to create a separate system for each type of Body with a new instance of CollisionMeshLoader, the new CollisionMeshBuilderSystem handles all Body creation.

The BodyLinked component has two new fields - one for the JSON path to the mesh data, and another for the schema file that details how the data is laid out. When an entity has a BodyLinked component, the system will build a Body using the mesh data when it receives a GenerateBodyEvent (which will happen at the next tick).

Testing

Shoot the testing asteroid (the golden asteroid visible on startup). The projectile should still collide with it, so the asteroid should be destroyed. Then try flying into the rubble. The ship should not pass through the rubble.